diff --git a/.gitignore b/.gitignore
index 298a9c370..be28908ec 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,7 @@
*.pyc
*.egg
*.so
+*.swp
.dir-locals.el
.ropeproject/
diff --git a/AUTHORS b/AUTHORS
index f30631c42..e1e4e8a59 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -24,11 +24,12 @@ Other contributors, listed alphabetically, are:
* Charles Duffy -- original graphviz extension
* Kevin Dunn -- MathJax extension
* Josip Dzolonga -- coverage builder
+* Buck Evan -- dummy builder
* Hernan Grecco -- search improvements
* Horst Gutmann -- internationalization support
* Martin Hans -- autodoc improvements
* Doug Hellmann -- graphviz improvements
-* Timotheus Kampik - stop words language fix
+* Timotheus Kampik - JS enhancements, stop words language fix
* Takeshi Komiya -- numref feature
* Dave Kuhlman -- original LaTeX writer
* Blaise Laflamme -- pyramid theme
@@ -50,6 +51,7 @@ Other contributors, listed alphabetically, are:
* Rob Ruana -- napoleon extension
* Stefan Seefeld -- toctree improvements
* Shibukawa Yoshiki -- pluggable search API and Japanese search
+* Taku Shimizu -- epub3 builder
* Antonio Valentino -- qthelp builder
* Filip Vavera -- napoleon todo directive
* Pauli Virtanen -- autodoc improvements, autosummary extension
@@ -60,6 +62,7 @@ Other contributors, listed alphabetically, are:
* Sebastian Wiesner -- image handling, distutils support
* Michael Wilson -- Intersphinx HTTP basic auth support
* Joel Wurtz -- cellspanning support in LaTeX
+* Hong Xu -- svg support in imgmath extension and various bug fixes
Many thanks for all contributions!
diff --git a/CHANGES b/CHANGES
index 8c935097d..96ebb2ec3 100644
--- a/CHANGES
+++ b/CHANGES
@@ -4,20 +4,55 @@ Release 1.4 (in development)
Incompatible changes
--------------------
+* Drop ``PorterStemmer`` package support. Use ``PyStemmer`` instead of ``PorterStemmer``
+ to accelerate stemming.
+* sphinx_rtd_theme has become optional. Please install it manually.
+ Refs #2087, #2086, #1845 and #2097. Thanks to Victor Zverovich.
+* #2231: Use DUrole instead of DUspan for custom roles in LaTeX writer. It enables to take
+ title of roles as an argument of custom macros.
+* #2022: 'Thumbs.db' and '.DS_Store' are added to `exclude_patterns` default values in
+ conf.py that will be provided on sphinx-quickstart.
+* #2027, #2208: The ``html_title`` accepts string values only. And The None value cannot be
+ accepted.
+* ``sphinx.ext.graphviz``: show graph image in inline by default
+* #2060, #2224: The ``manpage`` role now generate ``sphinx.addnodes.manpage`` node instead
+ of ``sphinx.addnodes.literal_emphasis`` node.
+* #2022: :confval:`html_extra_path` also copies dotfiles in the extra directory, and
+ refers to :confval:`exclude_patterns` to exclude extra files and directories.
+
Features added
--------------
-* #2092: add todo directive support in napoleon package
+* #2092: add todo directive support in napoleon package.
* #1962: when adding directives, roles or nodes from an extension, warn if such
an element is already present (built-in or added by another extension).
* #1909: Add "doc" references to Intersphinx inventories.
-* C++ type alias support (e.g., ``.. type:: T = int``)
+* C++ type alias support (e.g., ``.. type:: T = int``).
* C++ template support for classes, functions, type aliases, and variables (#1729, #1314).
* C++, added new scope management directives ``namespace-push`` and ``namespace-pop``.
+* #1970: Keyboard shortcuts to navigate Next and Previous topics
* Intersphinx: Added support for fetching Intersphinx inventories with URLs
- using HTTP basic auth
+ using HTTP basic auth.
* C++, added support for template parameter in function info field lists.
* C++, added support for pointers to member (function).
+* #2113: Allow ``:class:`` option to code-block directive.
+* #2192: Imgmath (pngmath with svg support).
+* #2200: Support XeTeX and LuaTeX for the LaTeX builder.
+* #1906: Use xcolor over color for \fcolorbox where available for LaTeX output.
+* #2216: Texinputs makefile improvements.
+* #2170: Support for Chinese language search index.
+* #2214: Add sphinx.ext.githubpages to publish the docs on GitHub Pages
+* #1030: Make page reference names for latex_show_pagerefs translatable
+* #2162: Add Sphinx.add_source_parser() to add source_suffix and source_parsers from extension
+* #2207: Add sphinx.parsers.Parser class; a base class for new parsers
+* #656: Add ``graphviz_dot`` option to graphviz directives to switch the ``dot`` command
+* #1939: Added the ``dummy`` builder: syntax check without output.
+* #2230: Add ``math_number_all`` option to number all displayed math in math extensions
+* #2235: ``needs_sphinx`` supports micro version comparison
+* #2282: Add "language" attribute to html tag in the "basic" theme
+* #1779: Add EPUB 3 builder
+* #1751: Add :confval:`todo_link_only` to avoid file path and line indication on
+ :rst:dir:`todolist`.
Bugs fixed
----------
@@ -28,10 +63,16 @@ Bugs fixed
* C++, add missing support for virtual base classes (thanks to Rapptz).
* C++, add support for final classes.
* C++, fix parsing of types prefixed with 'enum'.
-* #2023: Dutch search support uses Danish stemming info
+* #2023: Dutch search support uses Danish stemming info.
* C++, add support for user-defined literals.
* #1804: Now html output wraps overflowed long-line-text in the sidebar. Thanks to
Hassen ben tanfous.
+* #2183: Fix porterstemmer causes ``make json`` to fail.
+* #1899: Ensure list is sent to OptParse.
+* #2164: Fix wrong check for pdftex inside sphinx.sty (for graphicx package option).
+* #2165, #2218: Remove faulty and non-need conditional from sphinx.sty.
+* Fix broken LaTeX code is generated if unknown language is given
+* #1944: Fix rst_prolog breaks file-wide metadata
Documentation
-------------
@@ -39,15 +80,87 @@ Documentation
* #1757: Fix for usage of :confval:`html_last_updated_fmt`. Thanks to Ralf Hemmecke.
-Release 1.3.4 (in development)
+Release 1.3.6 (in development)
==============================
Bugs fixed
----------
+
+Release 1.3.5 (released Jan 24, 2016)
+=====================================
+
+Bugs fixed
+----------
+
+* Fix line numbers was not shown on warnings in LaTeX and texinfo builders
+* Fix filenames were not shown on warnings of citations
+* Fix line numbers was not shown on warnings in LaTeX and texinfo builders
+* Fix line numbers was not shown on warnings of indices
+* #2026: Fix LaTeX builder raises error if parsed-literal includes links
+* #2243: Ignore strange docstring types for classes, do not crash
+* #2247: Fix #2205 breaks make html for definition list with classifiers
+ that contains regular-expression like string
+* #1565: Show warning if Pygments throws an ErrorToken
+* #2211: Fix paragraphs in table cell doesn't work in Latex output
+* #2253: ``:pyobject:`` option of ``literalinclude`` directive can't detect indented
+ body block when the block starts with blank or comment lines.
+* Fix TOC is not shown when no ``:maxdepth:`` for toctrees (ref: #771)
+* Fix warning message for ``:numref:`` if target is in orphaned doc (ref: #2244)
+
+Release 1.3.4 (released Jan 12, 2016)
+=====================================
+
+Bugs fixed
+----------
+
* #2134: Fix figure caption with reference causes latex build error
* #2094: Fix rubric with reference not working in Latex
-
+* #2147: Fix literalinclude code in latex does not break in pages
+* #1833: Fix email addresses is showed again if latex_show_urls is not None
+* #2176: sphinx.ext.graphviz: use
\n')
+ raise nodes.SkipNode
+
+
+def setup(app):
+ mathbase_setup(app, (html_visit_math, None), (html_visit_displaymath, None))
+ app.add_config_value('imgmath_image_format', 'png', 'html')
+ app.add_config_value('imgmath_dvipng', 'dvipng', 'html')
+ app.add_config_value('imgmath_dvisvgm', 'dvisvgm', 'html')
+ app.add_config_value('imgmath_latex', 'latex', 'html')
+ app.add_config_value('imgmath_use_preview', False, 'html')
+ app.add_config_value('imgmath_dvipng_args',
+ ['-gamma', '1.5', '-D', '110', '-bg', 'Transparent'],
+ 'html')
+ app.add_config_value('imgmath_dvisvgm_args', ['--no-fonts'], 'html')
+ app.add_config_value('imgmath_latex_args', [], 'html')
+ app.add_config_value('imgmath_latex_preamble', '', 'html')
+ app.add_config_value('imgmath_add_tooltips', True, 'html')
+ app.add_config_value('imgmath_font_size', 12, 'html')
+ app.connect('build-finished', cleanup_tempdir)
+ return {'version': sphinx.__display_version__, 'parallel_read_safe': True}
diff --git a/sphinx/ext/inheritance_diagram.py b/sphinx/ext/inheritance_diagram.py
index f618aaf15..4ac2bd2fd 100644
--- a/sphinx/ext/inheritance_diagram.py
+++ b/sphinx/ext/inheritance_diagram.py
@@ -32,7 +32,7 @@ r"""
The graph is inserted as a PNG+image map into HTML and a PDF in
LaTeX.
- :copyright: Copyright 2007-2015 by the Sphinx team, see AUTHORS.
+ :copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
@@ -227,10 +227,10 @@ class InheritanceGraph(object):
}
def _format_node_attrs(self, attrs):
- return ','.join(['%s=%s' % x for x in attrs.items()])
+ return ','.join(['%s=%s' % x for x in sorted(attrs.items())])
def _format_graph_attrs(self, attrs):
- return ''.join(['%s=%s;\n' % x for x in attrs.items()])
+ return ''.join(['%s=%s;\n' % x for x in sorted(attrs.items())])
def generate_dot(self, name, urls={}, env=None,
graph_attrs={}, node_attrs={}, edge_attrs={}):
@@ -264,6 +264,7 @@ class InheritanceGraph(object):
this_node_attrs = n_attrs.copy()
if fullname in urls:
this_node_attrs['URL'] = '"%s"' % urls[fullname]
+ this_node_attrs['target'] = '"_top"'
if tooltip:
this_node_attrs['tooltip'] = tooltip
res.append(' "%s" [%s];\n' %
@@ -348,12 +349,20 @@ def html_visit_inheritance_diagram(self, node):
name = 'inheritance%s' % graph_hash
# Create a mapping from fully-qualified class names to URLs.
+ graphviz_output_format = self.builder.env.config.graphviz_output_format.upper()
+ current_filename = self.builder.current_docname + self.builder.out_suffix
urls = {}
for child in node:
if child.get('refuri') is not None:
- urls[child['reftitle']] = child.get('refuri')
+ if graphviz_output_format == 'SVG':
+ urls[child['reftitle']] = "../" + child.get('refuri')
+ else:
+ urls[child['reftitle']] = child.get('refuri')
elif child.get('refid') is not None:
- urls[child['reftitle']] = '#' + child.get('refid')
+ if graphviz_output_format == 'SVG':
+ urls[child['reftitle']] = '../' + current_filename + '#' + child.get('refid')
+ else:
+ urls[child['reftitle']] = '#' + child.get('refid')
dotcode = graph.generate_dot(name, urls, env=self.builder.env)
render_dot_html(self, node, dotcode, [], 'inheritance', 'inheritance',
diff --git a/sphinx/ext/intersphinx.py b/sphinx/ext/intersphinx.py
index 4d2c6755c..9fe2f765c 100644
--- a/sphinx/ext/intersphinx.py
+++ b/sphinx/ext/intersphinx.py
@@ -20,7 +20,7 @@
also be specified individually, e.g. if the docs should be buildable
without Internet access.
- :copyright: Copyright 2007-2015 by the Sphinx team, see AUTHORS.
+ :copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
diff --git a/sphinx/ext/jsmath.py b/sphinx/ext/jsmath.py
index 2cc661430..ff77c2d1b 100644
--- a/sphinx/ext/jsmath.py
+++ b/sphinx/ext/jsmath.py
@@ -6,7 +6,7 @@
Set up everything for use of JSMath to display math in HTML
via JavaScript.
- :copyright: Copyright 2007-2015 by the Sphinx team, see AUTHORS.
+ :copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
@@ -26,7 +26,7 @@ def html_visit_math(self, node):
def html_visit_displaymath(self, node):
if node['nowrap']:
self.body.append(self.starttag(node, 'div', CLASS='math'))
- self.body.append(node['latex'])
+ self.body.append(self.encode(node['latex']))
self.body.append('')
raise nodes.SkipNode
for i, part in enumerate(node['latex'].split('\n\n')):
diff --git a/sphinx/ext/linkcode.py b/sphinx/ext/linkcode.py
index b0ee5e43e..63bd38727 100644
--- a/sphinx/ext/linkcode.py
+++ b/sphinx/ext/linkcode.py
@@ -5,7 +5,7 @@
Add external links to module code in Python object descriptions.
- :copyright: Copyright 2007-2015 by the Sphinx team, see AUTHORS.
+ :copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
diff --git a/sphinx/ext/mathbase.py b/sphinx/ext/mathbase.py
index 4327fba1c..8ede05b87 100644
--- a/sphinx/ext/mathbase.py
+++ b/sphinx/ext/mathbase.py
@@ -5,7 +5,7 @@
Set up math support in source files and LaTeX/text output.
- :copyright: Copyright 2007-2015 by the Sphinx team, see AUTHORS.
+ :copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
@@ -28,20 +28,25 @@ class eqref(nodes.Inline, nodes.TextElement):
pass
-def wrap_displaymath(math, label):
+def wrap_displaymath(math, label, numbering):
parts = math.split('\n\n')
ret = []
for i, part in enumerate(parts):
if not part.strip():
continue
- if label is not None and i == 0:
- ret.append('\\begin{split}%s\\end{split}' % part +
- (label and '\\label{'+label+'}' or ''))
- else:
- ret.append('\\begin{split}%s\\end{split}\\notag' % part)
+ ret.append(r'\begin{split}%s\end{split}' % part)
if not ret:
return ''
- return '\\begin{gather}\n' + '\\\\'.join(ret) + '\n\\end{gather}'
+ if label is not None or numbering:
+ env_begin = r'\begin{align}'
+ if label is not None:
+ env_begin += r'\label{%s}' % label
+ env_end = r'\end{align}'
+ else:
+ env_begin = r'\begin{align*}'
+ env_end = r'\end{align*}'
+ return ('%s\\begin{aligned}\n%s\\end{aligned}%s') % (
+ env_begin, '\\\\\n'.join(ret), env_end)
def math_role(role, rawtext, text, lineno, inliner, options={}, content=[]):
@@ -56,6 +61,17 @@ def eq_role(role, rawtext, text, lineno, inliner, options={}, content=[]):
return [node], []
+def is_in_section_title(node):
+ """Determine whether the node is in a section title"""
+ from sphinx.util.nodes import traverse_parent
+
+ for ancestor in traverse_parent(node):
+ if isinstance(ancestor, nodes.title) and \
+ isinstance(ancestor.parent, nodes.section):
+ return True
+ return False
+
+
class MathDirective(Directive):
has_content = True
@@ -91,7 +107,12 @@ class MathDirective(Directive):
def latex_visit_math(self, node):
- self.body.append('\\(' + node['latex'] + '\\)')
+ if is_in_section_title(node):
+ protect = r'\protect'
+ else:
+ protect = ''
+ equation = protect + r'\(' + node['latex'] + protect + r'\)'
+ self.body.append(equation)
raise nodes.SkipNode
@@ -100,7 +121,8 @@ def latex_visit_displaymath(self, node):
self.body.append(node['latex'])
else:
label = node['label'] and node['docname'] + '-' + node['label'] or None
- self.body.append(wrap_displaymath(node['latex'], label))
+ self.body.append(wrap_displaymath(node['latex'], label,
+ self.builder.config.math_number_all))
raise nodes.SkipNode
@@ -178,10 +200,11 @@ def number_equations(app, doctree, docname):
num = 0
numbers = {}
for node in doctree.traverse(displaymath):
- if node['label'] is not None:
+ if node['label'] is not None or app.config.math_number_all:
num += 1
node['number'] = num
- numbers[node['label']] = num
+ if node['label'] is not None:
+ numbers[node['label']] = num
else:
node['number'] = None
for node in doctree.traverse(eqref):
@@ -192,6 +215,7 @@ def number_equations(app, doctree, docname):
def setup_math(app, htmlinlinevisitors, htmldisplayvisitors):
+ app.add_config_value('math_number_all', False, 'html')
app.add_node(math, override=True,
latex=(latex_visit_math, None),
text=(text_visit_math, None),
@@ -214,3 +238,4 @@ def setup_math(app, htmlinlinevisitors, htmldisplayvisitors):
app.add_role('eq', eq_role)
app.add_directive('math', MathDirective)
app.connect('doctree-resolved', number_equations)
+ app.add_latex_package('amsfonts')
diff --git a/sphinx/ext/mathjax.py b/sphinx/ext/mathjax.py
index d512db465..511c4f3dd 100644
--- a/sphinx/ext/mathjax.py
+++ b/sphinx/ext/mathjax.py
@@ -7,7 +7,7 @@
Sphinx's HTML writer -- requires the MathJax JavaScript library on your
webserver/computer.
- :copyright: Copyright 2007-2015 by the Sphinx team, see AUTHORS.
+ :copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
@@ -30,7 +30,7 @@ def html_visit_displaymath(self, node):
self.body.append(self.starttag(node, 'div', CLASS='math'))
if node['nowrap']:
self.body.append(self.builder.config.mathjax_display[0] +
- node['latex'] +
+ self.encode(node['latex']) +
self.builder.config.mathjax_display[1])
self.body.append('')
raise nodes.SkipNode
diff --git a/sphinx/ext/napoleon/__init__.py b/sphinx/ext/napoleon/__init__.py
index 6124ee9be..85c8acec8 100644
--- a/sphinx/ext/napoleon/__init__.py
+++ b/sphinx/ext/napoleon/__init__.py
@@ -5,7 +5,7 @@
Support for NumPy and Google style docstrings.
- :copyright: Copyright 2007-2015 by the Sphinx team, see AUTHORS.
+ :copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
diff --git a/sphinx/ext/napoleon/docstring.py b/sphinx/ext/napoleon/docstring.py
index 1065533dc..742a9fbba 100644
--- a/sphinx/ext/napoleon/docstring.py
+++ b/sphinx/ext/napoleon/docstring.py
@@ -7,7 +7,7 @@
Classes for docstring parsing and formatting.
- :copyright: Copyright 2007-2015 by the Sphinx team, see AUTHORS.
+ :copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
@@ -27,6 +27,11 @@ _google_section_regex = re.compile(r'^(\s|\w)+:\s*$')
_google_typed_arg_regex = re.compile(r'\s*(.+?)\s*\(\s*(.+?)\s*\)')
_numpy_section_regex = re.compile(r'^[=\-`:\'"~^_*+#<>]{2,}\s*$')
_xref_regex = re.compile(r'(:\w+:\S+:`.+?`|:\S+:`.+?`|`.+?`)')
+_bullet_list_regex = re.compile(r'^(\*|\+|\-)(\s+\S|\s*$)')
+_enumerated_list_regex = re.compile(
+ r'^(?P\()?'
+ r'(\d+|#|[ivxlcdm]+|[IVXLCDM]+|[a-zA-Z])'
+ r'(?(paren)\)|\.)(\s+\S|\s*$)')
class GoogleDocstring(UnicodeMixin):
@@ -349,6 +354,8 @@ class GoogleDocstring(UnicodeMixin):
field = ''
if has_desc:
+ if self._is_list(_desc):
+ return [field, ''] + _desc
return [field + _desc[0]] + _desc[1:]
else:
return [field]
@@ -408,6 +415,23 @@ class GoogleDocstring(UnicodeMixin):
return False
return False
+ def _is_list(self, lines):
+ if not lines:
+ return False
+ if _bullet_list_regex.match(lines[0]):
+ return True
+ if _enumerated_list_regex.match(lines[0]):
+ return True
+ if len(lines) < 2 or lines[0].endswith('::'):
+ return False
+ indent = self._get_indent(lines[0])
+ next_indent = indent
+ for line in lines[1:]:
+ if line:
+ next_indent = self._get_indent(line)
+ break
+ return next_indent > indent
+
def _is_section_header(self):
section = self._line_iter.peek().lower()
match = _google_section_regex.match(section)
@@ -530,10 +554,18 @@ class GoogleDocstring(UnicodeMixin):
if self._config.napoleon_use_param:
lines = []
for _name, _type, _desc in fields:
- field = ':param %s: ' % _name
- lines.extend(self._format_block(field, _desc))
+ _desc = self._strip_empty(_desc)
+ if any(_desc):
+ if self._is_list(_desc):
+ _desc = [''] + _desc
+ field = ':param %s: ' % _name
+ lines.extend(self._format_block(field, _desc))
+ else:
+ lines.append(':param %s:' % _name)
+
if _type:
lines.append(':type %s: %s' % (_name, _type))
+
return lines + ['']
else:
return self._format_fields('Parameters', fields)
@@ -777,10 +809,11 @@ class NumpyDocstring(GoogleDocstring):
_name, _type = line, ''
_name, _type = _name.strip(), _type.strip()
_name = self._escape_args_and_kwargs(_name)
+
if prefer_type and not _type:
_type, _name = _name, _type
- indent = self._get_indent(line)
- _desc = self._dedent(self._consume_indented_block(indent + 1))
+ indent = self._get_indent(line) + 1
+ _desc = self._dedent(self._consume_indented_block(indent))
_desc = self.__class__(_desc, self._config).lines()
return _name, _type, _desc
diff --git a/sphinx/ext/napoleon/iterators.py b/sphinx/ext/napoleon/iterators.py
index f59a3f088..f66d67f2c 100644
--- a/sphinx/ext/napoleon/iterators.py
+++ b/sphinx/ext/napoleon/iterators.py
@@ -7,7 +7,7 @@
A collection of helpful iterators.
- :copyright: Copyright 2007-2015 by the Sphinx team, see AUTHORS.
+ :copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
diff --git a/sphinx/ext/pngmath.py b/sphinx/ext/pngmath.py
index 8ef860f80..a2801bd1f 100644
--- a/sphinx/ext/pngmath.py
+++ b/sphinx/ext/pngmath.py
@@ -3,9 +3,10 @@
sphinx.ext.pngmath
~~~~~~~~~~~~~~~~~~
- Render math in HTML via dvipng.
+ Render math in HTML via dvipng. This extension has been deprecated; please
+ use sphinx.ext.imgmath instead.
- :copyright: Copyright 2007-2015 by the Sphinx team, see AUTHORS.
+ :copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
@@ -212,7 +213,8 @@ def html_visit_displaymath(self, node):
if node['nowrap']:
latex = node['latex']
else:
- latex = wrap_displaymath(node['latex'], None)
+ latex = wrap_displaymath(node['latex'], None,
+ self.builder.config.math_number_all)
try:
fname, depth = render_math(self, latex)
except MathExtError as exc:
@@ -236,6 +238,7 @@ def html_visit_displaymath(self, node):
def setup(app):
+ app.warn('sphinx.ext.pngmath has been deprecated. Please use sphinx.ext.imgmath instead.')
mathbase_setup(app, (html_visit_math, None), (html_visit_displaymath, None))
app.add_config_value('pngmath_dvipng', 'dvipng', 'html')
app.add_config_value('pngmath_latex', 'latex', 'html')
diff --git a/sphinx/ext/todo.py b/sphinx/ext/todo.py
index faa086fc8..a853ec93c 100644
--- a/sphinx/ext/todo.py
+++ b/sphinx/ext/todo.py
@@ -8,7 +8,7 @@
all todos of your project and lists them along with a backlink to the
original location.
- :copyright: Copyright 2007-2015 by the Sphinx team, see AUTHORS.
+ :copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
@@ -19,7 +19,8 @@ import sphinx
from sphinx.locale import _
from sphinx.environment import NoUri
from sphinx.util.nodes import set_source_info
-from sphinx.util.compat import Directive, make_admonition
+from docutils.parsers.rst import Directive
+from docutils.parsers.rst.directives.admonitions import BaseAdmonition
class todo_node(nodes.Admonition, nodes.Element):
@@ -30,11 +31,12 @@ class todolist(nodes.General, nodes.Element):
pass
-class Todo(Directive):
+class Todo(BaseAdmonition):
"""
A todo entry, displayed (if configured) in the form of an admonition.
"""
+ node_class = todo_node
has_content = True
required_arguments = 0
optional_arguments = 0
@@ -44,18 +46,20 @@ class Todo(Directive):
}
def run(self):
- env = self.state.document.settings.env
- targetid = 'index-%s' % env.new_serialno('index')
- targetnode = nodes.target('', '', ids=[targetid])
-
if not self.options.get('class'):
self.options['class'] = ['admonition-todo']
- ad = make_admonition(todo_node, self.name, [_('Todo')], self.options,
- self.content, self.lineno, self.content_offset,
- self.block_text, self.state, self.state_machine)
- set_source_info(self, ad[0])
- return [targetnode] + ad
+ (todo,) = super(Todo, self).run()
+ if isinstance(todo, nodes.system_message):
+ return [todo]
+
+ todo.insert(0, nodes.title(text=_('Todo')))
+ set_source_info(self, todo)
+
+ env = self.state.document.settings.env
+ targetid = 'index-%s' % env.new_serialno('index')
+ targetnode = nodes.target('', '', ids=[targetid])
+ return [targetnode, todo]
def process_todos(app, doctree):
@@ -121,9 +125,13 @@ def process_todo_nodes(app, doctree, fromdocname):
for todo_info in env.todo_all_todos:
para = nodes.paragraph(classes=['todo-source'])
- description = _('(The <> is located in '
- ' %s, line %d.)') % \
- (todo_info['source'], todo_info['lineno'])
+ if app.config['todo_link_only']:
+ description = _('<>')
+ else:
+ description = (
+ _('(The <> is located in %s, line %d.)') %
+ (todo_info['source'], todo_info['lineno'])
+ )
desc1 = description[:description.find('<<')]
desc2 = description[description.find('>>')+2:]
para += nodes.Text(desc1, desc1)
@@ -180,6 +188,7 @@ def depart_todo_node(self, node):
def setup(app):
app.add_config_value('todo_include_todos', False, 'html')
+ app.add_config_value('todo_link_only', False, 'html')
app.add_node(todolist)
app.add_node(todo_node,
diff --git a/sphinx/ext/viewcode.py b/sphinx/ext/viewcode.py
index e6af4f550..d64cc88f7 100644
--- a/sphinx/ext/viewcode.py
+++ b/sphinx/ext/viewcode.py
@@ -5,7 +5,7 @@
Add links to module code in Python object descriptions.
- :copyright: Copyright 2007-2015 by the Sphinx team, see AUTHORS.
+ :copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
diff --git a/sphinx/highlighting.py b/sphinx/highlighting.py
index 6f22993c2..eb008dc4e 100644
--- a/sphinx/highlighting.py
+++ b/sphinx/highlighting.py
@@ -5,7 +5,7 @@
Highlight code blocks using Pygments.
- :copyright: Copyright 2007-2015 by the Sphinx team, see AUTHORS.
+ :copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
@@ -183,9 +183,13 @@ class PygmentsBridge(object):
formatter = self.get_formatter(**kwargs)
try:
hlsource = highlight(source, lexer, formatter)
- except ErrorToken:
+ except ErrorToken as exc:
# this is most probably not the selected language,
# so let it pass unhighlighted
+ if warn:
+ warn('Could not parse literal_block as "%s". highlighting skipped.' % lang)
+ else:
+ raise exc
hlsource = highlight(source, lexers['none'], formatter)
if self.dest == 'html':
return hlsource
diff --git a/sphinx/jinja2glue.py b/sphinx/jinja2glue.py
index c8a7165fc..f3ce87a8c 100644
--- a/sphinx/jinja2glue.py
+++ b/sphinx/jinja2glue.py
@@ -5,7 +5,7 @@
Glue code for the jinja2 templating engine.
- :copyright: Copyright 2007-2015 by the Sphinx team, see AUTHORS.
+ :copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
diff --git a/sphinx/locale/__init__.py b/sphinx/locale/__init__.py
index 444ad5d0c..f7a375dec 100644
--- a/sphinx/locale/__init__.py
+++ b/sphinx/locale/__init__.py
@@ -5,7 +5,7 @@
Locale utilities.
- :copyright: Copyright 2007-2015 by the Sphinx team, see AUTHORS.
+ :copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
diff --git a/sphinx/make_mode.py b/sphinx/make_mode.py
index 7d239f51c..67ba9e1e1 100644
--- a/sphinx/make_mode.py
+++ b/sphinx/make_mode.py
@@ -11,7 +11,7 @@
This is in its own module so that importing it is fast. It should not
import the main Sphinx modules (like sphinx.applications, sphinx.builders).
- :copyright: Copyright 2007-2015 by the Sphinx team, see AUTHORS.
+ :copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
from __future__ import print_function
diff --git a/sphinx/parsers.py b/sphinx/parsers.py
new file mode 100644
index 000000000..926de9f1c
--- /dev/null
+++ b/sphinx/parsers.py
@@ -0,0 +1,44 @@
+# -*- coding: utf-8 -*-
+"""
+ sphinx.parsers
+ ~~~~~~~~~~~~~~
+
+ A Base class for additional parsers.
+
+ :copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS.
+ :license: BSD, see LICENSE for details.
+"""
+
+import docutils.parsers
+
+
+class Parser(docutils.parsers.Parser):
+ """
+ A base class of source parsers. The additonal parsers should inherits this class instead
+ of ``docutils.parsers.Parser``. Compared with ``docutils.parsers.Parser``, this class
+ improves accessibility to Sphinx APIs.
+
+ The subclasses can access following objects and functions:
+
+ self.app
+ The application object (:class:`sphinx.application.Sphinx`)
+ self.config
+ The config object (:class:`sphinx.config.Config`)
+ self.env
+ The environment object (:class:`sphinx.environment.BuildEnvironment`)
+ self.warn()
+ Emit a warning. (Same as :meth:`sphinx.application.Sphinx.warn()`)
+ self.info()
+ Emit a informational message. (Same as :meth:`sphinx.application.Sphinx.info()`)
+ """
+
+ def set_application(self, app):
+ """set_application will be called from Sphinx to set app and other instance variables
+
+ :param sphinx.application.Sphinx app: Sphinx application object
+ """
+ self.app = app
+ self.config = app.config
+ self.env = app.env
+ self.warn = app.warn
+ self.info = app.info
diff --git a/sphinx/pycode/__init__.py b/sphinx/pycode/__init__.py
index 57707e9d0..3da887d6c 100644
--- a/sphinx/pycode/__init__.py
+++ b/sphinx/pycode/__init__.py
@@ -5,7 +5,7 @@
Utilities parsing and analyzing Python code.
- :copyright: Copyright 2007-2015 by the Sphinx team, see AUTHORS.
+ :copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
from __future__ import print_function
@@ -300,7 +300,7 @@ class ModuleAnalyzer(object):
yield tokentup
tokeniter = tokeniter()
for type, tok, spos, epos, line in tokeniter:
- if expect_indent:
+ if expect_indent and type != token.NL:
if type != token.INDENT:
# no suite -- one-line definition
assert stack
diff --git a/sphinx/pycode/nodes.py b/sphinx/pycode/nodes.py
index 3b244db7f..ee40f3c0d 100644
--- a/sphinx/pycode/nodes.py
+++ b/sphinx/pycode/nodes.py
@@ -5,7 +5,7 @@
Parse tree node implementations.
- :copyright: Copyright 2007-2015 by the Sphinx team, see AUTHORS.
+ :copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
diff --git a/sphinx/pygments_styles.py b/sphinx/pygments_styles.py
index ff2263e1c..469947149 100644
--- a/sphinx/pygments_styles.py
+++ b/sphinx/pygments_styles.py
@@ -5,7 +5,7 @@
Sphinx theme specific highlighting styles.
- :copyright: Copyright 2007-2015 by the Sphinx team, see AUTHORS.
+ :copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
diff --git a/sphinx/quickstart.py b/sphinx/quickstart.py
index ffc4961dc..7d7271824 100644
--- a/sphinx/quickstart.py
+++ b/sphinx/quickstart.py
@@ -5,7 +5,7 @@
Quickly setup documentation source to work with Sphinx.
- :copyright: Copyright 2007-2015 by the Sphinx team, see AUTHORS.
+ :copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
from __future__ import print_function
@@ -60,7 +60,7 @@ DEFAULT_VALUE = {
}
EXTENSIONS = ('autodoc', 'doctest', 'intersphinx', 'todo', 'coverage',
- 'pngmath', 'mathjax', 'ifconfig', 'viewcode')
+ 'imgmath', 'mathjax', 'ifconfig', 'viewcode', 'githubpages')
PROMPT_PREFIX = '> '
@@ -146,6 +146,7 @@ language = %(language)r
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
+# This patterns also effect to html_static_path and html_extra_path
exclude_patterns = [%(exclude_patterns)s]
# The reST default role (used for this markup: `text`) to use for all
@@ -190,9 +191,9 @@ html_theme = 'alabaster'
# 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
-# " v documentation".
-#html_title = None
+# The name for this set of Sphinx documents.
+# " v documentation" by default.
+#html_title = u'%(project_str)s v%(release_str)s'
# A shorter title for the navigation bar. Default is the same as html_title.
#html_short_title = None
@@ -261,11 +262,12 @@ html_static_path = ['%(dot)sstatic']
# Language to be used for generating the HTML full-text search index.
# Sphinx supports the following languages:
# 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja'
-# 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr'
+# 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr', 'zh'
#html_search_language = 'en'
# A dictionary with options for the search language support, empty by default.
-# Now only 'ja' uses this config value
+# 'ja' uses this config value.
+# 'zh' user can custom change `jieba` dictionary path.
#html_search_options = {'type': 'default'}
# The name of a javascript file (relative to the configuration directory) that
@@ -295,8 +297,8 @@ latex_elements = {
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
- (master_doc, '%(project_fn)s.tex', u'%(project_doc_texescaped_str)s',
- u'%(author_texescaped_str)s', 'manual'),
+ (master_doc, '%(project_fn)s.tex', u'%(project_doc_texescaped_str)s',
+ u'%(author_texescaped_str)s', 'manual'),
]
# The name of an image file (relative to this directory) to place at the top of
@@ -339,9 +341,9 @@ man_pages = [
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
- (master_doc, '%(project_fn)s', u'%(project_doc_str)s',
- author, '%(project_fn)s', 'One line description of project.',
- 'Miscellaneous'),
+ (master_doc, '%(project_fn)s', u'%(project_doc_str)s',
+ author, '%(project_fn)s', 'One line description of project.',
+ 'Miscellaneous'),
]
# Documents to append as an appendix to all manuals.
@@ -370,10 +372,10 @@ epub_copyright = copyright
# The basename for the epub file. It defaults to the project name.
#epub_basename = project
-# The HTML theme for the epub output. Since the default themes are not optimized
-# for small screen space, using the same theme for HTML and epub output is
-# usually not wise. This defaults to 'epub', a theme designed to save visual
-# space.
+# The HTML theme for the epub output. Since the default themes are not
+# optimized for small screen space, using the same theme for HTML and epub
+# output is usually not wise. This defaults to 'epub', a theme designed to save
+# visual space.
#epub_theme = 'epub'
# The language of the text. It defaults to the language option
@@ -400,7 +402,7 @@ epub_copyright = copyright
# The format is a list of tuples containing the path and title.
#epub_pre_files = []
-# HTML files shat should be inserted after the pages created by sphinx.
+# HTML files that should be inserted after the pages created by sphinx.
# The format is a list of tuples containing the path and title.
#epub_post_files = []
@@ -488,9 +490,7 @@ $(SPHINXOPTS) %(rsrcdir)s
# the i18n builder cannot share the environment and doctrees with the others
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) %(rsrcdir)s
-.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp \
-epub latex latexpdf text man changes linkcheck doctest coverage gettext
-
+.PHONY: help
help:
\t@echo "Please use \\`make ' where is one of"
\t@echo " html to make standalone HTML files"
@@ -503,6 +503,7 @@ help:
\t@echo " applehelp to make an Apple Help Book"
\t@echo " devhelp to make HTML files and a Devhelp project"
\t@echo " epub to make an epub"
+\t@echo " epub3 to make an epub3"
\t@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
\t@echo " latexpdf to make LaTeX files and run them through pdflatex"
\t@echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx"
@@ -519,40 +520,48 @@ help:
(if enabled)"
\t@echo " coverage to run coverage check of the documentation (if enabled)"
+.PHONY: clean
clean:
\trm -rf $(BUILDDIR)/*
+.PHONY: html
html:
\t$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
\t@echo
\t@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
+.PHONY: dirhtml
dirhtml:
\t$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
\t@echo
\t@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
+.PHONY: singlehtml
singlehtml:
\t$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
\t@echo
\t@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
+.PHONY: pickle
pickle:
\t$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
\t@echo
\t@echo "Build finished; now you can process the pickle files."
+.PHONY: json
json:
\t$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
\t@echo
\t@echo "Build finished; now you can process the JSON files."
+.PHONY: htmlhelp
htmlhelp:
\t$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
\t@echo
\t@echo "Build finished; now you can run HTML Help Workshop with the" \\
\t ".hhp project file in $(BUILDDIR)/htmlhelp."
+.PHONY: qthelp
qthelp:
\t$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
\t@echo
@@ -562,6 +571,7 @@ qthelp:
\t@echo "To view the help file:"
\t@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/%(project_fn)s.qhc"
+.PHONY: applehelp
applehelp:
\t$(SPHINXBUILD) -b applehelp $(ALLSPHINXOPTS) $(BUILDDIR)/applehelp
\t@echo
@@ -570,6 +580,7 @@ applehelp:
\t "~/Library/Documentation/Help or install it in your application" \\
\t "bundle."
+.PHONY: devhelp
devhelp:
\t$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
\t@echo
@@ -580,11 +591,19 @@ devhelp:
$$HOME/.local/share/devhelp/%(project_fn)s"
\t@echo "# devhelp"
+.PHONY: epub
epub:
\t$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
\t@echo
\t@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
+.PHONY: epub3
+epub3:
+\t$(SPHINXBUILD) -b epub3 $(ALLSPHINXOPTS) $(BUILDDIR)/epub3
+\t@echo
+\t@echo "Build finished. The epub3 file is in $(BUILDDIR)/epub3."
+
+.PHONY: latex
latex:
\t$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
\t@echo
@@ -592,28 +611,33 @@ latex:
\t@echo "Run \\`make' in that directory to run these through (pdf)latex" \\
\t "(use \\`make latexpdf' here to do that automatically)."
+.PHONY: latexpdf
latexpdf:
\t$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
\t@echo "Running LaTeX files through pdflatex..."
\t$(MAKE) -C $(BUILDDIR)/latex all-pdf
\t@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
+.PHONY: latexpdfja
latexpdfja:
\t$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
\t@echo "Running LaTeX files through platex and dvipdfmx..."
\t$(MAKE) -C $(BUILDDIR)/latex all-pdf-ja
\t@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
+.PHONY: text
text:
\t$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
\t@echo
\t@echo "Build finished. The text files are in $(BUILDDIR)/text."
+.PHONY: man
man:
\t$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
\t@echo
\t@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
+.PHONY: texinfo
texinfo:
\t$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
\t@echo
@@ -621,43 +645,51 @@ texinfo:
\t@echo "Run \\`make' in that directory to run these through makeinfo" \\
\t "(use \\`make info' here to do that automatically)."
+.PHONY: info
info:
\t$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
\t@echo "Running Texinfo files through makeinfo..."
\tmake -C $(BUILDDIR)/texinfo info
\t@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
+.PHONY: gettext
gettext:
\t$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
\t@echo
\t@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
+.PHONY: changes
changes:
\t$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
\t@echo
\t@echo "The overview file is in $(BUILDDIR)/changes."
+.PHONY: linkcheck
linkcheck:
\t$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
\t@echo
\t@echo "Link check complete; look for any errors in the above output " \\
\t "or in $(BUILDDIR)/linkcheck/output.txt."
+.PHONY: doctest
doctest:
\t$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
\t@echo "Testing of doctests in the sources finished, look at the " \\
\t "results in $(BUILDDIR)/doctest/output.txt."
+.PHONY: coverage
coverage:
\t$(SPHINXBUILD) -b coverage $(ALLSPHINXOPTS) $(BUILDDIR)/coverage
\t@echo "Testing of coverage in the sources finished, look at the " \\
\t "results in $(BUILDDIR)/coverage/python.txt."
+.PHONY: xml
xml:
\t$(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml
\t@echo
\t@echo "Build finished. The XML files are in $(BUILDDIR)/xml."
+.PHONY: pseudoxml
pseudoxml:
\t$(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml
\t@echo
@@ -694,6 +726,7 @@ if "%%1" == "help" (
\techo. qthelp to make HTML files and a qthelp project
\techo. devhelp to make HTML files and a Devhelp project
\techo. epub to make an epub
+\techo. epub3 to make an epub3
\techo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter
\techo. text to make text files
\techo. man to make manual pages
@@ -816,6 +849,14 @@ if "%%1" == "epub" (
\tgoto end
)
+if "%%1" == "epub3" (
+\t%%SPHINXBUILD%% -b epub3 %%ALLSPHINXOPTS%% %%BUILDDIR%%/epub3
+\tif errorlevel 1 exit /b 1
+\techo.
+\techo.Build finished. The epub3 file is in %%BUILDDIR%%/epub3.
+\tgoto end
+)
+
if "%%1" == "latex" (
\t%%SPHINXBUILD%% -b latex %%ALLSPHINXOPTS%% %%BUILDDIR%%/latex
\tif errorlevel 1 exit /b 1
@@ -1255,22 +1296,25 @@ Please indicate if you want to use one of the following Sphinx extensions:''')
if 'ext_coverage' not in d:
do_prompt(d, 'ext_coverage', 'coverage: checks for documentation '
'coverage (y/n)', 'n', boolean)
- if 'ext_pngmath' not in d:
- do_prompt(d, 'ext_pngmath', 'pngmath: include math, rendered '
- 'as PNG images (y/n)', 'n', boolean)
+ if 'ext_imgmath' not in d:
+ do_prompt(d, 'ext_imgmath', 'imgmath: include math, rendered '
+ 'as PNG or SVG images (y/n)', 'n', boolean)
if 'ext_mathjax' not in d:
do_prompt(d, 'ext_mathjax', 'mathjax: include math, rendered in the '
'browser by MathJax (y/n)', 'n', boolean)
- if d['ext_pngmath'] and d['ext_mathjax']:
- print('''Note: pngmath and mathjax cannot be enabled at the same time.
-pngmath has been deselected.''')
- d['ext_pngmath'] = False
+ if d['ext_imgmath'] and d['ext_mathjax']:
+ print('''Note: imgmath and mathjax cannot be enabled at the same time.
+imgmath has been deselected.''')
+ d['ext_imgmath'] = False
if 'ext_ifconfig' not in d:
do_prompt(d, 'ext_ifconfig', 'ifconfig: conditional inclusion of '
'content based on config values (y/n)', 'n', boolean)
if 'ext_viewcode' not in d:
do_prompt(d, 'ext_viewcode', 'viewcode: include links to the source '
'code of documented Python objects (y/n)', 'n', boolean)
+ if 'ext_githubpages' not in d:
+ do_prompt(d, 'ext_githubpages', 'githubpages: create .nojekyll file '
+ 'to publish the document on GitHub pages (y/n)', 'n', boolean)
if 'no_makefile' in d:
d['makefile'] = False
@@ -1337,7 +1381,11 @@ def generate(d, overwrite=True, silent=False):
d['exclude_patterns'] = ''
else:
builddir = path.join(srcdir, d['dot'] + 'build')
- d['exclude_patterns'] = repr(d['dot'] + 'build')
+ exclude_patterns = map(repr, [
+ d['dot'] + 'build',
+ 'Thumbs.db', '.DS_Store',
+ ])
+ d['exclude_patterns'] = ', '.join(exclude_patterns)
mkdir_p(builddir)
mkdir_p(path.join(srcdir, d['dot'] + 'templates'))
mkdir_p(path.join(srcdir, d['dot'] + 'static'))
diff --git a/sphinx/roles.py b/sphinx/roles.py
index 96e098569..59d69a1f1 100644
--- a/sphinx/roles.py
+++ b/sphinx/roles.py
@@ -5,7 +5,7 @@
Handlers for additional ReST roles.
- :copyright: Copyright 2007-2015 by the Sphinx team, see AUTHORS.
+ :copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
@@ -29,7 +29,7 @@ generic_docroles = {
'kbd': nodes.literal,
'mailheader': addnodes.literal_emphasis,
'makevar': addnodes.literal_strong,
- 'manpage': addnodes.literal_emphasis,
+ 'manpage': addnodes.manpage,
'mimetype': addnodes.literal_emphasis,
'newsgroup': addnodes.literal_emphasis,
'program': addnodes.literal_strong, # XXX should be an x-ref
diff --git a/sphinx/search/__init__.py b/sphinx/search/__init__.py
index 050ab2d7f..75d03f19d 100644
--- a/sphinx/search/__init__.py
+++ b/sphinx/search/__init__.py
@@ -5,7 +5,7 @@
Create a full-text search index for offline search.
- :copyright: Copyright 2007-2015 by the Sphinx team, see AUTHORS.
+ :copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
import re
@@ -135,6 +135,7 @@ languages = {
'ru': 'sphinx.search.ru.SearchRussian',
'sv': 'sphinx.search.sv.SearchSwedish',
'tr': 'sphinx.search.tr.SearchTurkish',
+ 'zh': 'sphinx.search.zh.SearchChinese',
}
diff --git a/sphinx/search/de.py b/sphinx/search/de.py
index 89cbe3de5..35c6263c4 100644
--- a/sphinx/search/de.py
+++ b/sphinx/search/de.py
@@ -311,4 +311,5 @@ class SearchGerman(SearchLanguage):
self.stemmer = snowballstemmer.stemmer('german')
def stem(self, word):
+ word = word.lower()
return self.stemmer.stemWord(word)
diff --git a/sphinx/search/en.py b/sphinx/search/en.py
index de77ae294..9501cddeb 100644
--- a/sphinx/search/en.py
+++ b/sphinx/search/en.py
@@ -5,25 +5,18 @@
English search language: includes the JS porter stemmer.
- :copyright: Copyright 2007-2015 by the Sphinx team, see AUTHORS.
+ :copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
from sphinx.search import SearchLanguage
try:
- # http://bitbucket.org/methane/porterstemmer/
- from porterstemmer import Stemmer as CStemmer
- CSTEMMER = True
- PYSTEMMER = False
+ from Stemmer import Stemmer as PyStemmer
+ PYSTEMMER = True
except ImportError:
- CSTEMMER = False
- try:
- from Stemmer import Stemmer as PyStemmer
- PYSTEMMER = True
- except ImportError:
- from sphinx.util.stemmer import PorterStemmer
- PYSTEMMER = False
+ from sphinx.util.stemmer import PorterStemmer
+ PYSTEMMER = False
english_stopwords = set("""
a and are as at
@@ -231,11 +224,7 @@ class SearchEnglish(SearchLanguage):
stopwords = english_stopwords
def init(self, options):
- if CSTEMMER:
- class Stemmer(CStemmer):
- def stem(self, word):
- return self(word.lower())
- elif PYSTEMMER:
+ if PYSTEMMER:
class Stemmer(object):
def __init__(self):
self.stemmer = PyStemmer('porter')
diff --git a/sphinx/search/ja.py b/sphinx/search/ja.py
index 23de74d37..6e9ead616 100644
--- a/sphinx/search/ja.py
+++ b/sphinx/search/ja.py
@@ -5,7 +5,7 @@
Japanese search language: includes routine to split words.
- :copyright: Copyright 2007-2015 by the Sphinx team, see AUTHORS.
+ :copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
@@ -29,6 +29,7 @@ try:
except ImportError:
native_module = False
+from sphinx.errors import SphinxError
from sphinx.search import SearchLanguage
@@ -86,9 +87,16 @@ class MecabBinder(object):
if dict:
param += ' -d %s' % dict
+ fs_enc = sys.getfilesystemencoding() or sys.getdefaultencoding()
+
self.ctypes_libmecab = ctypes.CDLL(libpath)
+ self.ctypes_libmecab.mecab_new2.argtypes = (ctypes.c_char_p,)
+ self.ctypes_libmecab.mecab_new2.restype = ctypes.c_void_p
+ self.ctypes_libmecab.mecab_sparse_tostr.argtypes = (ctypes.c_void_p, ctypes.c_char_p)
self.ctypes_libmecab.mecab_sparse_tostr.restype = ctypes.c_char_p
- self.ctypes_mecab = self.ctypes_libmecab.mecab_new2(param)
+ self.ctypes_mecab = self.ctypes_libmecab.mecab_new2(param.encode(fs_enc))
+ if self.ctypes_mecab is None:
+ raise SphinxError('mecab initialization failed')
def __del__(self):
if self.ctypes_libmecab:
diff --git a/sphinx/search/zh.py b/sphinx/search/zh.py
new file mode 100644
index 000000000..92f66e971
--- /dev/null
+++ b/sphinx/search/zh.py
@@ -0,0 +1,276 @@
+# -*- coding: utf-8 -*-
+"""
+ sphinx.search.zh
+ ~~~~~~~~~~~~~~~~
+
+ Chinese search language: includes routine to split words.
+
+ :copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS.
+ :license: BSD, see LICENSE for details.
+"""
+
+import os
+import re
+
+from sphinx.search import SearchLanguage
+
+try:
+ from Stemmer import Stemmer as PyStemmer
+ PYSTEMMER = True
+except ImportError:
+ from sphinx.util.stemmer import PorterStemmer
+ PYSTEMMER = False
+
+try:
+ import jieba
+ JIEBA = True
+except ImportError:
+ JIEBA = False
+
+english_stopwords = set("""
+a and are as at
+be but by
+for
+if in into is it
+near no not
+of on or
+such
+that the their then there these they this to
+was will with
+""".split())
+
+js_porter_stemmer = """
+/**
+ * Porter Stemmer
+ */
+var Stemmer = function() {
+
+ var step2list = {
+ ational: 'ate',
+ tional: 'tion',
+ enci: 'ence',
+ anci: 'ance',
+ izer: 'ize',
+ bli: 'ble',
+ alli: 'al',
+ entli: 'ent',
+ eli: 'e',
+ ousli: 'ous',
+ ization: 'ize',
+ ation: 'ate',
+ ator: 'ate',
+ alism: 'al',
+ iveness: 'ive',
+ fulness: 'ful',
+ ousness: 'ous',
+ aliti: 'al',
+ iviti: 'ive',
+ biliti: 'ble',
+ logi: 'log'
+ };
+
+ var step3list = {
+ icate: 'ic',
+ ative: '',
+ alize: 'al',
+ iciti: 'ic',
+ ical: 'ic',
+ ful: '',
+ ness: ''
+ };
+
+ var c = "[^aeiou]"; // consonant
+ var v = "[aeiouy]"; // vowel
+ var C = c + "[^aeiouy]*"; // consonant sequence
+ var V = v + "[aeiou]*"; // vowel sequence
+
+ var mgr0 = "^(" + C + ")?" + V + C; // [C]VC... is m>0
+ var meq1 = "^(" + C + ")?" + V + C + "(" + V + ")?$"; // [C]VC[V] is m=1
+ var mgr1 = "^(" + C + ")?" + V + C + V + C; // [C]VCVC... is m>1
+ var s_v = "^(" + C + ")?" + v; // vowel in stem
+
+ this.stemWord = function (w) {
+ var stem;
+ var suffix;
+ var firstch;
+ var origword = w;
+
+ if (w.length < 3)
+ return w;
+
+ var re;
+ var re2;
+ var re3;
+ var re4;
+
+ firstch = w.substr(0,1);
+ if (firstch == "y")
+ w = firstch.toUpperCase() + w.substr(1);
+
+ // Step 1a
+ re = /^(.+?)(ss|i)es$/;
+ re2 = /^(.+?)([^s])s$/;
+
+ if (re.test(w))
+ w = w.replace(re,"$1$2");
+ else if (re2.test(w))
+ w = w.replace(re2,"$1$2");
+
+ // Step 1b
+ re = /^(.+?)eed$/;
+ re2 = /^(.+?)(ed|ing)$/;
+ if (re.test(w)) {
+ var fp = re.exec(w);
+ re = new RegExp(mgr0);
+ if (re.test(fp[1])) {
+ re = /.$/;
+ w = w.replace(re,"");
+ }
+ }
+ else if (re2.test(w)) {
+ var fp = re2.exec(w);
+ stem = fp[1];
+ re2 = new RegExp(s_v);
+ if (re2.test(stem)) {
+ w = stem;
+ re2 = /(at|bl|iz)$/;
+ re3 = new RegExp("([^aeiouylsz])\\\\1$");
+ re4 = new RegExp("^" + C + v + "[^aeiouwxy]$");
+ if (re2.test(w))
+ w = w + "e";
+ else if (re3.test(w)) {
+ re = /.$/;
+ w = w.replace(re,"");
+ }
+ else if (re4.test(w))
+ w = w + "e";
+ }
+ }
+
+ // Step 1c
+ re = /^(.+?)y$/;
+ if (re.test(w)) {
+ var fp = re.exec(w);
+ stem = fp[1];
+ re = new RegExp(s_v);
+ if (re.test(stem))
+ w = stem + "i";
+ }
+
+ // Step 2
+ re = /^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|\
+ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/;
+ if (re.test(w)) {
+ var fp = re.exec(w);
+ stem = fp[1];
+ suffix = fp[2];
+ re = new RegExp(mgr0);
+ if (re.test(stem))
+ w = stem + step2list[suffix];
+ }
+
+ // Step 3
+ re = /^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/;
+ if (re.test(w)) {
+ var fp = re.exec(w);
+ stem = fp[1];
+ suffix = fp[2];
+ re = new RegExp(mgr0);
+ if (re.test(stem))
+ w = stem + step3list[suffix];
+ }
+
+ // Step 4
+ re = /^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|\
+iti|ous|ive|ize)$/;
+ re2 = /^(.+?)(s|t)(ion)$/;
+ if (re.test(w)) {
+ var fp = re.exec(w);
+ stem = fp[1];
+ re = new RegExp(mgr1);
+ if (re.test(stem))
+ w = stem;
+ }
+ else if (re2.test(w)) {
+ var fp = re2.exec(w);
+ stem = fp[1] + fp[2];
+ re2 = new RegExp(mgr1);
+ if (re2.test(stem))
+ w = stem;
+ }
+
+ // Step 5
+ re = /^(.+?)e$/;
+ if (re.test(w)) {
+ var fp = re.exec(w);
+ stem = fp[1];
+ re = new RegExp(mgr1);
+ re2 = new RegExp(meq1);
+ re3 = new RegExp("^" + C + v + "[^aeiouwxy]$");
+ if (re.test(stem) || (re2.test(stem) && !(re3.test(stem))))
+ w = stem;
+ }
+ re = /ll$/;
+ re2 = new RegExp(mgr1);
+ if (re.test(w) && re2.test(w)) {
+ re = /.$/;
+ w = w.replace(re,"");
+ }
+
+ // and turn initial Y back to y
+ if (firstch == "y")
+ w = firstch.toLowerCase() + w.substr(1);
+ return w;
+ }
+}
+"""
+
+
+class SearchChinese(SearchLanguage):
+ """
+ Chinese search implementation
+ """
+
+ lang = 'zh'
+ language_name = 'Chinese'
+ js_stemmer_code = js_porter_stemmer
+ stopwords = english_stopwords
+ latin1_letters = re.compile(r'\w+(?u)[\u0000-\u00ff]')
+
+ def init(self, options):
+ if JIEBA:
+ dict_path = options.get('dict')
+ if dict_path and os.path.isfile(dict_path):
+ jieba.set_dictionary(dict_path)
+
+ if PYSTEMMER:
+ class Stemmer(object):
+ def __init__(self):
+ self.stemmer = PyStemmer('porter')
+
+ def stem(self, word):
+ return self.stemmer.stemWord(word)
+ else:
+ class Stemmer(PorterStemmer):
+ """All those porter stemmer implementations look hideous;
+ make at least the stem method nicer.
+ """
+ def stem(self, word):
+ word = word.lower()
+ return PorterStemmer.stem(self, word, 0, len(word) - 1)
+
+ self.stemmer = Stemmer()
+
+ def split(self, input):
+ chinese = []
+ if JIEBA:
+ chinese = list(jieba.cut_for_search(input))
+
+ latin1 = self.latin1_letters.findall(input)
+ return chinese + latin1
+
+ def word_filter(self, stemmed_word):
+ return len(stemmed_word) > 1
+
+ def stem(self, word):
+ return self.stemmer.stem(word)
diff --git a/sphinx/setup_command.py b/sphinx/setup_command.py
index 1a942c5da..128c1415c 100644
--- a/sphinx/setup_command.py
+++ b/sphinx/setup_command.py
@@ -8,7 +8,7 @@
:author: Sebastian Wiesner
:contact: basti.wiesner@gmx.net
- :copyright: Copyright 2007-2015 by the Sphinx team, see AUTHORS.
+ :copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
from __future__ import print_function
diff --git a/sphinx/texinputs/Makefile b/sphinx/texinputs/Makefile
index 5e6030c0d..d748006cc 100644
--- a/sphinx/texinputs/Makefile
+++ b/sphinx/texinputs/Makefile
@@ -8,6 +8,8 @@ ALLDVI = $(addsuffix .dvi,$(ALLDOCS))
ARCHIVEPRREFIX =
# Additional LaTeX options
LATEXOPTS =
+# format: pdf or dvi
+FMT = pdf
LATEX = latex
PDFLATEX = pdflatex
@@ -41,9 +43,15 @@ tar: all-$(FMT)
tar cf $(ARCHIVEPREFIX)docs-$(FMT).tar $(ARCHIVEPREFIX)docs-$(FMT)
rm -r $(ARCHIVEPREFIX)docs-$(FMT)
+gz: tar
+ gzip -9 < $(ARCHIVEPREFIX)docs-$(FMT).tar > $(ARCHIVEPREFIX)docs-$(FMT).tar.gz
+
bz2: tar
bzip2 -9 -k $(ARCHIVEPREFIX)docs-$(FMT).tar
+xz: tar
+ xz -9 -k $(ARCHIVEPREFIX)docs-$(FMT).tar
+
# The number of LaTeX runs is quite conservative, but I don't expect it
# to get run often, so the little extra time won't hurt.
%.dvi: %.tex
@@ -63,8 +71,8 @@ bz2: tar
$(PDFLATEX) $(LATEXOPTS) '$<'
clean:
- rm -f *.dvi *.log *.ind *.aux *.toc *.syn *.idx *.out *.ilg *.pla
+ rm -f *.log *.ind *.aux *.toc *.syn *.idx *.out *.ilg *.pla *.ps *.tar *.tar.gz *.tar.bz2 *.tar.xz $(ALLPDF) $(ALLDVI)
-.PHONY: all all-pdf all-dvi all-ps clean
+.PHONY: all all-pdf all-dvi all-ps clean zip tar gz bz2 xz
.PHONY: all-pdf-ja
diff --git a/sphinx/texinputs/sphinx.sty b/sphinx/texinputs/sphinx.sty
index 210f6ea1d..f94d5c934 100644
--- a/sphinx/texinputs/sphinx.sty
+++ b/sphinx/texinputs/sphinx.sty
@@ -19,7 +19,13 @@
\RequirePackage{makeidx}
\RequirePackage{framed}
\RequirePackage{ifthen}
-\RequirePackage{color}
+%The xcolor package draws better fcolorboxes
+%around verbatim code
+\IfFileExists{xcolor.sty}{
+ \RequirePackage[xcdraw]{xcolor}
+}{
+ \RequirePackage{color}
+}
% For highlighted code.
\RequirePackage{fancyvrb}
% For table captions.
@@ -52,18 +58,12 @@
%\renewcommand{\paperwidth}{7in} % O'Reilly ``Programmming Python''
% use pdfoutput for pTeX and dvipdfmx
+% when pTeX (\kanjiskip is defined), set pdfoutput to evade \include{pdfcolor}
\ifx\kanjiskip\undefined\else
- \ifx\Gin@driver{dvipdfmx.def}\undefined\else
- \newcount\pdfoutput\pdfoutput=0
- \fi
+ \newcount\pdfoutput\pdfoutput=0
\fi
-% For graphicx, check if we are compiling under latex or pdflatex.
-\ifx\pdftexversion\undefined
- \usepackage{graphicx}
-\else
- \usepackage[pdftex]{graphicx}
-\fi
+\RequirePackage{graphicx}
% for PDF output, use colors and maximal compression
\newif\ifsphinxpdfoutput\sphinxpdfoutputfalse
@@ -270,16 +270,15 @@
\fbox{\TheSbox}
}
-\newcommand{\py@lightbox}{{%
- \setlength\parskip{0pt}\par
- \noindent\rule[0ex]{\linewidth}{0.5pt}%
- \par\noindent\vspace{-0.5ex}%
- }}
-\newcommand{\py@endlightbox}{{%
- \setlength{\parskip}{0pt}%
- \par\noindent\rule[0.5ex]{\linewidth}{0.5pt}%
- \par\vspace{-0.5ex}%
- }}
+\newcommand{\py@lightbox}{%
+ \par\allowbreak
+ \noindent\rule{\linewidth}{0.5pt}\par\nobreak
+ {\parskip\z@skip\noindent}%
+ }
+\newcommand{\py@endlightbox}{%
+ \par\nobreak
+ {\parskip\z@skip\noindent\rule[.4\baselineskip]{\linewidth}{0.5pt}}\par
+ }
% Some are quite plain:
\newcommand{\py@noticestart@note}{\py@lightbox}
@@ -445,15 +444,18 @@
\RequirePackage{hypcap}
% From docutils.writers.latex2e
-\providecommand{\DUspan}[2]{%
- {% group ("span") to limit the scope of styling commands
- \@for\node@class@name:=#1\do{%
- \ifcsname docutilsrole\node@class@name\endcsname%
- \csname docutilsrole\node@class@name\endcsname%
+% inline markup (custom roles)
+% \DUrole{#1}{#2} tries \DUrole#1{#2}
+\providecommand*{\DUrole}[2]{%
+ \ifcsname DUrole#1\endcsname%
+ \csname DUrole#1\endcsname{#2}%
+ \else% backwards compatibility: try \docutilsrole#1{#2}
+ \ifcsname docutilsrole#1\endcsname%
+ \csname docutilsrole#1\endcsname{#2}%
+ \else%
+ #2%
\fi%
- }%
- {#2}% node content
- }% close "span"
+ \fi%
}
\providecommand*{\DUprovidelength}[2]{
@@ -525,11 +527,18 @@
\fi
% Define literal-block environment
-\RequirePackage{float}
-\floatstyle{plaintop}
+\RequirePackage{newfloat}
+\DeclareFloatingEnvironment{literal-block}
\ifx\thechapter\undefined
- \newfloat{literal-block}{htbp}{loc}[section]
+ \SetupFloatingEnvironment{literal-block}{within=section,placement=h}
\else
- \newfloat{literal-block}{htbp}{loc}[chapter]
+ \SetupFloatingEnvironment{literal-block}{within=chapter,placement=h}
\fi
-\floatname{literal-block}{List}
+\SetupFloatingEnvironment{literal-block}{name=List}
+% control caption around literal-block
+\RequirePackage{capt-of}
+\RequirePackage{needspace}
+% if the left page space is less than \literalblockneedsapce, insert page-break
+\newcommand{\literalblockneedspace}{5\baselineskip}
+% margin before the caption of literal-block
+\newcommand{\literalblockcaptiontopvspace}{0.5\baselineskip}
diff --git a/sphinx/themes/agogo/layout.html b/sphinx/themes/agogo/layout.html
index 6a80a207f..9a24b834f 100644
--- a/sphinx/themes/agogo/layout.html
+++ b/sphinx/themes/agogo/layout.html
@@ -5,7 +5,7 @@
Sphinx layout template for the agogo theme, originally written
by Andi Albrecht.
- :copyright: Copyright 2007-2015 by the Sphinx team, see AUTHORS.
+ :copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
#}
{%- extends "basic/layout.html" %}
diff --git a/sphinx/themes/agogo/static/agogo.css_t b/sphinx/themes/agogo/static/agogo.css_t
index 87801d685..26df9d6d5 100644
--- a/sphinx/themes/agogo/static/agogo.css_t
+++ b/sphinx/themes/agogo/static/agogo.css_t
@@ -4,7 +4,7 @@
*
* Sphinx stylesheet -- agogo theme.
*
- * :copyright: Copyright 2007-2015 by the Sphinx team, see AUTHORS.
+ * :copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS.
* :license: BSD, see LICENSE for details.
*
*/
diff --git a/sphinx/themes/basic/changes/frameset.html b/sphinx/themes/basic/changes/frameset.html
index 9d9af9eb5..e14cb9e15 100644
--- a/sphinx/themes/basic/changes/frameset.html
+++ b/sphinx/themes/basic/changes/frameset.html
@@ -1,6 +1,6 @@
-
+
{% trans version=version|e, docstitle=docstitle|e %}Changes in Version {{ version }} — {{ docstitle }}{% endtrans %}
diff --git a/sphinx/themes/basic/changes/rstsource.html b/sphinx/themes/basic/changes/rstsource.html
index abd12c1d0..0a27479b0 100644
--- a/sphinx/themes/basic/changes/rstsource.html
+++ b/sphinx/themes/basic/changes/rstsource.html
@@ -1,6 +1,6 @@
-
+
{% trans filename=filename, docstitle=docstitle|e %}{{ filename }} — {{ docstitle }}{% endtrans %}