Sphinx builtin themes not found - templates

In my conf.py it says I should see the documentation for a list of builtin-themes. Now my first google hit leads me to http://www.sphinx-doc.org/en/stable/theming.html#builtin-themes . There are a bunch of themes in there which my sphinx does not know about. For example 'classic'.
in conf.py
html_theme = 'classic'
On my shell I do: sphinx-build -b html source build
writing output... [100%] index
Exception occurred:
File "~\appdata\local\programs\python\python35\lib\site-packages\sphinx\jinja2glue.py", line 200, in get_source
raise TemplateNotFound(template)
jinja2.exceptions.TemplateNotFound: about.html
sphinx version: 1.6.3.

I had same problem because I used alabaster theme before. There are a few lines in conf.py that are needed for alabaster and break other themes. You need to comment them out.
# Custom sidebar templates, must be a dictionary that maps document names
# to template names.
#
# This is required for the alabaster theme
# refs: http://alabaster.readthedocs.io/en/latest/installation.html#sidebars
# html_sidebars = {
# '**': [
# 'about.html',
# 'navigation.html',
# 'relations.html', # needs 'show_related': True theme option to display
# 'searchbox.html',
# 'donate.html',
# ]
# }

It is an issue after changing alabaster theme to another one that doesn't use about.html. Laurent said the workaround.
Issue:
https://github.com/sphinx-doc/sphinx/issues/3987

Related

Is there a way to directly make use of SMOTE to a xxx.csv in python-weka-wrapper3

For example,I have a data-set,which has 18 instances(class value:True:False=12:6),and it has 11 attributes.Can just make use SMOTE in python like in weka?
How can I make it by code?
enter image description here
Have you looked at the API examples and the example repository? These resources explain most if not all of the available functionality.
Here is an example of loading a CSV file and applying the SMOTE filter:
import weka.core.jvm as jvm
from weka.core.classes import from_commandline
from weka.core.packages import install_missing_package, installed_package
from weka.core.converters import load_any_file
jvm.start(packages=True)
# install SMOTE if necessary
installed = installed_package("SMOTE")
if not installed:
success, restart = install_missing_package("SMOTE")
if restart:
print("Please rerun script")
jvm.stop()
import sys
sys.exit(0)
# load data
data = load_any_file("/some/where/iris.csv", class_index="last")
# if the default parameters for loading the CSV file don't work,
# you need to configure the CSVLoader yourself and set the
# appropriate options (or even use a 3rd-party package):
# from weka.core.converters import Loader
# loader = Loader(classname="weka.core.converters.CSVLoader", options=[])
# data = loader.load_file("/some/where/iris.csv", class_index="last")
print(data.num_instances)
# apply SMOTE
# replace the command-line with the one that you can copy/paste from
# the Weka Explorer via right-click menu
smote = from_commandline("weka.filters.supervised.instance.SMOTE -C 0 -K 5 -P 100.0 -S 1", classname="weka.filters.Filter")
smote.inputformat(data)
filtered = smote.filter(data)
print(filtered.num_instances)
jvm.stop()

Django models aren't loaded yet

I am getting this error when I run make html in sphinx: http://pastebin.com/FjyigBJ9
Is this because the utils file is calling Frequency module before the models are registered?
What should be done to rectify it?
This is my conf.py:
#!/usr/bin/env python3
import sys
import os
import shlex
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
sys.path.insert(0, os.path.abspath('..'))
from django.conf import settings
settings.configure()
# -- General configuration ------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
#needs_sphinx = '1.0'
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.coverage',
]
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
# source_suffix = ['.rst', '.md']
source_suffix = '.rst'
# The encoding of source files.
#source_encoding = 'utf-8-sig'
# The master toctree document.
master_doc = 'index'
# General information about the project.
project = 'Locality Management'
copyright = '2015, DOne'
author = 'DOne'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '0.0.1'
# The full version, including alpha/beta/rc tags.
release = '0.0.1'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
#today = ''
# Else, today_fmt is used as the format for a strftime call.
#today_fmt = '%B %d, %Y'
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = ['_build']
# The reST default role (used for this markup: `text`) to use for all
# documents.
#default_role = None
# If true, '()' will be appended to :func: etc. cross-reference text.
#add_function_parentheses = True
# If true, the current module name will be prepended to all description
# unit titles (such as .. function::).
#add_module_names = True
# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
#show_authors = False
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
# A list of ignored prefixes for module index sorting.
#modindex_common_prefix = []
# If true, keep warnings as "system message" paragraphs in the built documents.
#keep_warnings = False
# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = False
# -- Options for HTML output ----------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = 'alabaster'
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#html_theme_options = {}
# Add any paths that contain custom themes here, relative to this directory.
#html_theme_path = []
# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
#html_title = None
# A shorter title for the navigation bar. Default is the same as html_title.
#html_short_title = None
# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
#html_logo = None
# The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
#html_favicon = None
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
# Add any extra paths that contain custom files (such as robots.txt or
# .htaccess) here, relative to this directory. These files are copied
# directly to the root of the documentation.
#html_extra_path = []
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
#html_last_updated_fmt = '%b %d, %Y'
# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
#html_use_smartypants = True
# Custom sidebar templates, maps document names to template names.
#html_sidebars = {}
# Additional templates that should be rendered to pages, maps page names to
# template names.
#html_additional_pages = {}
# If false, no module index is generated.
#html_domain_indices = True
# If false, no index is generated.
#html_use_index = True
# If true, the index is split into individual pages for each letter.
#html_split_index = False
# If true, links to the reST sources are added to the pages.
#html_show_sourcelink = True
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
#html_show_sphinx = True
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
#html_show_copyright = True
# If true, an OpenSearch description file will be output, and all pages will
# contain a <link> tag referring to it. The value of this option must be the
# base URL from which the finished HTML is served.
#html_use_opensearch = ''
# This is the file name suffix for HTML files (e.g. ".xhtml").
#html_file_suffix = None
# Language to be used for generating the HTML full-text search index.
# Sphinx supports the following languages:
# 'da', 'de', 'en', 'es', 'fi', 'fr', 'h', 'it', 'ja'
# 'nl', 'no', 'pt', 'ro', 'r', 'sv', 'tr'
#html_search_language = 'en'
# A dictionary with options for the search language support, empty by default.
# Now only 'ja' uses this config value
#html_search_options = {'type': 'default'}
# The name of a javascript file (relative to the configuration directory) that
# implements a search results scorer. If empty, the default will be used.
#html_search_scorer = 'scorer.js'
# Output file base name for HTML help builder.
htmlhelp_basename = 'LocalityManagementdoc'
# -- Options for LaTeX output ---------------------------------------------
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
#'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
#'preamble': '',
# Latex figure (float) alignment
#'figure_align': 'htbp',
}
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'LocalityManagement.tex', 'Locality Management Documentation',
'DOne', 'manual'),
]
# The name of an image file (relative to this directory) to place at the top of
# the title page.
#latex_logo = None
# For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters.
#latex_use_parts = False
# If true, show page references after internal links.
#latex_show_pagerefs = False
# If true, show URL addresses after external links.
#latex_show_urls = False
# Documents to append as an appendix to all manuals.
#latex_appendices = []
# If false, no module index is generated.
#latex_domain_indices = True
# -- Options for manual page output ---------------------------------------
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'localitymanagement', 'Locality Management Documentation',
[author], 1)
]
# If true, show URL addresses after external links.
#man_show_urls = False
# -- Options for Texinfo output -------------------------------------------
# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'LocalityManagement', 'Locality Management Documentation',
author, 'LocalityManagement', 'One line description of project.',
'Miscellaneous'),
]
# Documents to append as an appendix to all manuals.
#texinfo_appendices = []
# If false, no module index is generated.
#texinfo_domain_indices = True
# How to display URL addresses: 'footnote', 'no', or 'inline'.
#texinfo_show_urls = 'footnote'
# If true, do not generate a #detailmenu in the "Top" node's menu.
#texinfo_no_detailmenu = False
Writing
import django
os.environ['DJANGO_SETTINGS_MODULE'] = 'myproject.settings'
django.setup()
instead of
from django.conf import settings
settings.configure()
should do the trick.

Plone 4.3.x - grokcore.view - UserWarning: Found the following unassociated template after configuration

On a vanilla Plone 4.3.3 site (Unified Installer on Ubuntu 14.04.1LTS), and after updating buildout.cfg with the zopeskel and paster boiler plate stuff and running buildout, I successfully created a dexterity package in my src folder:
$ cd src
$ ../bin/zopeskel dexterity my.package
After updating buildout.cfg (adding my.package to the eggs section and src/my.package to the develop section) and running buildout, I added content to my new package:
$ cd my.package
$ ../../bin/paster addcontent dexterity_content
I called the new content type mytype, resulting in mytype.py, a templates folder called mytype_templates, etc.
Restarting Plone and.... so far, so good....
Then I add templates to the mytype_templates folder:
add.pt
edit.pt
view.pt
In the mytype.py file I added all the necessary imports, schema definition
Class Imytype(form.Schema, IImageScaleTraversable):
....
....
, etc, etc, and obviously also the view, add and edit classes:
class View(dexterity.DisplayForm):
grok.context(Imytype)
grok.require('zope2.View')
# Disable turn fieldsets to tabs behavior
enable_form_tabbing = False
def update(self):
super(View, self).update()
class Add(dexterity.AddForm):
grok.name('my.package.mytype')
# Disable turn fieldsets to tabs behavior
enable_form_tabbing = False
def __init__(self, context, request):
super(Add, self).__init__(context, request)
......
......
class Edit(dexterity.EditForm):
grok.context(Imytype)
# Disable turn fieldsets to tabs behavior
enable_form_tabbing = False
def update(self):
super(Edit, self).update()
......
......
When I restart my Plone site in foreground mode, I get the following messages:
2015-02-06 12:52:41 INFO ZServer HTTP server started at Fri Feb 6 12:52:41 2015
Hostname: 0.0.0.0
Port: 8080
/home/Plone434_site/buildout-cache/eggs/grokcore.view-2.8-py2.7.egg/grokcore/view/templatereg.py:261: UserWarning: Found the following unassociated template after configuration: /home/Plone434_site/zinstance/src/my.package/my/package/mytype_templates/edit.pt
warnings.warn(msg, UserWarning, 1)
/home/Plone434_site/buildout-cache/eggs/grokcore.view-2.8-py2.7.egg/grokcore/view/templatereg.py:261: UserWarning: Found the following unassociated template after configuration: /home/Plone434_site/zinstance/src/my.package/my/package/mytype_templates/add.pt
warnings.warn(msg, UserWarning, 1)
2015-02-06 12:52:46 INFO Zope Ready to handle requests
Seemingly grok successfully picks up the view.pt, but not the add.pt and edit.pt
This is confirmed by customizing the templates. Changes to view.pt renders fine, changes to add.pt and edit.pt have no results. Plone falls back on the default dexterity templates, as the add.pt and edit.pt are not grokked.
I found a work-around by adding the following:
....
from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
....
and to the Add class:
template = ViewPageTemplateFile('mytype_templates/add.pt')
and to the Edit class:
template = ViewPageTemplateFile('mytype_templates/edit.pt')
Obviously the error messages as listed above are still there, but at least it works and I can customize the add.pt and edit.pt.
Although I can live with this workaround, I am wondering why only the view.pt is grokked and not the add.pt and edit.pt.
Please notice that this (weird?) behavior was also duplicated using Plone 4.3.1, 4.3.2, 4.3.3 and 4.3.4
Any suggestions?
You have to declare the name, context, layer and schema of the views; use something like this (note the grok.layer method which maybe you're missing):
class AddForm(dexterity.AddForm):
grok.name('my.package.mytype')
grok.layer(Imylayer)
grok.context(Imytype)
schema = Imytype
def update(self):
super(AddForm, self).update()
...
class EditForm(dexterity.EditForm):
grok.context(Imytype)
grok.layer(Imylayer)
schema = Imytype
def update(self):
super(EditForm, self).update()
...
Alternatively you may skip the use of Grok at all and register everything via ZCML.
An example of this can be found in the collective.nitf package. There's a branch using Grok and a pull request removing it.

Using Mixins with Foundation 5

I've just installed Foundation 5 with Sass and am using Compass to watch my stylesheets. I wanted to know what's the best practice for adding my custom styles. I've already created a custom.scss file and am referencing it using #import "custom"; in my app.scss file.
If I wanted to go ahead and change the background colour of the body, for example, how would I go about doing this using the mixins. I'm adding:
$body-bg: red;
to my custom.scss file, but the body's background isn't changing. Should I just edit the _settings.scss file, that seems wrong...
Any idea what I'm doing wrong? Thanks in advance!
Here's my config.rb:
# Require any additional compass plugins here.
add_import_path "bower_components/foundation/scss"
# Set this to the root of your project when deployed:
http_path = "/"
css_dir = "stylesheets"
sass_dir = "scss"
images_dir = "images"
javascripts_dir = "javascripts"
# You can select your preferred output style here (can be overridden via the command line):
# output_style = :expanded or :nested or :compact or :compressed
# To enable relative paths to assets via compass helper functions. Uncomment:
# relative_assets = true
# To disable debugging comments that display the original location of your selectors. Uncomment:
# line_comments = false
# If you prefer the indented syntax, you might want to regenerate this
# project again passing --syntax sass, or you can uncomment this:
# preferred_syntax = :sass
# and then run:
# sass-convert -R --from scss --to sass sass scss && rm -rf sass && mv scss sass
In your case maybe would be better use these structure:
app.scss:
#import "custom"; //where you define variables for foundation such as $body-bg: red;
#import "foundation";
#import "other styles";
Yes, I've always just edited the _settings.scss file -- then use a decent file comparison (like Araxis Merge or Kaleidoscope to merge in new options as updates are made). If I have custom variables, I'll stick those at the top of the settings file (that need to effect both the settings and my global stuff after the fact).

Sphinx documentation and autodoc-skip-member

I'm building my sphinx doc for a django project the following way:
sphinx-apidoc app -o docs/source/app --force
Now it includes all of the South migrations which I don't want to have in my documentation. I now tried to exclude them the following way:
conf.py:
def skip_migrations(app, what, name, obj, skip, options):
return skip or (what == 'module' and name.find('Migration') != -1)\
or str(obj).find('migrations') != -1
def setup(app):
app.connect('autodoc-skip-member', skip_migrations)
Now they aren't documented anymore, but are still listed under modules. How can I exclude them?
You may exclude the rst files created for the migrations by adding them to the exclude_pattern in your conf.py file:
exclude_patterns = ["**/*.migrations.rst",]
Just avoid generating the .rst files with sphinx-apidoc in the first place:
sphinx-apidoc app -o docs/source/app --force */migrations/*
Patterns added after the module name are understood as excluded paths.