diff options
| author | Georg Brandl <georg@python.org> | 2014-01-17 07:25:31 +0100 |
|---|---|---|
| committer | Georg Brandl <georg@python.org> | 2014-01-17 07:25:31 +0100 |
| commit | caf7fccc80bc2fb485599113bb4e977de0729169 (patch) | |
| tree | a841e992d1dacb1468656a5584e3ab93b72ed44e | |
| parent | 97df8becb0e97373d76c5d8809d50711a987cf92 (diff) | |
| parent | d0dccd32a9d4e0960c5be9a801b14a3739670684 (diff) | |
| download | sphinx-caf7fccc80bc2fb485599113bb4e977de0729169.tar.gz | |
merge with stable
40 files changed, 276 insertions, 224 deletions
@@ -1,9 +1,31 @@ -Release 1.2.1 (in development) -============================== +Release 1.3 (in development) +============================ + +Incompatible changes +-------------------- + +* Removed the ``sphinx.ext.oldcmarkup`` extension. + +New features +------------ + +* PR#202: Allow "." and "~" prefixed references in ``:param:`` doc fields + for Python. + +* #925: Allow list-typed config values to be provided on the command line, + like ``-D key=val1,val2``. + +* #668: Allow line numbering of ``code-block`` and ``literalinclude`` directives + to start at an arbitrary line number, with a new ``lineno-start`` option. + +* Prompt for the document language in sphinx-quickstart. Bugs fixed ---------- +* #1174: Fix smart quotes being applied inside roles like :rst:role:`program` or + :rst:role:`makevar`. + * #1335: Fix autosummary template overloading with exclamation prefix like ``{% extends "!autosummary/class.rst" %}`` cause infinite recursive function call. This caused by PR#181. diff --git a/doc/config.rst b/doc/config.rst index 82ecdfdf..181ef2a4 100644 --- a/doc/config.rst +++ b/doc/config.rst @@ -120,7 +120,7 @@ General configuration in that case. .. deprecated:: 1.0 - Use :confval:`exclude_patterns` instead. + Use :confval:`exclude_patterns` or :ref:`metadata` instead. .. confval:: exclude_trees diff --git a/doc/domains.rst b/doc/domains.rst index 024edc9a..6c3c4359 100644 --- a/doc/domains.rst +++ b/doc/domains.rst @@ -157,17 +157,6 @@ declarations: The following directives are provided for module and class contents: -.. rst:directive:: .. py:data:: name - - Describes global data in a module, including both variables and values used - as "defined constants." Class and object attributes are not documented - using this environment. - -.. rst:directive:: .. py:exception:: name - - Describes an exception class. The signature can, but need not include - parentheses with constructor arguments. - .. rst:directive:: .. py:function:: name(parameters) Describes a module-level function. The signature should include the @@ -178,11 +167,23 @@ The following directives are provided for module and class contents: For methods you should use :rst:dir:`py:method`. - The description should include information about the parameters required and - how they are used (especially whether mutable objects passed as parameters - are modified), side effects, and possible exceptions. This information can - optionally be given in a structured form, see :ref:`info-field-lists`. A - small example may be provided. + The description normally includes information about the parameters required + and how they are used (especially whether mutable objects passed as + parameters are modified), side effects, and possible exceptions. + + This information can (in any ``py`` directive) optionally be given in a + structured form, see :ref:`info-field-lists`. + +.. rst:directive:: .. py:data:: name + + Describes global data in a module, including both variables and values used + as "defined constants." Class and object attributes are not documented + using this environment. + +.. rst:directive:: .. py:exception:: name + + Describes an exception class. The signature can, but need not include + parentheses with constructor arguments. .. rst:directive:: .. py:class:: name .. py:class:: name(parameters) diff --git a/doc/ext/appapi.rst b/doc/ext/appapi.rst index a6393d40..156dede8 100644 --- a/doc/ext/appapi.rst +++ b/doc/ext/appapi.rst @@ -199,10 +199,13 @@ the following public API: .. index:: pair: function; directive The reference node will be of class ``literal`` (so it will be rendered in a - proportional font, as appropriate for code) unless you give the *ref_nodeclass* - argument, which must be a docutils node class (most useful are - ``docutils.nodes.emphasis`` or ``docutils.nodes.strong`` -- you can also use - ``docutils.nodes.generated`` if you want no further text decoration). + proportional font, as appropriate for code) unless you give the + *ref_nodeclass* argument, which must be a docutils node class. Most useful + are ``docutils.nodes.emphasis`` or ``docutils.nodes.strong`` -- you can also + use ``docutils.nodes.generated`` if you want no further text decoration. If + the text should be treated as literal (e.g. no smart quote replacement), but + not have typewriter styling, use ``sphinx.addnodes.literal_emphasis`` or + ``sphinx.addnodes.literal_strong``. For the role content, you have the same syntactical possibilities as for standard Sphinx roles (see :ref:`xref-syntax`). diff --git a/doc/ext/oldcmarkup.rst b/doc/ext/oldcmarkup.rst deleted file mode 100644 index 0fdd9fec..00000000 --- a/doc/ext/oldcmarkup.rst +++ /dev/null @@ -1,35 +0,0 @@ -:mod:`sphinx.ext.oldcmarkup` -- Compatibility extension for old C markup -======================================================================== - -.. module:: sphinx.ext.oldcmarkup - :synopsis: Allow further use of the pre-domain C markup -.. moduleauthor:: Georg Brandl - -.. versionadded:: 1.0 - - -This extension is a transition helper for projects that used the old -(pre-domain) C markup, i.e. the directives like ``cfunction`` and roles like -``cfunc``. Since the introduction of domains, they must be called by their -fully-qualified name (``c:function`` and ``c:func``, respectively) or, with the -default domain set to ``c``, by their new name (``function`` and ``func``). -(See :ref:`c-domain` for the details.) - -If you activate this extension, it will register the old names, and you can -use them like before Sphinx 1.0. The directives are: - -- ``cfunction`` -- ``cmember`` -- ``cmacro`` -- ``ctype`` -- ``cvar`` - -The roles are: - -- ``cdata`` -- ``cfunc`` -- ``cmacro`` -- ``ctype`` - -However, it is advised to migrate to the new markup -- this extension is a -compatibility convenience and will disappear in a future version of Sphinx. diff --git a/doc/extensions.rst b/doc/extensions.rst index 334e5039..7597f281 100644 --- a/doc/extensions.rst +++ b/doc/extensions.rst @@ -53,7 +53,6 @@ These extensions are built in and can be activated by respective entries in the ext/extlinks ext/viewcode ext/linkcode - ext/oldcmarkup Third-party extensions diff --git a/doc/invocation.rst b/doc/invocation.rst index 52ee803f..f831dc0a 100644 --- a/doc/invocation.rst +++ b/doc/invocation.rst @@ -124,13 +124,22 @@ The :program:`sphinx-build` script has several options: .. option:: -D setting=value Override a configuration value set in the :file:`conf.py` file. The value - must be a string or dictionary value. For the latter, supply the setting - name and key like this: ``-D latex_elements.docclass=scrartcl``. For boolean - values, use ``0`` or ``1`` as the value. + must be a number, string, list or dictionary value. + + For lists, you can separate elements with a comma like this: ``-D + html_theme_path=path1,path2``. + + For dictionary values, supply the setting name and key like this: + ``-D latex_elements.docclass=scrartcl``. + + For boolean values, use ``0`` or ``1`` as the value. .. versionchanged:: 0.6 The value can now be a dictionary value. + .. versionchanged:: 1.3 + The value can now also be a list value. + .. option:: -A name=value Make the *name* assigned to *value* in the HTML templates. diff --git a/doc/markup/code.rst b/doc/markup/code.rst index 98fdad7d..6e707e00 100644 --- a/doc/markup/code.rst +++ b/doc/markup/code.rst @@ -86,6 +86,14 @@ on line numbers for the individual block:: Some more Ruby code. +The first line number can be selected with the ``lineno-start`` option. If +present, ``linenos`` is automatically activated as well. + + .. code-block:: ruby + :lineno-start: 10 + + Some more Ruby code, with line numbering starting at 10. + Additionally, an ``emphasize-lines`` option can be given to have Pygments emphasize particular lines:: @@ -101,6 +109,9 @@ emphasize particular lines:: .. versionchanged:: 1.1 ``emphasize-lines`` has been added. +.. versionchanged:: 1.3 + ``lineno-start`` has been added. + Includes ^^^^^^^^ @@ -121,10 +132,11 @@ Includes Tabs in the input are expanded if you give a ``tab-width`` option with the desired tab width. - The directive also supports the ``linenos`` flag option to switch on line - numbers, the ``emphasize-lines`` option to emphasize particular lines, and - a ``language`` option to select a language different from the current - file's standard language. Example with options:: + Like :rst:dir:`code-block`, the directive supports the ``linenos`` flag + option to switch on line numbers, the ``lineno-start`` option to select the + first line number, the ``emphasize-lines`` option to emphasize particular + lines, and a ``language`` option to select a language different from the + current file's standard language. Example with options:: .. literalinclude:: example.rb :language: ruby diff --git a/doc/markup/toctree.rst b/doc/markup/toctree.rst index 9316e69a..fdecc37d 100644 --- a/doc/markup/toctree.rst +++ b/doc/markup/toctree.rst @@ -141,8 +141,9 @@ tables of contents. The ``toctree`` directive is the central element. In the end, all documents in the :term:`source directory` (or subdirectories) must occur in some ``toctree`` directive; Sphinx will emit a warning if it finds a file that is not included, because that means that this file will not - be reachable through standard navigation. Use :confval:`exclude_patterns` to - explicitly exclude documents or directories from building. + be reachable through standard navigation. Use :ref:`metadata` to remove the + warning, and :confval:`exclude_patterns` to explicitly exclude documents or + directories from building. The "master document" (selected by :confval:`master_doc`) is the "root" of the TOC tree hierarchy. It can be used as the documentation's main page, or diff --git a/sphinx/__init__.py b/sphinx/__init__.py index d41d4424..f93e57a1 100644 --- a/sphinx/__init__.py +++ b/sphinx/__init__.py @@ -15,12 +15,12 @@ import sys from os import path -__version__ = '1.2+' -__released__ = '1.2' # used when Sphinx builds its own docs +__version__ = '1.3a0' +__released__ = '1.3a0' # used when Sphinx builds its own docs # version info for better programmatic use # possible values for 3rd element: 'alpha', 'beta', 'rc', 'final' # 'final' has 0 as the last element -version_info = (1, 2, 0, 'final', 0) +version_info = (1, 3, 0, 'alpha', 0) package_dir = path.abspath(path.dirname(__file__)) diff --git a/sphinx/addnodes.py b/sphinx/addnodes.py index d8dca2ce..e3f6d7d6 100644 --- a/sphinx/addnodes.py +++ b/sphinx/addnodes.py @@ -168,6 +168,11 @@ class literal_emphasis(nodes.emphasis): applied (e.g. smartypants for HTML output). """ +class literal_strong(nodes.strong): + """Node that behaves like `strong`, but further text processors are not + applied (e.g. smartypants for HTML output). + """ + class abbreviation(nodes.Inline, nodes.TextElement): """Node for abbreviations with explanations.""" diff --git a/sphinx/application.py b/sphinx/application.py index ceb7c32c..6b86b181 100644 --- a/sphinx/application.py +++ b/sphinx/application.py @@ -15,6 +15,7 @@ import os import sys import types import posixpath +import traceback from os import path from cStringIO import StringIO @@ -112,8 +113,6 @@ class Sphinx(object): if self.confdir is None: self.confdir = self.srcdir - # backwards compatibility: activate old C markup - self.setup_extension('sphinx.ext.oldcmarkup') # load all user-given extension modules for extension in self.config.extensions: self.setup_extension(extension) @@ -122,7 +121,7 @@ class Sphinx(object): self.config.setup(self) # now that we know all config values, collect them from conf.py - self.config.init_values() + self.config.init_values(self.warn) # check the Sphinx version if requested if self.config.needs_sphinx and \ @@ -282,6 +281,7 @@ class Sphinx(object): try: mod = __import__(extension, None, None, ['setup']) except ImportError, err: + self.verbose('Original exception:\n' + traceback.format_exc()) raise ExtensionError('Could not import extension %s' % extension, err) if not hasattr(mod, 'setup'): diff --git a/sphinx/cmdline.py b/sphinx/cmdline.py index e5ad3ab5..2d7146c3 100644 --- a/sphinx/cmdline.py +++ b/sphinx/cmdline.py @@ -173,14 +173,11 @@ def main(argv): print >>sys.stderr, ('Error: -D option argument must be ' 'in the form name=value.') return 1 - try: - val = int(val) - except ValueError: - if likely_encoding and isinstance(val, bytes): - try: - val = val.decode(likely_encoding) - except UnicodeError: - pass + if likely_encoding and isinstance(val, bytes): + try: + val = val.decode(likely_encoding) + except UnicodeError: + pass confoverrides[key] = val elif opt == '-A': try: diff --git a/sphinx/config.py b/sphinx/config.py index 8b15bdf3..df74e914 100644 --- a/sphinx/config.py +++ b/sphinx/config.py @@ -214,8 +214,11 @@ class Config(object): self.overrides = overrides self.values = Config.config_values.copy() config = {} - if "extensions" in overrides: - config["extensions"] = overrides["extensions"] + if 'extensions' in overrides: + if isinstance(overrides['extensions'], (str, unicode)): + config['extensions'] = overrides.pop('extensions').split(',') + else: + config['extensions'] = overrides.pop('extensions') if dirname is not None: config_file = path.join(dirname, filename) config['__file__'] = config_file @@ -248,12 +251,36 @@ class Config(object): 'Please use Unicode strings, e.g. %r.' % (name, u'Content') ) - def init_values(self): + def init_values(self, warn): config = self._raw_config for valname, value in self.overrides.iteritems(): if '.' in valname: realvalname, key = valname.split('.', 1) config.setdefault(realvalname, {})[key] = value + continue + elif valname not in self.values: + warn('unknown config value %r in override, ignoring' % valname) + continue + defvalue = self.values[valname][0] + if isinstance(value, (str, unicode)): + if isinstance(defvalue, dict): + warn('cannot override dictionary config setting %r, ' + 'ignoring (use %r to set individual elements)' % + (valname, valname + '.key=value')) + continue + elif isinstance(defvalue, list): + config[valname] = value.split(',') + elif isinstance(defvalue, (int, long)): + try: + config[valname] = int(value) + except ValueError: + warn('invalid number %r for config value %r, ignoring' + % (value, valname)) + elif defvalue is not None and not isinstance(defvalue, (str, unicode)): + warn('cannot override config setting %r with unsupported type, ' + 'ignoring' % valname) + else: + config[valname] = value else: config[valname] = value for name in config: diff --git a/sphinx/directives/code.py b/sphinx/directives/code.py index 4d43e5ff..7b1acfd5 100644 --- a/sphinx/directives/code.py +++ b/sphinx/directives/code.py @@ -56,6 +56,7 @@ class CodeBlock(Directive): final_argument_whitespace = False option_spec = { 'linenos': directives.flag, + 'lineno-start': int, 'emphasize-lines': directives.unchanged_required, } @@ -75,9 +76,13 @@ class CodeBlock(Directive): literal = nodes.literal_block(code, code) literal['language'] = self.arguments[0] - literal['linenos'] = 'linenos' in self.options + literal['linenos'] = 'linenos' in self.options or \ + 'lineno-start' in self.options + extra_args = literal['highlight_args'] = {} if hl_lines is not None: - literal['highlight_args'] = {'hl_lines': hl_lines} + extra_args['hl_lines'] = hl_lines + if 'lineno-start' in self.options: + extra_args['linenostart'] = self.options['lineno-start'] set_source_info(self, literal) return [literal] @@ -95,6 +100,7 @@ class LiteralInclude(Directive): final_argument_whitespace = True option_spec = { 'linenos': directives.flag, + 'lineno-start': int, 'tab-width': int, 'language': directives.unchanged_required, 'encoding': directives.encoding, @@ -204,10 +210,13 @@ class LiteralInclude(Directive): set_source_info(self, retnode) if self.options.get('language', ''): retnode['language'] = self.options['language'] - if 'linenos' in self.options: - retnode['linenos'] = True + retnode['linenos'] = 'linenos' in self.options or \ + 'lineno-start' in self.options + extra_args = retnode['highlight_args'] = {} if hl_lines is not None: - retnode['highlight_args'] = {'hl_lines': hl_lines} + extra_args['hl_lines'] = hl_lines + if 'lineno-start' in self.options: + extra_args['linenostart'] = self.options['lineno-start'] env.note_dependency(rel_filename) return [retnode] diff --git a/sphinx/domains/python.py b/sphinx/domains/python.py index a7ed7557..6714e838 100644 --- a/sphinx/domains/python.py +++ b/sphinx/domains/python.py @@ -81,6 +81,23 @@ def _pseudo_parse_arglist(signode, arglist): signode += paramlist +# This override allows our inline type specifiers to behave like :class: link +# when it comes to handling "." and "~" prefixes. +class PyTypedField(TypedField): + def make_xref(self, rolename, domain, target, innernode=nodes.emphasis): + result = super(PyTypedField, self).make_xref(rolename, domain, target, + innernode) + if target.startswith('.'): + result['reftarget'] = target[1:] + result['refspecific'] = True + result[0][0] = nodes.Text(target[1:]) + if target.startswith('~'): + result['reftarget'] = target[1:] + title = target.split('.')[-1] + result[0][0] = nodes.Text(title) + return result + + class PyObject(ObjectDescription): """ Description of a general Python object. @@ -92,7 +109,7 @@ class PyObject(ObjectDescription): } doc_field_types = [ - TypedField('parameter', label=l_('Parameters'), + PyTypedField('parameter', label=l_('Parameters'), names=('param', 'parameter', 'arg', 'argument', 'keyword', 'kwarg', 'kwparam'), typerolename='obj', typenames=('paramtype', 'type'), diff --git a/sphinx/ext/oldcmarkup.py b/sphinx/ext/oldcmarkup.py deleted file mode 100644 index aa10246b..00000000 --- a/sphinx/ext/oldcmarkup.py +++ /dev/null @@ -1,67 +0,0 @@ -# -*- coding: utf-8 -*- -""" - sphinx.ext.oldcmarkup - ~~~~~~~~~~~~~~~~~~~~~ - - Extension for compatibility with old C markup (directives and roles). - - :copyright: Copyright 2007-2013 by the Sphinx team, see AUTHORS. - :license: BSD, see LICENSE for details. -""" - -from docutils.parsers.rst import directives - -from sphinx.util.compat import Directive - -_warned_oldcmarkup = False -WARNING_MSG = 'using old C markup; please migrate to new-style markup ' \ - '(e.g. c:function instead of cfunction), see ' \ - 'http://sphinx-doc.org/domains.html' - - -class OldCDirective(Directive): - has_content = True - required_arguments = 1 - optional_arguments = 0 - final_argument_whitespace = True - option_spec = { - 'noindex': directives.flag, - 'module': directives.unchanged, - } - - def run(self): - env = self.state.document.settings.env - if not env.app._oldcmarkup_warned: - self.state_machine.reporter.warning(WARNING_MSG, line=self.lineno) - env.app._oldcmarkup_warned = True - newname = 'c:' + self.name[1:] - newdir = env.lookup_domain_element('directive', newname)[0] - return newdir(newname, self.arguments, self.options, - self.content, self.lineno, self.content_offset, - self.block_text, self.state, self.state_machine).run() - - -def old_crole(typ, rawtext, text, lineno, inliner, options={}, content=[]): - env = inliner.document.settings.env - if not typ: - typ = env.config.default_role - if not env.app._oldcmarkup_warned: - inliner.reporter.warning(WARNING_MSG, line=lineno) - env.app._oldcmarkup_warned = True - newtyp = 'c:' + typ[1:] - newrole = env.lookup_domain_element('role', newtyp)[0] - return newrole(newtyp, rawtext, text, lineno, inliner, options, content) - - -def setup(app): - app._oldcmarkup_warned = False - app.add_directive('cfunction', OldCDirective) - app.add_directive('cmember', OldCDirective) - app.add_directive('cmacro', OldCDirective) - app.add_directive('ctype', OldCDirective) - app.add_directive('cvar', OldCDirective) - app.add_role('cdata', old_crole) - app.add_role('cfunc', old_crole) - app.add_role('cmacro', old_crole) - app.add_role('ctype', old_crole) - app.add_role('cmember', old_crole) diff --git a/sphinx/ext/todo.py b/sphinx/ext/todo.py index de5d2b9f..253ae07d 100644 --- a/sphinx/ext/todo.py +++ b/sphinx/ext/todo.py @@ -171,4 +171,3 @@ def setup(app): app.connect('doctree-read', process_todos) app.connect('doctree-resolved', process_todo_nodes) app.connect('env-purge-doc', purge_todos) - diff --git a/sphinx/quickstart.py b/sphinx/quickstart.py index f77e2f22..ce18c0c1 100644 --- a/sphinx/quickstart.py +++ b/sphinx/quickstart.py @@ -99,7 +99,10 @@ release = '%(release_str)s' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. -#language = None +# +# This is also used if you do content translation via gettext catalogs. +# Usually you set "language" from the command line for these cases. +language = %(language)r # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: @@ -320,7 +323,7 @@ epub_copyright = u'%(copyright_str)s' #epub_theme = 'epub' # The language of the text. It defaults to the language option -# or en if the language is not set. +# or 'en' if the language is not set. #epub_language = '' # The scheme of the identifier. Typical schemes are ISBN or URL. @@ -948,6 +951,7 @@ def ask_user(d): * author: author names * version: version of project * release: release of project + * language: document language * suffix: source file suffix * master: master document name * epub: use epub (bool) @@ -1014,6 +1018,18 @@ just set both to the same value.''' if 'release' not in d: do_prompt(d, 'release', 'Project release', d['version']) + if 'language' not in d: + print ''' +If the documents are to be written in a language other than English, +you can select a language here by its language code. Sphinx will then +translate text that it generates into that language. + +For a list of supported codes, see +http://sphinx-doc.org/config.html#confval-language.''' + do_prompt(d, 'language', 'Project language', 'en') + if d['language'] == 'en': + d['language'] = None + if 'suffix' not in d: print ''' The file name suffix for source files. Commonly, this is either ".txt" diff --git a/sphinx/roles.py b/sphinx/roles.py index 6703b6b8..3b858588 100644 --- a/sphinx/roles.py +++ b/sphinx/roles.py @@ -22,15 +22,15 @@ from sphinx.util.nodes import split_explicit_title, process_index_entry, \ generic_docroles = { - 'command' : nodes.strong, + 'command' : addnodes.literal_strong, 'dfn' : nodes.emphasis, 'kbd' : nodes.literal, 'mailheader' : addnodes.literal_emphasis, - 'makevar' : nodes.strong, + 'makevar' : addnodes.literal_strong, 'manpage' : addnodes.literal_emphasis, 'mimetype' : addnodes.literal_emphasis, 'newsgroup' : addnodes.literal_emphasis, - 'program' : nodes.strong, # XXX should be an x-ref + 'program' : addnodes.literal_strong, # XXX should be an x-ref 'regexp' : nodes.literal, } diff --git a/sphinx/themes/agogo/layout.html b/sphinx/themes/agogo/layout.html index fde19dbc..f2ddb217 100644 --- a/sphinx/themes/agogo/layout.html +++ b/sphinx/themes/agogo/layout.html @@ -11,7 +11,7 @@ {%- extends "basic/layout.html" %} {% block header %} - <div class="header-wrapper"> + <div class="header-wrapper" role="banner"> <div class="header"> {%- if logo %} <p class="logo"><a href="{{ pathto(master_doc) }}"> @@ -22,7 +22,7 @@ <div class="headertitle"><a href="{{ pathto(master_doc) }}">{{ shorttitle|e }}</a></div> {%- endblock %} - <div class="rel"> + <div class="rel" role="navigation" aria-label="related navigation"> {%- for rellink in rellinks|reverse %} <a href="{{ pathto(rellink[0]) }}" title="{{ rellink[1]|striptags|e }}" {{ accesskey(rellink[2]) }}>{{ rellink[3] }}</a> @@ -47,16 +47,18 @@ {{ toctree() }} {%- endblock %} {%- block sidebarsearch %} - <h3 style="margin-top: 1.5em;">{{ _('Search') }}</h3> - <form class="search" action="{{ pathto('search') }}" method="get"> - <input type="text" name="q" /> - <input type="submit" value="{{ _('Go') }}" /> - <input type="hidden" name="check_keywords" value="yes" /> - <input type="hidden" name="area" value="default" /> - </form> - <p class="searchtip" style="font-size: 90%"> - {{ _('Enter search terms or a module, class or function name.') }} - </p> + <div role="search"> + <h3 style="margin-top: 1.5em;">{{ _('Search') }}</h3> + <form class="search" action="{{ pathto('search') }}" method="get"> + <input type="text" name="q" /> + <input type="submit" value="{{ _('Go') }}" /> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> + <p class="searchtip" style="font-size: 90%"> + {{ _('Enter search terms or a module, class or function name.') }} + </p> + </div> {%- endblock %} </div> <div class="clearer"></div> @@ -68,16 +70,20 @@ <div class="footer-wrapper"> <div class="footer"> <div class="left"> - {%- for rellink in rellinks|reverse %} - <a href="{{ pathto(rellink[0]) }}" title="{{ rellink[1]|striptags|e }}" - {{ accesskey(rellink[2]) }}>{{ rellink[3] }}</a> - {%- if not loop.last %}{{ reldelim2 }}{% endif %} - {%- endfor %} - {%- if show_source and has_source and sourcename %} - <br/> - <a href="{{ pathto('_sources/' + sourcename, true)|e }}" - rel="nofollow">{{ _('Show Source') }}</a> - {%- endif %} + <div role="navigation" aria-label="related navigaton"> + {%- for rellink in rellinks|reverse %} + <a href="{{ pathto(rellink[0]) }}" title="{{ rellink[1]|striptags|e }}" + {{ accesskey(rellink[2]) }}>{{ rellink[3] }}</a> + {%- if not loop.last %}{{ reldelim2 }}{% endif %} + {%- endfor %} + </div> + <div role="note" aria-label="source link"> + {%- if show_source and has_source and sourcename %} + <br/> + <a href="{{ pathto('_sources/' + sourcename, true)|e }}" + rel="nofollow">{{ _('Show Source') }}</a> + {%- endif %} + </div> </div> <div class="right"> diff --git a/sphinx/themes/basic/layout.html b/sphinx/themes/basic/layout.html index 9e4e39a1..68a070b3 100644 --- a/sphinx/themes/basic/layout.html +++ b/sphinx/themes/basic/layout.html @@ -25,7 +25,7 @@ {%- endif %} {%- macro relbar() %} - <div class="related"> + <div class="related" role="navigation" aria-label="related navigation"> <h3>{{ _('Navigation') }}</h3> <ul> {%- for rellink in rellinks %} @@ -47,7 +47,7 @@ {%- macro sidebar() %} {%- if render_sidebar %} - <div class="sphinxsidebar"> + <div class="sphinxsidebar" role="navigation" aria-label="main navigation"> <div class="sphinxsidebarwrapper"> {%- block sidebarlogo %} {%- if logo %} @@ -152,7 +152,7 @@ {%- endblock %} {%- block extrahead %} {% endblock %} </head> - <body> + <body role="document"> {%- block header %}{% endblock %} {%- block relbar1 %}{{ relbar() }}{% endblock %} @@ -166,7 +166,7 @@ {%- if render_sidebar %} <div class="bodywrapper"> {%- endif %} - <div class="body"> + <div class="body" role="main"> {% block body %} {% endblock %} </div> {%- if render_sidebar %} @@ -183,7 +183,7 @@ {%- block relbar2 %}{{ relbar() }}{% endblock %} {%- block footer %} - <div class="footer"> + <div class="footer" role="contentinfo"> {%- if show_copyright %} {%- if hasdoc('copyright') %} {% trans path=pathto('copyright'), copyright=copyright|e %}© <a href="{{ path }}">Copyright</a> {{ copyright }}.{% endtrans %} diff --git a/sphinx/themes/basic/searchbox.html b/sphinx/themes/basic/searchbox.html index 609aac83..0a573c32 100644 --- a/sphinx/themes/basic/searchbox.html +++ b/sphinx/themes/basic/searchbox.html @@ -8,7 +8,7 @@ :license: BSD, see LICENSE for details. #} {%- if pagename != "search" %} -<div id="searchbox" style="display: none"> +<div id="searchbox" style="display: none" role="search"> <h3>{{ _('Quick search') }}</h3> <form class="search" action="{{ pathto('search') }}" method="get"> <input type="text" name="q" /> diff --git a/sphinx/themes/basic/sourcelink.html b/sphinx/themes/basic/sourcelink.html index 08232efc..fbbae064 100644 --- a/sphinx/themes/basic/sourcelink.html +++ b/sphinx/themes/basic/sourcelink.html @@ -8,9 +8,11 @@ :license: BSD, see LICENSE for details. #} {%- if show_source and has_source and sourcename %} - <h3>{{ _('This Page') }}</h3> - <ul class="this-page-menu"> - <li><a href="{{ pathto('_sources/' + sourcename, true)|e }}" - rel="nofollow">{{ _('Show Source') }}</a></li> - </ul> + <div role="note" aria-label="source link"> + <h3>{{ _('This Page') }}</h3> + <ul class="this-page-menu"> + <li><a href="{{ pathto('_sources/' + sourcename, true)|e }}" + rel="nofollow">{{ _('Show Source') }}</a></li> + </ul> + </div> {%- endif %} diff --git a/sphinx/themes/haiku/layout.html b/sphinx/themes/haiku/layout.html index 0c6b41e7..a98d89c6 100644 --- a/sphinx/themes/haiku/layout.html +++ b/sphinx/themes/haiku/layout.html @@ -32,7 +32,7 @@ {% endmacro %} {% block content %} - <div class="header"> + <div class="header" role="banner"> {%- block haikuheader %} {%- if theme_full_logo != "false" %} <a href="{{ pathto('index') }}"> @@ -48,7 +48,7 @@ {%- endif %} {%- endblock %} </div> - <div class="topnav"> + <div class="topnav" role="navigation" aria-label="top navigation"> {{ nav() }} </div> <div class="content"> @@ -60,7 +60,7 @@ {%- endif %}#} {% block body %}{% endblock %} </div> - <div class="bottomnav"> + <div class="bottomnav" role="navigation" aria-label="bottom navigation"> {{ nav() }} </div> {% endblock %} diff --git a/sphinx/themes/pyramid/layout.html b/sphinx/themes/pyramid/layout.html index 8780ceae..318a3662 100644 --- a/sphinx/themes/pyramid/layout.html +++ b/sphinx/themes/pyramid/layout.html @@ -10,7 +10,7 @@ {% block header %} {%- if logo %} -<div class="header"> +<div class="header" role="banner"> <div class="logo"> <a href="{{ pathto(master_doc) }}"> <img class="logo" src="{{ pathto('_static/' + logo, 1) }}" alt="Logo"/> diff --git a/sphinx/themes/scrolls/layout.html b/sphinx/themes/scrolls/layout.html index 48e5e4e4..0961808e 100644 --- a/sphinx/themes/scrolls/layout.html +++ b/sphinx/themes/scrolls/layout.html @@ -20,7 +20,7 @@ <h1 class="heading"><a href="{{ pathto('index') }}" title="back to the documentation overview"><span>{{ title|striptags|e }}</span></a></h1> </div> - <div class="relnav"> + <div class="relnav" role="navigation" aria-label="related navigation"> {%- if prev %} <a href="{{ prev.link|e }}">« {{ prev.title }}</a> | {%- endif %} @@ -31,7 +31,7 @@ </div> <div id="contentwrapper"> {%- if display_toc %} - <div id="toc"> + <div id="toc" role="navigation" aria-label="table of contents navigation"> <h3>{{ _('Table Of Contents') }}</h3> {{ toc }} </div> diff --git a/sphinx/util/docfields.py b/sphinx/util/docfields.py index 6fd8ba95..150bf3a1 100644 --- a/sphinx/util/docfields.py +++ b/sphinx/util/docfields.py @@ -99,7 +99,8 @@ class GroupedField(Field): return Field.make_field(self, types, domain, items[0]) for fieldarg, content in items: par = nodes.paragraph() - par += self.make_xref(self.rolename, domain, fieldarg, nodes.strong) + par += self.make_xref(self.rolename, domain, fieldarg, + addnodes.literal_strong) par += nodes.Text(' -- ') par += content listnode += nodes.list_item('', par) @@ -137,7 +138,8 @@ class TypedField(GroupedField): def make_field(self, types, domain, items): def handle_item(fieldarg, content): par = nodes.paragraph() - par += self.make_xref(self.rolename, domain, fieldarg, nodes.strong) + par += self.make_xref(self.rolename, domain, fieldarg, + addnodes.literal_strong) if fieldarg in types: par += nodes.Text(' (') # NOTE: using .pop() here to prevent a single type node to be diff --git a/sphinx/writers/html.py b/sphinx/writers/html.py index 41663a0c..308e1f5b 100644 --- a/sphinx/writers/html.py +++ b/sphinx/writers/html.py @@ -508,6 +508,11 @@ class HTMLTranslator(BaseTranslator): def depart_literal_emphasis(self, node): return self.depart_emphasis(node) + def visit_literal_strong(self, node): + return self.visit_strong(node) + def depart_literal_strong(self, node): + return self.depart_strong(node) + def visit_abbreviation(self, node): attrs = {} if node.hasattr('explanation'): @@ -618,6 +623,14 @@ class SmartyPantsHTMLTranslator(HTMLTranslator): self.depart_emphasis(node) self.no_smarty -= 1 + def visit_literal_strong(self, node): + self.no_smarty += 1 + self.visit_strong(node) + + def depart_literal_strong(self, node): + self.depart_strong(node) + self.no_smarty -= 1 + def visit_desc_signature(self, node): self.no_smarty += 1 HTMLTranslator.visit_desc_signature(self, node) diff --git a/sphinx/writers/latex.py b/sphinx/writers/latex.py index 3c1a50f8..b55adda0 100644 --- a/sphinx/writers/latex.py +++ b/sphinx/writers/latex.py @@ -1247,6 +1247,13 @@ class LaTeXTranslator(nodes.NodeVisitor): def depart_strong(self, node): self.body.append('}') + def visit_literal_strong(self, node): + self.body.append(r'\textbf{\texttt{') + self.no_contractions += 1 + def depart_literal_strong(self, node): + self.body.append('}}') + self.no_contractions -= 1 + def visit_abbreviation(self, node): abbr = node.astext() self.body.append(r'\textsc{') diff --git a/sphinx/writers/manpage.py b/sphinx/writers/manpage.py index bc4da17a..0aa0058c 100644 --- a/sphinx/writers/manpage.py +++ b/sphinx/writers/manpage.py @@ -304,6 +304,11 @@ class ManualPageTranslator(BaseTranslator): def depart_literal_emphasis(self, node): return self.depart_emphasis(node) + def visit_literal_strong(self, node): + return self.visit_strong(node) + def depart_literal_strong(self, node): + return self.depart_strong(node) + def visit_abbreviation(self, node): pass def depart_abbreviation(self, node): diff --git a/sphinx/writers/texinfo.py b/sphinx/writers/texinfo.py index 7b70485a..a930a525 100644 --- a/sphinx/writers/texinfo.py +++ b/sphinx/writers/texinfo.py @@ -1207,6 +1207,11 @@ class TexinfoTranslator(nodes.NodeVisitor): def depart_literal_emphasis(self, node): self.body.append('}') + def visit_literal_strong(self, node): + self.body.append('@code{') + def depart_literal_strong(self, node): + self.body.append('}') + def visit_index(self, node): # terminate the line but don't prevent paragraph breaks if isinstance(node.parent, nodes.paragraph): diff --git a/sphinx/writers/text.py b/sphinx/writers/text.py index 57a40b29..a174bc26 100644 --- a/sphinx/writers/text.py +++ b/sphinx/writers/text.py @@ -762,6 +762,11 @@ class TextTranslator(nodes.NodeVisitor): def depart_strong(self, node): self.add_text('**') + def visit_literal_strong(self, node): + self.add_text('**') + def depart_literal_strong(self, node): + self.add_text('**') + def visit_abbreviation(self, node): self.add_text('') def depart_abbreviation(self, node): diff --git a/tests/root/conf.py b/tests/root/conf.py index 8025ba33..3399043f 100644 --- a/tests/root/conf.py +++ b/tests/root/conf.py @@ -8,7 +8,7 @@ sys.path.append(os.path.abspath('..')) extensions = ['sphinx.ext.autodoc', 'sphinx.ext.jsmath', 'sphinx.ext.todo', 'sphinx.ext.coverage', 'sphinx.ext.autosummary', 'sphinx.ext.doctest', 'sphinx.ext.extlinks', - 'sphinx.ext.viewcode', 'sphinx.ext.oldcmarkup', 'ext'] + 'sphinx.ext.viewcode', 'ext'] jsmath_path = 'dummy.js' diff --git a/tests/root/includes.txt b/tests/root/includes.txt index 904f0677..08917811 100644 --- a/tests/root/includes.txt +++ b/tests/root/includes.txt @@ -40,6 +40,7 @@ Literalinclude options .. cssclass:: inc-lines .. literalinclude:: literal.inc :lines: 6-7,9 + :lineno-start: 6 .. cssclass:: inc-startend .. literalinclude:: literal.inc diff --git a/tests/root/objects.txt b/tests/root/objects.txt index 57e82212..73661d22 100644 --- a/tests/root/objects.txt +++ b/tests/root/objects.txt @@ -101,6 +101,7 @@ Referring to :func:`nothing <>`. :type hour: DuplicateType :param hour: Duplicate param. Should not lead to crashes. :type hour: DuplicateType + :param .Cls extcls: A class from another module. C items @@ -117,14 +118,6 @@ C items .. c:var:: sphinx_global -Old C items (from oldcmarkup ext) ---------------------------------- - -.. cfunction:: Sphinx_Func() - -Refer to :cfunc:`Sphinx_Func`. - - Javascript items ================ diff --git a/tests/test_build_html.py b/tests/test_build_html.py index ef8e3888..603ad546 100644 --- a/tests/test_build_html.py +++ b/tests/test_build_html.py @@ -44,9 +44,6 @@ reading included file u'.*?wrongenc.inc' seems to be wrong, try giving an \ %(root)s/includes.txt:4: WARNING: download file not readable: .*?nonexisting.png %(root)s/markup.txt:\\d+: WARNING: Malformed :option: u'Python c option', does \ not contain option marker - or -- or / -%(root)s/objects.txt:\\d*: WARNING: using old C markup; please migrate to \ -new-style markup \(e.g. c:function instead of cfunction\), see \ -http://sphinx-doc.org/domains.html """ HTML_WARNINGS = ENV_WARNINGS + """\ @@ -191,8 +188,6 @@ HTML_XPATH = { (".//a[@href='#c.SPHINX_USE_PYTHON']", ''), (".//a[@href='#c.SphinxType']", ''), (".//a[@href='#c.sphinx_global']", ''), - # reference from old C markup extension - (".//a[@href='#c.Sphinx_Func']", ''), # test global TOC created by toctree() (".//ul[@class='current']/li[@class='toctree-l1 current']/a[@href='']", 'Testing object descriptions'), diff --git a/tests/test_config.py b/tests/test_config.py index 4d3d51b0..ea6f3ba4 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -19,7 +19,8 @@ from sphinx.util.pycompat import b @with_app(confoverrides={'master_doc': 'master', 'nonexisting_value': 'True', - 'latex_elements.docclass': 'scrartcl'}) + 'latex_elements.docclass': 'scrartcl', + 'modindex_common_prefix': 'path1,path2'}) def test_core_config(app): cfg = app.config @@ -31,6 +32,7 @@ def test_core_config(app): # overrides assert cfg.master_doc == 'master' assert cfg.latex_elements['docclass'] == 'scrartcl' + assert cfg.modindex_common_prefix == ['path1', 'path2'] # simple default values assert 'locale_dirs' not in cfg.__dict__ @@ -92,7 +94,7 @@ def test_errors_warnings(dir): write_file(dir / 'conf.py', u'# -*- coding: utf-8\n\n' u'project = u"Jägermeister"\n', 'utf-8') cfg = Config(dir, 'conf.py', {}, None) - cfg.init_values() + cfg.init_values(lambda warning: 1/0) assert cfg.project == u'Jägermeister' # test the warning for bytestrings with non-ascii content @@ -122,5 +124,5 @@ def test_config_eol(tmpdir): for eol in ('\n', '\r\n'): configfile.write_bytes(b('project = "spam"' + eol)) cfg = Config(tmpdir, 'conf.py', {}, None) - cfg.init_values() + cfg.init_values(lambda warning: 1/0) assert cfg.project == u'spam' diff --git a/tests/test_intersphinx.py b/tests/test_intersphinx.py index a8679e7e..8ce02cc1 100644 --- a/tests/test_intersphinx.py +++ b/tests/test_intersphinx.py @@ -81,7 +81,7 @@ def test_read_inventory_v2(): '/util/glossary.html#term-a-term' -@with_app(confoverrides={'extensions': 'sphinx.ext.intersphinx'}) +@with_app() @with_tempdir def test_missing_reference(tempdir, app): inv_file = tempdir / 'inventory' @@ -157,7 +157,7 @@ def test_missing_reference(tempdir, app): assert contnode[0].astext() == 'py3k:unknown' -@with_app(confoverrides={'extensions': 'sphinx.ext.intersphinx'}) +@with_app() @with_tempdir def test_load_mappings_warnings(tempdir, app): """ diff --git a/tests/test_quickstart.py b/tests/test_quickstart.py index 9daa7401..7323f48e 100644 --- a/tests/test_quickstart.py +++ b/tests/test_quickstart.py @@ -170,6 +170,7 @@ def test_quickstart_all_answers(tempdir): 'Author name': u'Wolfgang Schäuble & G\'Beckstein'.encode('utf-8'), 'Project version': '2.0', 'Project release': '2.0.1', + 'Project language': 'de', 'Source file suffix': '.txt', 'Name of your master document': 'contents', 'autodoc': 'y', |
