mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge branch '2.0'
This commit is contained in:
commit
e628afd5cd
10
CHANGES
10
CHANGES
@ -50,10 +50,16 @@ Incompatible changes
|
|||||||
Deprecated
|
Deprecated
|
||||||
----------
|
----------
|
||||||
|
|
||||||
|
* The ``decode`` argument of ``sphinx.pycode.ModuleAnalyzer()``
|
||||||
|
* ``sphinx.directives.other.Index``
|
||||||
* ``sphinx.environment.BuildEnvironment.indexentries``
|
* ``sphinx.environment.BuildEnvironment.indexentries``
|
||||||
* ``sphinx.environment.collectors.indexentries.IndexEntriesCollector``
|
* ``sphinx.environment.collectors.indexentries.IndexEntriesCollector``
|
||||||
* ``sphinx.io.FiletypeNotFoundError``
|
* ``sphinx.io.FiletypeNotFoundError``
|
||||||
* ``sphinx.io.get_filetype()``
|
* ``sphinx.io.get_filetype()``
|
||||||
|
* ``sphinx.pycode.ModuleAnalyzer.encoding``
|
||||||
|
* ``sphinx.roles.Index``
|
||||||
|
* ``sphinx.util.detect_encoding()``
|
||||||
|
* ``sphinx.util.get_module_source()``
|
||||||
|
|
||||||
Features added
|
Features added
|
||||||
--------------
|
--------------
|
||||||
@ -62,12 +68,14 @@ Features added
|
|||||||
* #6446: duration: Add ``sphinx.ext.durations`` to inspect which documents slow
|
* #6446: duration: Add ``sphinx.ext.durations`` to inspect which documents slow
|
||||||
down the build
|
down the build
|
||||||
* #6837: LaTeX: Support a nested table
|
* #6837: LaTeX: Support a nested table
|
||||||
|
* #6966: graphviz: Support ``:class:`` option
|
||||||
|
|
||||||
Bugs fixed
|
Bugs fixed
|
||||||
----------
|
----------
|
||||||
|
|
||||||
* #6925: html: Remove redundant type="text/javascript" from <script> elements
|
* #6925: html: Remove redundant type="text/javascript" from <script> elements
|
||||||
* #6906: autodoc: failed to read the source codes encoeded in cp1251
|
* #6906, #6907: autodoc: failed to read the source codes encoeded in cp1251
|
||||||
|
* #6961: latex: warning for babel shown twice
|
||||||
|
|
||||||
Testing
|
Testing
|
||||||
--------
|
--------
|
||||||
|
@ -31,6 +31,16 @@ The following is a list of deprecated interfaces.
|
|||||||
- 5.0
|
- 5.0
|
||||||
- ``sphinx.domains.std.StandardDomain.note_object()``
|
- ``sphinx.domains.std.StandardDomain.note_object()``
|
||||||
|
|
||||||
|
* - ``decode`` argument of ``sphinx.pycode.ModuleAnalyzer()``
|
||||||
|
- 2.4
|
||||||
|
- 4.0
|
||||||
|
- N/A
|
||||||
|
|
||||||
|
* - ``sphinx.directives.other.Index``
|
||||||
|
- 2.4
|
||||||
|
- 4.0
|
||||||
|
- ``sphinx.domains.index.IndexDirective``
|
||||||
|
|
||||||
* - ``sphinx.environment.BuildEnvironment.indexentries``
|
* - ``sphinx.environment.BuildEnvironment.indexentries``
|
||||||
- 2.4
|
- 2.4
|
||||||
- 4.0
|
- 4.0
|
||||||
@ -51,6 +61,26 @@ The following is a list of deprecated interfaces.
|
|||||||
- 4.0
|
- 4.0
|
||||||
- ``sphinx.util.get_filetype()``
|
- ``sphinx.util.get_filetype()``
|
||||||
|
|
||||||
|
* - ``sphinx.pycode.ModuleAnalyzer.encoding``
|
||||||
|
- 2.4
|
||||||
|
- 4.0
|
||||||
|
- N/A
|
||||||
|
|
||||||
|
* - ``sphinx.roles.Index``
|
||||||
|
- 2.4
|
||||||
|
- 4.0
|
||||||
|
- ``sphinx.domains.index.IndexRole``
|
||||||
|
|
||||||
|
* - ``sphinx.util.detect_encoding()``
|
||||||
|
- 2.4
|
||||||
|
- 4.0
|
||||||
|
- ``tokenize.detect_encoding()``
|
||||||
|
|
||||||
|
* - ``sphinx.util.get_module_source()``
|
||||||
|
- 2.4
|
||||||
|
- 4.0
|
||||||
|
- N/A
|
||||||
|
|
||||||
* - ``sphinx.builders.gettext.POHEADER``
|
* - ``sphinx.builders.gettext.POHEADER``
|
||||||
- 2.3
|
- 2.3
|
||||||
- 4.0
|
- 4.0
|
||||||
|
@ -82,6 +82,13 @@ It adds these directives:
|
|||||||
|
|
||||||
.. versionadded:: 1.6
|
.. versionadded:: 1.6
|
||||||
|
|
||||||
|
.. rst:directive:option:: class: class names
|
||||||
|
:type: a list of class names separeted by spaces
|
||||||
|
|
||||||
|
The class name of the graph.
|
||||||
|
|
||||||
|
.. versionadded:: 2.4
|
||||||
|
|
||||||
|
|
||||||
.. rst:directive:: graph
|
.. rst:directive:: graph
|
||||||
|
|
||||||
@ -131,6 +138,13 @@ It adds these directives:
|
|||||||
|
|
||||||
.. versionadded:: 1.6
|
.. versionadded:: 1.6
|
||||||
|
|
||||||
|
.. rst:directive:option:: class: class names
|
||||||
|
:type: a list of class names separeted by spaces
|
||||||
|
|
||||||
|
The class name of the graph.
|
||||||
|
|
||||||
|
.. versionadded:: 2.4
|
||||||
|
|
||||||
|
|
||||||
.. rst:directive:: digraph
|
.. rst:directive:: digraph
|
||||||
|
|
||||||
@ -176,6 +190,13 @@ It adds these directives:
|
|||||||
|
|
||||||
.. versionadded:: 1.6
|
.. versionadded:: 1.6
|
||||||
|
|
||||||
|
.. rst:directive:option:: class: class names
|
||||||
|
:type: a list of class names separeted by spaces
|
||||||
|
|
||||||
|
The class name of the graph.
|
||||||
|
|
||||||
|
.. versionadded:: 2.4
|
||||||
|
|
||||||
|
|
||||||
There are also these config values:
|
There are also these config values:
|
||||||
|
|
||||||
|
@ -41,6 +41,7 @@ paths =
|
|||||||
|
|
||||||
[mypy]
|
[mypy]
|
||||||
python_version = 3.5
|
python_version = 3.5
|
||||||
|
disallow_incomplete_defs = True
|
||||||
show_column_numbers = True
|
show_column_numbers = True
|
||||||
show_error_context = True
|
show_error_context = True
|
||||||
ignore_missing_imports = True
|
ignore_missing_imports = True
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
The Sphinx documentation toolchain.
|
The Sphinx documentation toolchain.
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
The Sphinx documentation toolchain.
|
The Sphinx documentation toolchain.
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
Additional docutils nodes.
|
Additional docutils nodes.
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -12,6 +12,7 @@ import warnings
|
|||||||
from typing import Any, Dict, List, Sequence
|
from typing import Any, Dict, List, Sequence
|
||||||
|
|
||||||
from docutils import nodes
|
from docutils import nodes
|
||||||
|
from docutils.nodes import Node
|
||||||
|
|
||||||
from sphinx.deprecation import RemovedInSphinx40Warning
|
from sphinx.deprecation import RemovedInSphinx40Warning
|
||||||
|
|
||||||
@ -305,7 +306,8 @@ class abbreviation(nodes.abbreviation):
|
|||||||
.. deprecated:: 2.0
|
.. deprecated:: 2.0
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, rawsource: str = '', text: str = '', *children, **attributes) -> None:
|
def __init__(self, rawsource: str = '', text: str = '',
|
||||||
|
*children: Node, **attributes: Any) -> None:
|
||||||
warnings.warn("abbrevition node for Sphinx was replaced by docutils'.",
|
warnings.warn("abbrevition node for Sphinx was replaced by docutils'.",
|
||||||
RemovedInSphinx40Warning, stacklevel=2)
|
RemovedInSphinx40Warning, stacklevel=2)
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
Gracefully adapted from the TextPress system by Armin.
|
Gracefully adapted from the TextPress system by Armin.
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -422,7 +422,7 @@ class Sphinx:
|
|||||||
logger.debug('[app] disconnecting event: [id=%s]', listener_id)
|
logger.debug('[app] disconnecting event: [id=%s]', listener_id)
|
||||||
self.events.disconnect(listener_id)
|
self.events.disconnect(listener_id)
|
||||||
|
|
||||||
def emit(self, event: str, *args) -> List:
|
def emit(self, event: str, *args: Any) -> List:
|
||||||
"""Emit *event* and pass *arguments* to the callback functions.
|
"""Emit *event* and pass *arguments* to the callback functions.
|
||||||
|
|
||||||
Return the return values of all callbacks as a list. Do not emit core
|
Return the return values of all callbacks as a list. Do not emit core
|
||||||
@ -430,7 +430,7 @@ class Sphinx:
|
|||||||
"""
|
"""
|
||||||
return self.events.emit(event, *args)
|
return self.events.emit(event, *args)
|
||||||
|
|
||||||
def emit_firstresult(self, event: str, *args) -> Any:
|
def emit_firstresult(self, event: str, *args: Any) -> Any:
|
||||||
"""Emit *event* and pass *arguments* to the callback functions.
|
"""Emit *event* and pass *arguments* to the callback functions.
|
||||||
|
|
||||||
Return the result of the first callback that doesn't return ``None``.
|
Return the result of the first callback that doesn't return ``None``.
|
||||||
@ -508,7 +508,8 @@ class Sphinx:
|
|||||||
"""
|
"""
|
||||||
self.registry.add_translator(name, translator_class, override=override)
|
self.registry.add_translator(name, translator_class, override=override)
|
||||||
|
|
||||||
def add_node(self, node: "Type[Element]", override: bool = False, **kwds) -> None:
|
def add_node(self, node: "Type[Element]", override: bool = False,
|
||||||
|
**kwds: Tuple[Callable, Callable]) -> None:
|
||||||
"""Register a Docutils node class.
|
"""Register a Docutils node class.
|
||||||
|
|
||||||
This is necessary for Docutils internals. It may also be used in the
|
This is necessary for Docutils internals. It may also be used in the
|
||||||
@ -548,7 +549,7 @@ class Sphinx:
|
|||||||
|
|
||||||
def add_enumerable_node(self, node: "Type[Element]", figtype: str,
|
def add_enumerable_node(self, node: "Type[Element]", figtype: str,
|
||||||
title_getter: TitleGetter = None, override: bool = False,
|
title_getter: TitleGetter = None, override: bool = False,
|
||||||
**kwds) -> None:
|
**kwds: Tuple[Callable, Callable]) -> None:
|
||||||
"""Register a Docutils node class as a numfig target.
|
"""Register a Docutils node class as a numfig target.
|
||||||
|
|
||||||
Sphinx numbers the node automatically. And then the users can refer it
|
Sphinx numbers the node automatically. And then the users can refer it
|
||||||
@ -575,7 +576,7 @@ class Sphinx:
|
|||||||
self.registry.add_enumerable_node(node, figtype, title_getter, override=override)
|
self.registry.add_enumerable_node(node, figtype, title_getter, override=override)
|
||||||
self.add_node(node, override=override, **kwds)
|
self.add_node(node, override=override, **kwds)
|
||||||
|
|
||||||
def add_directive(self, name: str, cls: "Type[Directive]", override: bool = False):
|
def add_directive(self, name: str, cls: "Type[Directive]", override: bool = False) -> None:
|
||||||
"""Register a Docutils directive.
|
"""Register a Docutils directive.
|
||||||
|
|
||||||
*name* must be the prospective directive name. *cls* is a directive
|
*name* must be the prospective directive name. *cls* is a directive
|
||||||
@ -1036,7 +1037,7 @@ class Sphinx:
|
|||||||
"""
|
"""
|
||||||
self.registry.add_source_suffix(suffix, filetype, override=override)
|
self.registry.add_source_suffix(suffix, filetype, override=override)
|
||||||
|
|
||||||
def add_source_parser(self, *args, **kwargs) -> None:
|
def add_source_parser(self, *args: Any, **kwargs: Any) -> None:
|
||||||
"""Register a parser class.
|
"""Register a parser class.
|
||||||
|
|
||||||
.. versionadded:: 1.4
|
.. versionadded:: 1.4
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
Builder superclass for all builders.
|
Builder superclass for all builders.
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -118,11 +118,11 @@ class Builder:
|
|||||||
self.env.set_versioning_method(self.versioning_method,
|
self.env.set_versioning_method(self.versioning_method,
|
||||||
self.versioning_compare)
|
self.versioning_compare)
|
||||||
|
|
||||||
def get_translator_class(self, *args) -> "Type[nodes.NodeVisitor]":
|
def get_translator_class(self, *args: Any) -> "Type[nodes.NodeVisitor]":
|
||||||
"""Return a class of translator."""
|
"""Return a class of translator."""
|
||||||
return self.app.registry.get_translator_class(self)
|
return self.app.registry.get_translator_class(self)
|
||||||
|
|
||||||
def create_translator(self, *args) -> nodes.NodeVisitor:
|
def create_translator(self, *args: Any) -> nodes.NodeVisitor:
|
||||||
"""Return an instance of translator.
|
"""Return an instance of translator.
|
||||||
|
|
||||||
This method returns an instance of ``default_translator_class`` by default.
|
This method returns an instance of ``default_translator_class`` by default.
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
Base class of epub2/epub3 builders.
|
Base class of epub2/epub3 builders.
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
Build Apple help books.
|
Build Apple help books.
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
Changelog builder.
|
Changelog builder.
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ class ChangesBuilder(Builder):
|
|||||||
'deprecated': 'deprecated',
|
'deprecated': 'deprecated',
|
||||||
}
|
}
|
||||||
|
|
||||||
def write(self, *ignored) -> None:
|
def write(self, *ignored: Any) -> None:
|
||||||
version = self.config.version
|
version = self.config.version
|
||||||
domain = cast(ChangeSetDomain, self.env.get_domain('changeset'))
|
domain = cast(ChangeSetDomain, self.env.get_domain('changeset'))
|
||||||
libchanges = {} # type: Dict[str, List[Tuple[str, str, int]]]
|
libchanges = {} # type: Dict[str, List[Tuple[str, str, int]]]
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
.. _Devhelp: https://wiki.gnome.org/Apps/Devhelp
|
.. _Devhelp: https://wiki.gnome.org/Apps/Devhelp
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
Directory HTML builders.
|
Directory HTML builders.
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
The MessageCatalogBuilder class.
|
The MessageCatalogBuilder class.
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -198,7 +198,7 @@ if source_date_epoch is not None:
|
|||||||
|
|
||||||
|
|
||||||
class LocalTimeZone(tzinfo):
|
class LocalTimeZone(tzinfo):
|
||||||
def __init__(self, *args, **kw) -> None:
|
def __init__(self, *args: Any, **kw: Any) -> None:
|
||||||
super().__init__(*args, **kw) # type: ignore
|
super().__init__(*args, **kw) # type: ignore
|
||||||
self.tzdelta = tzdelta
|
self.tzdelta = tzdelta
|
||||||
|
|
||||||
@ -212,7 +212,7 @@ class LocalTimeZone(tzinfo):
|
|||||||
ltz = LocalTimeZone()
|
ltz = LocalTimeZone()
|
||||||
|
|
||||||
|
|
||||||
def should_write(filepath: str, new_content: str):
|
def should_write(filepath: str, new_content: str) -> bool:
|
||||||
if not path.exists(filepath):
|
if not path.exists(filepath):
|
||||||
return True
|
return True
|
||||||
try:
|
try:
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
Several HTML builders.
|
Several HTML builders.
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -858,7 +858,7 @@ class StandaloneHTMLBuilder(Builder):
|
|||||||
indexer_name, indexer_name),
|
indexer_name, indexer_name),
|
||||||
RemovedInSphinx40Warning)
|
RemovedInSphinx40Warning)
|
||||||
|
|
||||||
def _get_local_toctree(self, docname: str, collapse: bool = True, **kwds) -> str:
|
def _get_local_toctree(self, docname: str, collapse: bool = True, **kwds: Any) -> str:
|
||||||
if 'includehidden' not in kwds:
|
if 'includehidden' not in kwds:
|
||||||
kwds['includehidden'] = False
|
kwds['includehidden'] = False
|
||||||
return self.render_partial(TocTree(self.env).get_toctree_for(
|
return self.render_partial(TocTree(self.env).get_toctree_for(
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
Build HTML help support files.
|
Build HTML help support files.
|
||||||
Parts adapted from Python's Doc/tools/prechm.py.
|
Parts adapted from Python's Doc/tools/prechm.py.
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
LaTeX builder.
|
LaTeX builder.
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -216,7 +216,7 @@ class LaTeXBuilder(Builder):
|
|||||||
'[2016/05/29 stylesheet for highlighting with pygments]\n\n')
|
'[2016/05/29 stylesheet for highlighting with pygments]\n\n')
|
||||||
f.write(highlighter.get_stylesheet())
|
f.write(highlighter.get_stylesheet())
|
||||||
|
|
||||||
def write(self, *ignored) -> None:
|
def write(self, *ignored: Any) -> None:
|
||||||
docwriter = LaTeXWriter(self)
|
docwriter = LaTeXWriter(self)
|
||||||
docsettings = OptionParser(
|
docsettings = OptionParser(
|
||||||
defaults=self.env.settings,
|
defaults=self.env.settings,
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
Additional nodes for LaTeX writer.
|
Additional nodes for LaTeX writer.
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
Transforms for LaTeX builder.
|
Transforms for LaTeX builder.
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -32,7 +32,7 @@ class FootnoteDocnameUpdater(SphinxTransform):
|
|||||||
default_priority = 700
|
default_priority = 700
|
||||||
TARGET_NODES = (nodes.footnote, nodes.footnote_reference)
|
TARGET_NODES = (nodes.footnote, nodes.footnote_reference)
|
||||||
|
|
||||||
def apply(self, **kwargs) -> None:
|
def apply(self, **kwargs: Any) -> None:
|
||||||
matcher = NodeMatcher(*self.TARGET_NODES)
|
matcher = NodeMatcher(*self.TARGET_NODES)
|
||||||
for node in self.document.traverse(matcher): # type: nodes.Element
|
for node in self.document.traverse(matcher): # type: nodes.Element
|
||||||
node['docname'] = self.env.docname
|
node['docname'] = self.env.docname
|
||||||
@ -51,7 +51,7 @@ class ShowUrlsTransform(SphinxPostTransform):
|
|||||||
# references are expanded to footnotes (or not)
|
# references are expanded to footnotes (or not)
|
||||||
expanded = False
|
expanded = False
|
||||||
|
|
||||||
def run(self, **kwargs) -> None:
|
def run(self, **kwargs: Any) -> None:
|
||||||
try:
|
try:
|
||||||
# replace id_prefix temporarily
|
# replace id_prefix temporarily
|
||||||
settings = self.document.settings # type: Any
|
settings = self.document.settings # type: Any
|
||||||
@ -338,7 +338,7 @@ class LaTeXFootnoteTransform(SphinxPostTransform):
|
|||||||
default_priority = 600
|
default_priority = 600
|
||||||
builders = ('latex',)
|
builders = ('latex',)
|
||||||
|
|
||||||
def run(self, **kwargs) -> None:
|
def run(self, **kwargs: Any) -> None:
|
||||||
footnotes = list(self.document.traverse(nodes.footnote))
|
footnotes = list(self.document.traverse(nodes.footnote))
|
||||||
for node in footnotes:
|
for node in footnotes:
|
||||||
node.parent.remove(node)
|
node.parent.remove(node)
|
||||||
@ -490,7 +490,7 @@ class BibliographyTransform(SphinxPostTransform):
|
|||||||
default_priority = 750
|
default_priority = 750
|
||||||
builders = ('latex',)
|
builders = ('latex',)
|
||||||
|
|
||||||
def run(self, **kwargs) -> None:
|
def run(self, **kwargs: Any) -> None:
|
||||||
citations = thebibliography()
|
citations = thebibliography()
|
||||||
for node in self.document.traverse(nodes.citation):
|
for node in self.document.traverse(nodes.citation):
|
||||||
node.parent.remove(node)
|
node.parent.remove(node)
|
||||||
@ -509,7 +509,7 @@ class CitationReferenceTransform(SphinxPostTransform):
|
|||||||
default_priority = 5 # before ReferencesResolver
|
default_priority = 5 # before ReferencesResolver
|
||||||
builders = ('latex',)
|
builders = ('latex',)
|
||||||
|
|
||||||
def run(self, **kwargs) -> None:
|
def run(self, **kwargs: Any) -> None:
|
||||||
domain = cast(CitationDomain, self.env.get_domain('citation'))
|
domain = cast(CitationDomain, self.env.get_domain('citation'))
|
||||||
matcher = NodeMatcher(addnodes.pending_xref, refdomain='citation', reftype='ref')
|
matcher = NodeMatcher(addnodes.pending_xref, refdomain='citation', reftype='ref')
|
||||||
for node in self.document.traverse(matcher): # type: addnodes.pending_xref
|
for node in self.document.traverse(matcher): # type: addnodes.pending_xref
|
||||||
@ -529,7 +529,7 @@ class MathReferenceTransform(SphinxPostTransform):
|
|||||||
default_priority = 5 # before ReferencesResolver
|
default_priority = 5 # before ReferencesResolver
|
||||||
builders = ('latex',)
|
builders = ('latex',)
|
||||||
|
|
||||||
def run(self, **kwargs) -> None:
|
def run(self, **kwargs: Any) -> None:
|
||||||
equations = self.env.get_domain('math').data['objects']
|
equations = self.env.get_domain('math').data['objects']
|
||||||
for node in self.document.traverse(addnodes.pending_xref):
|
for node in self.document.traverse(addnodes.pending_xref):
|
||||||
if node['refdomain'] == 'math' and node['reftype'] in ('eq', 'numref'):
|
if node['refdomain'] == 'math' and node['reftype'] in ('eq', 'numref'):
|
||||||
@ -544,7 +544,7 @@ class LiteralBlockTransform(SphinxPostTransform):
|
|||||||
default_priority = 400
|
default_priority = 400
|
||||||
builders = ('latex',)
|
builders = ('latex',)
|
||||||
|
|
||||||
def run(self, **kwargs) -> None:
|
def run(self, **kwargs: Any) -> None:
|
||||||
matcher = NodeMatcher(nodes.container, literal_block=True)
|
matcher = NodeMatcher(nodes.container, literal_block=True)
|
||||||
for node in self.document.traverse(matcher): # type: nodes.container
|
for node in self.document.traverse(matcher): # type: nodes.container
|
||||||
newnode = captioned_literal_block('', *node.children, **node.attributes)
|
newnode = captioned_literal_block('', *node.children, **node.attributes)
|
||||||
@ -556,7 +556,7 @@ class DocumentTargetTransform(SphinxPostTransform):
|
|||||||
default_priority = 400
|
default_priority = 400
|
||||||
builders = ('latex',)
|
builders = ('latex',)
|
||||||
|
|
||||||
def run(self, **kwargs) -> None:
|
def run(self, **kwargs: Any) -> None:
|
||||||
for node in self.document.traverse(addnodes.start_of_file):
|
for node in self.document.traverse(addnodes.start_of_file):
|
||||||
section = node.next_node(nodes.section)
|
section = node.next_node(nodes.section)
|
||||||
if section:
|
if section:
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
The CheckExternalLinksBuilder class.
|
The CheckExternalLinksBuilder class.
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
Manual pages builder.
|
Manual pages builder.
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -56,7 +56,7 @@ class ManualPageBuilder(Builder):
|
|||||||
raise NoUri
|
raise NoUri
|
||||||
|
|
||||||
@progress_message(__('writing'))
|
@progress_message(__('writing'))
|
||||||
def write(self, *ignored) -> None:
|
def write(self, *ignored: Any) -> None:
|
||||||
docwriter = ManualPageWriter(self)
|
docwriter = ManualPageWriter(self)
|
||||||
docsettings = OptionParser(
|
docsettings = OptionParser(
|
||||||
defaults=self.env.settings,
|
defaults=self.env.settings,
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
Build input files for the Qt collection generator.
|
Build input files for the Qt collection generator.
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
Single HTML builders.
|
Single HTML builders.
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ class SingleFileHTMLBuilder(StandaloneHTMLBuilder):
|
|||||||
if hashindex >= 0:
|
if hashindex >= 0:
|
||||||
refnode['refuri'] = fname + refuri[hashindex:]
|
refnode['refuri'] = fname + refuri[hashindex:]
|
||||||
|
|
||||||
def _get_local_toctree(self, docname: str, collapse: bool = True, **kwds) -> str:
|
def _get_local_toctree(self, docname: str, collapse: bool = True, **kwds: Any) -> str:
|
||||||
if 'includehidden' not in kwds:
|
if 'includehidden' not in kwds:
|
||||||
kwds['includehidden'] = False
|
kwds['includehidden'] = False
|
||||||
toctree = TocTree(self.env).get_toctree_for(docname, self, collapse, **kwds)
|
toctree = TocTree(self.env).get_toctree_for(docname, self, collapse, **kwds)
|
||||||
@ -149,7 +149,7 @@ class SingleFileHTMLBuilder(StandaloneHTMLBuilder):
|
|||||||
'display_toc': display_toc,
|
'display_toc': display_toc,
|
||||||
}
|
}
|
||||||
|
|
||||||
def write(self, *ignored) -> None:
|
def write(self, *ignored: Any) -> None:
|
||||||
docnames = self.env.all_docs
|
docnames = self.env.all_docs
|
||||||
|
|
||||||
with progress_message(__('preparing documents')):
|
with progress_message(__('preparing documents')):
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
Texinfo builder.
|
Texinfo builder.
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -90,7 +90,7 @@ class TexinfoBuilder(Builder):
|
|||||||
docname = docname[:-5]
|
docname = docname[:-5]
|
||||||
self.titles.append((docname, entry[2]))
|
self.titles.append((docname, entry[2]))
|
||||||
|
|
||||||
def write(self, *ignored) -> None:
|
def write(self, *ignored: Any) -> None:
|
||||||
self.init_document_data()
|
self.init_document_data()
|
||||||
for entry in self.document_data:
|
for entry in self.document_data:
|
||||||
docname, targetname, title, author = entry[:4]
|
docname, targetname, title, author = entry[:4]
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
Plain-text Sphinx builder.
|
Plain-text Sphinx builder.
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
Docutils-native XML and pseudo-XML builders.
|
Docutils-native XML and pseudo-XML builders.
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -4,6 +4,6 @@
|
|||||||
|
|
||||||
Modules for command line executables.
|
Modules for command line executables.
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
Build documentation from a provided source.
|
Build documentation from a provided source.
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
This is in its own module so that importing it is fast. It should not
|
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).
|
import the main Sphinx modules (like sphinx.applications, sphinx.builders).
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
Quickly setup documentation source to work with Sphinx.
|
Quickly setup documentation source to work with Sphinx.
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
Build configuration file handling.
|
Build configuration file handling.
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
Sphinx deprecation classes and utilities.
|
Sphinx deprecation classes and utilities.
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
Handlers for additional ReST directives.
|
Handlers for additional ReST directives.
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -253,12 +253,13 @@ from sphinx.directives.code import ( # noqa
|
|||||||
Highlight, CodeBlock, LiteralInclude
|
Highlight, CodeBlock, LiteralInclude
|
||||||
)
|
)
|
||||||
from sphinx.directives.other import ( # noqa
|
from sphinx.directives.other import ( # noqa
|
||||||
TocTree, Author, Index, VersionChange, SeeAlso,
|
TocTree, Author, VersionChange, SeeAlso,
|
||||||
TabularColumns, Centered, Acks, HList, Only, Include, Class
|
TabularColumns, Centered, Acks, HList, Only, Include, Class
|
||||||
)
|
)
|
||||||
from sphinx.directives.patches import ( # noqa
|
from sphinx.directives.patches import ( # noqa
|
||||||
Figure, Meta
|
Figure, Meta
|
||||||
)
|
)
|
||||||
|
from sphinx.domains.index import IndexDirective # noqa
|
||||||
|
|
||||||
deprecated_alias('sphinx.directives',
|
deprecated_alias('sphinx.directives',
|
||||||
{
|
{
|
||||||
@ -267,7 +268,7 @@ deprecated_alias('sphinx.directives',
|
|||||||
'LiteralInclude': LiteralInclude,
|
'LiteralInclude': LiteralInclude,
|
||||||
'TocTree': TocTree,
|
'TocTree': TocTree,
|
||||||
'Author': Author,
|
'Author': Author,
|
||||||
'Index': Index,
|
'Index': IndexDirective,
|
||||||
'VersionChange': VersionChange,
|
'VersionChange': VersionChange,
|
||||||
'SeeAlso': SeeAlso,
|
'SeeAlso': SeeAlso,
|
||||||
'TabularColumns': TabularColumns,
|
'TabularColumns': TabularColumns,
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
sphinx.directives.code
|
sphinx.directives.code
|
||||||
~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
sphinx.directives.other
|
sphinx.directives.other
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -18,12 +18,13 @@ from docutils.parsers.rst.directives.misc import Class
|
|||||||
from docutils.parsers.rst.directives.misc import Include as BaseInclude
|
from docutils.parsers.rst.directives.misc import Include as BaseInclude
|
||||||
|
|
||||||
from sphinx import addnodes
|
from sphinx import addnodes
|
||||||
|
from sphinx.deprecation import RemovedInSphinx40Warning, deprecated_alias
|
||||||
from sphinx.domains.changeset import VersionChange # NOQA # for compatibility
|
from sphinx.domains.changeset import VersionChange # NOQA # for compatibility
|
||||||
from sphinx.locale import _
|
from sphinx.locale import _
|
||||||
from sphinx.util import url_re, docname_join
|
from sphinx.util import url_re, docname_join
|
||||||
from sphinx.util.docutils import SphinxDirective
|
from sphinx.util.docutils import SphinxDirective
|
||||||
from sphinx.util.matching import Matcher, patfilter
|
from sphinx.util.matching import Matcher, patfilter
|
||||||
from sphinx.util.nodes import explicit_title_re, process_index_entry
|
from sphinx.util.nodes import explicit_title_re
|
||||||
|
|
||||||
if False:
|
if False:
|
||||||
# For type annotation
|
# For type annotation
|
||||||
@ -182,30 +183,6 @@ class Author(SphinxDirective):
|
|||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
class Index(SphinxDirective):
|
|
||||||
"""
|
|
||||||
Directive to add entries to the index.
|
|
||||||
"""
|
|
||||||
has_content = False
|
|
||||||
required_arguments = 1
|
|
||||||
optional_arguments = 0
|
|
||||||
final_argument_whitespace = True
|
|
||||||
option_spec = {} # type: Dict
|
|
||||||
|
|
||||||
def run(self) -> List[Node]:
|
|
||||||
arguments = self.arguments[0].split('\n')
|
|
||||||
targetid = 'index-%s' % self.env.new_serialno('index')
|
|
||||||
targetnode = nodes.target('', '', ids=[targetid])
|
|
||||||
self.state.document.note_explicit_target(targetnode)
|
|
||||||
indexnode = addnodes.index()
|
|
||||||
indexnode['entries'] = []
|
|
||||||
indexnode['inline'] = False
|
|
||||||
self.set_source_info(indexnode)
|
|
||||||
for entry in arguments:
|
|
||||||
indexnode['entries'].extend(process_index_entry(entry, targetid))
|
|
||||||
return [indexnode, targetnode]
|
|
||||||
|
|
||||||
|
|
||||||
class SeeAlso(BaseAdmonition):
|
class SeeAlso(BaseAdmonition):
|
||||||
"""
|
"""
|
||||||
An admonition mentioning things to look at as reference.
|
An admonition mentioning things to look at as reference.
|
||||||
@ -383,12 +360,21 @@ class Include(BaseInclude, SphinxDirective):
|
|||||||
return super().run()
|
return super().run()
|
||||||
|
|
||||||
|
|
||||||
|
# Import old modules here for compatibility
|
||||||
|
from sphinx.domains.index import IndexDirective # NOQA
|
||||||
|
|
||||||
|
deprecated_alias('sphinx.directives.other',
|
||||||
|
{
|
||||||
|
'Index': IndexDirective,
|
||||||
|
},
|
||||||
|
RemovedInSphinx40Warning)
|
||||||
|
|
||||||
|
|
||||||
def setup(app: "Sphinx") -> Dict[str, Any]:
|
def setup(app: "Sphinx") -> Dict[str, Any]:
|
||||||
directives.register_directive('toctree', TocTree)
|
directives.register_directive('toctree', TocTree)
|
||||||
directives.register_directive('sectionauthor', Author)
|
directives.register_directive('sectionauthor', Author)
|
||||||
directives.register_directive('moduleauthor', Author)
|
directives.register_directive('moduleauthor', Author)
|
||||||
directives.register_directive('codeauthor', Author)
|
directives.register_directive('codeauthor', Author)
|
||||||
directives.register_directive('index', Index)
|
|
||||||
directives.register_directive('seealso', SeeAlso)
|
directives.register_directive('seealso', SeeAlso)
|
||||||
directives.register_directive('tabularcolumns', TabularColumns)
|
directives.register_directive('tabularcolumns', TabularColumns)
|
||||||
directives.register_directive('centered', Centered)
|
directives.register_directive('centered', Centered)
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
sphinx.directives.patches
|
sphinx.directives.patches
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
Support for domains, which are groupings of description directives
|
Support for domains, which are groupings of description directives
|
||||||
and roles describing e.g. constructs of one programming language.
|
and roles describing e.g. constructs of one programming language.
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -48,7 +48,7 @@ class ObjType:
|
|||||||
'searchprio': 1,
|
'searchprio': 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, lname: str, *roles, **attrs) -> None:
|
def __init__(self, lname: str, *roles: Any, **attrs: Any) -> None:
|
||||||
self.lname = lname
|
self.lname = lname
|
||||||
self.roles = roles # type: Tuple
|
self.roles = roles # type: Tuple
|
||||||
self.attrs = self.known_attrs.copy() # type: Dict
|
self.attrs = self.known_attrs.copy() # type: Dict
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
The C language domain.
|
The C language domain.
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
The changeset domain.
|
The changeset domain.
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
The citation domain.
|
The citation domain.
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -112,7 +112,7 @@ class CitationDefinitionTransform(SphinxTransform):
|
|||||||
"""Mark citation definition labels as not smartquoted."""
|
"""Mark citation definition labels as not smartquoted."""
|
||||||
default_priority = 619
|
default_priority = 619
|
||||||
|
|
||||||
def apply(self, **kwargs) -> None:
|
def apply(self, **kwargs: Any) -> None:
|
||||||
domain = cast(CitationDomain, self.env.get_domain('citation'))
|
domain = cast(CitationDomain, self.env.get_domain('citation'))
|
||||||
for node in self.document.traverse(nodes.citation):
|
for node in self.document.traverse(nodes.citation):
|
||||||
# register citation node to domain
|
# register citation node to domain
|
||||||
@ -131,7 +131,7 @@ class CitationReferenceTransform(SphinxTransform):
|
|||||||
"""
|
"""
|
||||||
default_priority = 619
|
default_priority = 619
|
||||||
|
|
||||||
def apply(self, **kwargs) -> None:
|
def apply(self, **kwargs: Any) -> None:
|
||||||
domain = cast(CitationDomain, self.env.get_domain('citation'))
|
domain = cast(CitationDomain, self.env.get_domain('citation'))
|
||||||
for node in self.document.traverse(nodes.citation_reference):
|
for node in self.document.traverse(nodes.citation_reference):
|
||||||
target = node.astext()
|
target = node.astext()
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -4,20 +4,26 @@
|
|||||||
|
|
||||||
The index domain.
|
The index domain.
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from typing import Any, Dict, Iterable, List, Tuple
|
from typing import Any, Dict, Iterable, List, Tuple
|
||||||
|
|
||||||
from docutils.nodes import Node
|
from docutils import nodes
|
||||||
|
from docutils.nodes import Node, system_message
|
||||||
|
|
||||||
from sphinx import addnodes
|
from sphinx import addnodes
|
||||||
from sphinx.application import Sphinx
|
|
||||||
from sphinx.domains import Domain
|
from sphinx.domains import Domain
|
||||||
from sphinx.environment import BuildEnvironment
|
from sphinx.environment import BuildEnvironment
|
||||||
from sphinx.util import logging
|
from sphinx.util import logging
|
||||||
from sphinx.util import split_index_msg
|
from sphinx.util import split_index_msg
|
||||||
|
from sphinx.util.docutils import ReferenceRole, SphinxDirective
|
||||||
|
from sphinx.util.nodes import process_index_entry
|
||||||
|
|
||||||
|
if False:
|
||||||
|
# For type annotation
|
||||||
|
from sphinx.application import Sphinx
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@ -54,8 +60,57 @@ class IndexDomain(Domain):
|
|||||||
entries.append(entry)
|
entries.append(entry)
|
||||||
|
|
||||||
|
|
||||||
def setup(app: Sphinx) -> Dict[str, Any]:
|
class IndexDirective(SphinxDirective):
|
||||||
|
"""
|
||||||
|
Directive to add entries to the index.
|
||||||
|
"""
|
||||||
|
has_content = False
|
||||||
|
required_arguments = 1
|
||||||
|
optional_arguments = 0
|
||||||
|
final_argument_whitespace = True
|
||||||
|
option_spec = {} # type: Dict
|
||||||
|
|
||||||
|
def run(self) -> List[Node]:
|
||||||
|
arguments = self.arguments[0].split('\n')
|
||||||
|
targetid = 'index-%s' % self.env.new_serialno('index')
|
||||||
|
targetnode = nodes.target('', '', ids=[targetid])
|
||||||
|
self.state.document.note_explicit_target(targetnode)
|
||||||
|
indexnode = addnodes.index()
|
||||||
|
indexnode['entries'] = []
|
||||||
|
indexnode['inline'] = False
|
||||||
|
self.set_source_info(indexnode)
|
||||||
|
for entry in arguments:
|
||||||
|
indexnode['entries'].extend(process_index_entry(entry, targetid))
|
||||||
|
return [indexnode, targetnode]
|
||||||
|
|
||||||
|
|
||||||
|
class IndexRole(ReferenceRole):
|
||||||
|
def run(self) -> Tuple[List[Node], List[system_message]]:
|
||||||
|
target_id = 'index-%s' % self.env.new_serialno('index')
|
||||||
|
if self.has_explicit_title:
|
||||||
|
# if an explicit target is given, process it as a full entry
|
||||||
|
title = self.title
|
||||||
|
entries = process_index_entry(self.target, target_id)
|
||||||
|
else:
|
||||||
|
# otherwise we just create a single entry
|
||||||
|
if self.target.startswith('!'):
|
||||||
|
title = self.title[1:]
|
||||||
|
entries = [('single', self.target[1:], target_id, 'main', None)]
|
||||||
|
else:
|
||||||
|
title = self.title
|
||||||
|
entries = [('single', self.target, target_id, '', None)]
|
||||||
|
|
||||||
|
index = addnodes.index(entries=entries)
|
||||||
|
target = nodes.target('', '', ids=[target_id])
|
||||||
|
text = nodes.Text(title, title)
|
||||||
|
self.set_source_info(index)
|
||||||
|
return [index, target, text], []
|
||||||
|
|
||||||
|
|
||||||
|
def setup(app: "Sphinx") -> Dict[str, Any]:
|
||||||
app.add_domain(IndexDomain)
|
app.add_domain(IndexDomain)
|
||||||
|
app.add_directive('index', IndexDirective)
|
||||||
|
app.add_role('index', IndexRole())
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'version': 'builtin',
|
'version': 'builtin',
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
The JavaScript domain.
|
The JavaScript domain.
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
The math domain.
|
The math domain.
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
The Python domain.
|
The Python domain.
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
The reStructuredText domain.
|
The reStructuredText domain.
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
The standard domain.
|
The standard domain.
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -643,7 +643,7 @@ class StandardDomain(Domain):
|
|||||||
self.progoptions[program, name] = (docname, labelid)
|
self.progoptions[program, name] = (docname, labelid)
|
||||||
|
|
||||||
def build_reference_node(self, fromdocname: str, builder: "Builder", docname: str,
|
def build_reference_node(self, fromdocname: str, builder: "Builder", docname: str,
|
||||||
labelid: str, sectname: str, rolename: str, **options
|
labelid: str, sectname: str, rolename: str, **options: Any
|
||||||
) -> Element:
|
) -> Element:
|
||||||
nodeclass = options.pop('nodeclass', nodes.reference)
|
nodeclass = options.pop('nodeclass', nodes.reference)
|
||||||
newnode = nodeclass('', '', internal=True, **options)
|
newnode = nodeclass('', '', internal=True, **options)
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
Global creation environment.
|
Global creation environment.
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -4,6 +4,6 @@
|
|||||||
|
|
||||||
Sphinx environment adapters
|
Sphinx environment adapters
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
Assets adapter for sphinx.environment.
|
Assets adapter for sphinx.environment.
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
Index entries adapters for sphinx.environment.
|
Index entries adapters for sphinx.environment.
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
import bisect
|
import bisect
|
||||||
|
@ -4,12 +4,12 @@
|
|||||||
|
|
||||||
Toctree adapter for sphinx.environment.
|
Toctree adapter for sphinx.environment.
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from typing import Any, Iterable, List
|
||||||
from typing import cast
|
from typing import cast
|
||||||
from typing import Iterable, List
|
|
||||||
|
|
||||||
from docutils import nodes
|
from docutils import nodes
|
||||||
from docutils.nodes import Element, Node
|
from docutils.nodes import Element, Node
|
||||||
@ -314,8 +314,8 @@ class TocTree:
|
|||||||
node['refuri'] = node['anchorname'] or '#'
|
node['refuri'] = node['anchorname'] or '#'
|
||||||
return toc
|
return toc
|
||||||
|
|
||||||
def get_toctree_for(self, docname: str, builder: "Builder", collapse: bool, **kwds
|
def get_toctree_for(self, docname: str, builder: "Builder", collapse: bool,
|
||||||
) -> Element:
|
**kwds: Any) -> Element:
|
||||||
"""Return the global TOC nodetree."""
|
"""Return the global TOC nodetree."""
|
||||||
doctree = self.env.get_doctree(self.env.config.master_doc)
|
doctree = self.env.get_doctree(self.env.config.master_doc)
|
||||||
toctrees = [] # type: List[Element]
|
toctrees = [] # type: List[Element]
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
The data collector components for sphinx.environment.
|
The data collector components for sphinx.environment.
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
The image collector for sphinx.environment.
|
The image collector for sphinx.environment.
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
The dependencies collector components for sphinx.environment.
|
The dependencies collector components for sphinx.environment.
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
Index entries collector for sphinx.environment.
|
Index entries collector for sphinx.environment.
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
The metadata collector components for sphinx.environment.
|
The metadata collector components for sphinx.environment.
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
The title collector components for sphinx.environment.
|
The title collector components for sphinx.environment.
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
Toctree collector for sphinx.environment.
|
Toctree collector for sphinx.environment.
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
Contains SphinxError and a few subclasses (in an extra module to avoid
|
Contains SphinxError and a few subclasses (in an extra module to avoid
|
||||||
circular import problems).
|
circular import problems).
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
Gracefully adapted from the TextPress system by Armin.
|
Gracefully adapted from the TextPress system by Armin.
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -81,7 +81,7 @@ class EventManager:
|
|||||||
for event in self.listeners.values():
|
for event in self.listeners.values():
|
||||||
event.pop(listener_id, None)
|
event.pop(listener_id, None)
|
||||||
|
|
||||||
def emit(self, name: str, *args) -> List:
|
def emit(self, name: str, *args: Any) -> List:
|
||||||
"""Emit a Sphinx event."""
|
"""Emit a Sphinx event."""
|
||||||
try:
|
try:
|
||||||
logger.debug('[app] emitting event: %r%s', name, repr(args)[:100])
|
logger.debug('[app] emitting event: %r%s', name, repr(args)[:100])
|
||||||
@ -99,7 +99,7 @@ class EventManager:
|
|||||||
results.append(callback(self.app, *args))
|
results.append(callback(self.app, *args))
|
||||||
return results
|
return results
|
||||||
|
|
||||||
def emit_firstresult(self, name: str, *args) -> Any:
|
def emit_firstresult(self, name: str, *args: Any) -> Any:
|
||||||
"""Emit a Sphinx event and returns first result.
|
"""Emit a Sphinx event and returns first result.
|
||||||
|
|
||||||
This returns the result of the first handler that doesn't return ``None``.
|
This returns the result of the first handler that doesn't return ``None``.
|
||||||
|
@ -4,6 +4,6 @@
|
|||||||
|
|
||||||
Contains Sphinx features not activated by default.
|
Contains Sphinx features not activated by default.
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
Copyright 2008 Société des arts technologiques (SAT),
|
Copyright 2008 Société des arts technologiques (SAT),
|
||||||
https://sat.qc.ca/
|
https://sat.qc.ca/
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
the doctree, thus avoiding duplication between docstrings and documentation
|
the doctree, thus avoiding duplication between docstrings and documentation
|
||||||
for those who like elaborate docstrings.
|
for those who like elaborate docstrings.
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -227,7 +227,7 @@ class Documenter:
|
|||||||
|
|
||||||
option_spec = {'noindex': bool_option} # type: Dict[str, Callable]
|
option_spec = {'noindex': bool_option} # type: Dict[str, Callable]
|
||||||
|
|
||||||
def get_attr(self, obj: Any, name: str, *defargs) -> Any:
|
def get_attr(self, obj: Any, name: str, *defargs: Any) -> Any:
|
||||||
"""getattr() override for types such as Zope interfaces."""
|
"""getattr() override for types such as Zope interfaces."""
|
||||||
return autodoc_attrgetter(self.env.app, obj, name, *defargs)
|
return autodoc_attrgetter(self.env.app, obj, name, *defargs)
|
||||||
|
|
||||||
@ -357,7 +357,7 @@ class Documenter:
|
|||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def format_args(self, **kwargs) -> str:
|
def format_args(self, **kwargs: Any) -> str:
|
||||||
"""Format the argument signature of *self.object*.
|
"""Format the argument signature of *self.object*.
|
||||||
|
|
||||||
Should return None if the object does not have a signature.
|
Should return None if the object does not have a signature.
|
||||||
@ -375,7 +375,7 @@ class Documenter:
|
|||||||
# directives of course)
|
# directives of course)
|
||||||
return '.'.join(self.objpath) or self.modname
|
return '.'.join(self.objpath) or self.modname
|
||||||
|
|
||||||
def format_signature(self, **kwargs) -> str:
|
def format_signature(self, **kwargs: Any) -> str:
|
||||||
"""Format the signature (arguments and return annotation) of the object.
|
"""Format the signature (arguments and return annotation) of the object.
|
||||||
|
|
||||||
Let the user process it via the ``autodoc-process-signature`` event.
|
Let the user process it via the ``autodoc-process-signature`` event.
|
||||||
@ -773,7 +773,7 @@ class ModuleDocumenter(Documenter):
|
|||||||
'imported-members': bool_option, 'ignore-module-all': bool_option
|
'imported-members': bool_option, 'ignore-module-all': bool_option
|
||||||
} # type: Dict[str, Callable]
|
} # type: Dict[str, Callable]
|
||||||
|
|
||||||
def __init__(self, *args) -> None:
|
def __init__(self, *args: Any) -> None:
|
||||||
super().__init__(*args)
|
super().__init__(*args)
|
||||||
merge_special_members_option(self.options)
|
merge_special_members_option(self.options)
|
||||||
|
|
||||||
@ -951,7 +951,7 @@ class DocstringSignatureMixin:
|
|||||||
return lines
|
return lines
|
||||||
return super().get_doc(None, ignore) # type: ignore
|
return super().get_doc(None, ignore) # type: ignore
|
||||||
|
|
||||||
def format_signature(self, **kwargs) -> str:
|
def format_signature(self, **kwargs: Any) -> str:
|
||||||
if self.args is None and self.env.config.autodoc_docstring_signature: # type: ignore
|
if self.args is None and self.env.config.autodoc_docstring_signature: # type: ignore
|
||||||
# only act if a signature is not explicitly given already, and if
|
# only act if a signature is not explicitly given already, and if
|
||||||
# the feature is enabled
|
# the feature is enabled
|
||||||
@ -966,7 +966,7 @@ class DocstringStripSignatureMixin(DocstringSignatureMixin):
|
|||||||
Mixin for AttributeDocumenter to provide the
|
Mixin for AttributeDocumenter to provide the
|
||||||
feature of stripping any function signature from the docstring.
|
feature of stripping any function signature from the docstring.
|
||||||
"""
|
"""
|
||||||
def format_signature(self, **kwargs) -> str:
|
def format_signature(self, **kwargs: Any) -> str:
|
||||||
if self.args is None and self.env.config.autodoc_docstring_signature: # type: ignore
|
if self.args is None and self.env.config.autodoc_docstring_signature: # type: ignore
|
||||||
# only act if a signature is not explicitly given already, and if
|
# only act if a signature is not explicitly given already, and if
|
||||||
# the feature is enabled
|
# the feature is enabled
|
||||||
@ -993,7 +993,7 @@ class FunctionDocumenter(DocstringSignatureMixin, ModuleLevelDocumenter): # typ
|
|||||||
return (inspect.isfunction(member) or inspect.isbuiltin(member) or
|
return (inspect.isfunction(member) or inspect.isbuiltin(member) or
|
||||||
(inspect.isroutine(member) and isinstance(parent, ModuleDocumenter)))
|
(inspect.isroutine(member) and isinstance(parent, ModuleDocumenter)))
|
||||||
|
|
||||||
def format_args(self, **kwargs) -> str:
|
def format_args(self, **kwargs: Any) -> str:
|
||||||
if self.env.config.autodoc_typehints == 'none':
|
if self.env.config.autodoc_typehints == 'none':
|
||||||
kwargs.setdefault('show_annotation', False)
|
kwargs.setdefault('show_annotation', False)
|
||||||
|
|
||||||
@ -1070,7 +1070,7 @@ class ClassDocumenter(DocstringSignatureMixin, ModuleLevelDocumenter): # type:
|
|||||||
'private-members': bool_option, 'special-members': members_option,
|
'private-members': bool_option, 'special-members': members_option,
|
||||||
} # type: Dict[str, Callable]
|
} # type: Dict[str, Callable]
|
||||||
|
|
||||||
def __init__(self, *args) -> None:
|
def __init__(self, *args: Any) -> None:
|
||||||
super().__init__(*args)
|
super().__init__(*args)
|
||||||
merge_special_members_option(self.options)
|
merge_special_members_option(self.options)
|
||||||
|
|
||||||
@ -1090,7 +1090,7 @@ class ClassDocumenter(DocstringSignatureMixin, ModuleLevelDocumenter): # type:
|
|||||||
self.doc_as_attr = True
|
self.doc_as_attr = True
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
def format_args(self, **kwargs) -> str:
|
def format_args(self, **kwargs: Any) -> str:
|
||||||
if self.env.config.autodoc_typehints == 'none':
|
if self.env.config.autodoc_typehints == 'none':
|
||||||
kwargs.setdefault('show_annotation', False)
|
kwargs.setdefault('show_annotation', False)
|
||||||
|
|
||||||
@ -1110,7 +1110,7 @@ class ClassDocumenter(DocstringSignatureMixin, ModuleLevelDocumenter): # type:
|
|||||||
# with __init__ in C
|
# with __init__ in C
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def format_signature(self, **kwargs) -> str:
|
def format_signature(self, **kwargs: Any) -> str:
|
||||||
if self.doc_as_attr:
|
if self.doc_as_attr:
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
@ -1298,7 +1298,7 @@ class MethodDocumenter(DocstringSignatureMixin, ClassLevelDocumenter): # type:
|
|||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
def format_args(self, **kwargs) -> str:
|
def format_args(self, **kwargs: Any) -> str:
|
||||||
if self.env.config.autodoc_typehints == 'none':
|
if self.env.config.autodoc_typehints == 'none':
|
||||||
kwargs.setdefault('show_annotation', False)
|
kwargs.setdefault('show_annotation', False)
|
||||||
|
|
||||||
@ -1313,7 +1313,7 @@ class MethodDocumenter(DocstringSignatureMixin, ClassLevelDocumenter): # type:
|
|||||||
args = args.replace('\\', '\\\\')
|
args = args.replace('\\', '\\\\')
|
||||||
return args
|
return args
|
||||||
|
|
||||||
def add_directive_header(self, sig) -> None:
|
def add_directive_header(self, sig: str) -> None:
|
||||||
super().add_directive_header(sig)
|
super().add_directive_header(sig)
|
||||||
|
|
||||||
sourcename = self.get_sourcename()
|
sourcename = self.get_sourcename()
|
||||||
@ -1515,7 +1515,7 @@ def get_documenters(app: Sphinx) -> Dict[str, "Type[Documenter]"]:
|
|||||||
return app.registry.documenters
|
return app.registry.documenters
|
||||||
|
|
||||||
|
|
||||||
def autodoc_attrgetter(app: Sphinx, obj: Any, name: str, *defargs) -> Any:
|
def autodoc_attrgetter(app: Sphinx, obj: Any, name: str, *defargs: Any) -> Any:
|
||||||
"""Alternative getattr() for types"""
|
"""Alternative getattr() for types"""
|
||||||
for typ, func in app.registry.autodoc_attrgettrs.items():
|
for typ, func in app.registry.autodoc_attrgettrs.items():
|
||||||
if isinstance(obj, typ):
|
if isinstance(obj, typ):
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
Importer utilities for autodoc
|
Importer utilities for autodoc
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
mock for autodoc
|
mock for autodoc
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -26,7 +26,7 @@ class _MockObject:
|
|||||||
|
|
||||||
__display_name__ = '_MockObject'
|
__display_name__ = '_MockObject'
|
||||||
|
|
||||||
def __new__(cls, *args, **kwargs) -> Any:
|
def __new__(cls, *args: Any, **kwargs: Any) -> Any:
|
||||||
if len(args) == 3 and isinstance(args[1], tuple):
|
if len(args) == 3 and isinstance(args[1], tuple):
|
||||||
superclass = args[1][-1].__class__
|
superclass = args[1][-1].__class__
|
||||||
if superclass is cls:
|
if superclass is cls:
|
||||||
@ -36,7 +36,7 @@ class _MockObject:
|
|||||||
|
|
||||||
return super().__new__(cls)
|
return super().__new__(cls)
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs) -> None:
|
def __init__(self, *args: Any, **kwargs: Any) -> None:
|
||||||
self.__qualname__ = ''
|
self.__qualname__ = ''
|
||||||
|
|
||||||
def __len__(self) -> int:
|
def __len__(self) -> int:
|
||||||
@ -57,7 +57,7 @@ class _MockObject:
|
|||||||
def __getattr__(self, key: str) -> "_MockObject":
|
def __getattr__(self, key: str) -> "_MockObject":
|
||||||
return _make_subclass(key, self.__display_name__, self.__class__)()
|
return _make_subclass(key, self.__display_name__, self.__class__)()
|
||||||
|
|
||||||
def __call__(self, *args, **kw) -> Any:
|
def __call__(self, *args: Any, **kw: Any) -> Any:
|
||||||
if args and type(args[0]) in [type, FunctionType, MethodType]:
|
if args and type(args[0]) in [type, FunctionType, MethodType]:
|
||||||
# Appears to be a decorator, pass through unchanged
|
# Appears to be a decorator, pass through unchanged
|
||||||
return args[0]
|
return args[0]
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
Allow reference sections by :ref: role using its title.
|
Allow reference sections by :ref: role using its title.
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@
|
|||||||
resolved to a Python object, and otherwise it becomes simple emphasis.
|
resolved to a Python object, and otherwise it becomes simple emphasis.
|
||||||
This can be used as the default role to make links 'smart'.
|
This can be used as the default role to make links 'smart'.
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
generate:
|
generate:
|
||||||
sphinx-autogen -o source/generated source/*.rst
|
sphinx-autogen -o source/generated source/*.rst
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -62,7 +62,7 @@ class DummyApplication:
|
|||||||
self._warncount = 0
|
self._warncount = 0
|
||||||
self.warningiserror = False
|
self.warningiserror = False
|
||||||
|
|
||||||
def emit_firstresult(self, *args) -> None:
|
def emit_firstresult(self, *args: Any) -> None:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
Check Python modules and C API for coverage. Mostly written by Josip
|
Check Python modules and C API for coverage. Mostly written by Josip
|
||||||
Dzolonga for the Google Highly Open Participation contest.
|
Dzolonga for the Google Highly Open Participation contest.
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -80,7 +80,7 @@ class CoverageBuilder(Builder):
|
|||||||
def get_outdated_docs(self) -> str:
|
def get_outdated_docs(self) -> str:
|
||||||
return 'coverage overview'
|
return 'coverage overview'
|
||||||
|
|
||||||
def write(self, *ignored) -> None:
|
def write(self, *ignored: Any) -> None:
|
||||||
self.py_undoc = {} # type: Dict[str, Dict[str, Any]]
|
self.py_undoc = {} # type: Dict[str, Dict[str, Any]]
|
||||||
self.build_py_coverage()
|
self.build_py_coverage()
|
||||||
self.write_py_coverage()
|
self.write_py_coverage()
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
Mimic doctest by automatically executing code snippets and checking
|
Mimic doctest by automatically executing code snippets and checking
|
||||||
their results.
|
their results.
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
Measure durations of Sphinx processing.
|
Measure durations of Sphinx processing.
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -32,7 +32,7 @@ class DurationDomain(Domain):
|
|||||||
def reading_durations(self) -> Dict[str, timedelta]:
|
def reading_durations(self) -> Dict[str, timedelta]:
|
||||||
return self.data.setdefault('reading_durations', {})
|
return self.data.setdefault('reading_durations', {})
|
||||||
|
|
||||||
def note_reading_duration(self, duration: timedelta):
|
def note_reading_duration(self, duration: timedelta) -> None:
|
||||||
self.reading_durations[self.env.docname] = duration
|
self.reading_durations[self.env.docname] = duration
|
||||||
|
|
||||||
def clear(self) -> None:
|
def clear(self) -> None:
|
||||||
@ -69,7 +69,7 @@ def on_doctree_read(app: Sphinx, doctree: nodes.document) -> None:
|
|||||||
domain.note_reading_duration(duration)
|
domain.note_reading_duration(duration)
|
||||||
|
|
||||||
|
|
||||||
def on_build_finished(app: Sphinx, error):
|
def on_build_finished(app: Sphinx, error: Exception) -> None:
|
||||||
"""Display duration ranking on current build."""
|
"""Display duration ranking on current build."""
|
||||||
domain = cast(DurationDomain, app.env.get_domain('duration'))
|
domain = cast(DurationDomain, app.env.get_domain('duration'))
|
||||||
durations = sorted(domain.reading_durations.items(), key=itemgetter(1), reverse=True)
|
durations = sorted(domain.reading_durations.items(), key=itemgetter(1), reverse=True)
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
You can also give an explicit caption, e.g. :exmpl:`Foo <foo>`.
|
You can also give an explicit caption, e.g. :exmpl:`Foo <foo>`.
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
To publish HTML docs at GitHub Pages, create .nojekyll file.
|
To publish HTML docs at GitHub Pages, create .nojekyll file.
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
Allow graphviz-formatted graphs to be included in Sphinx-generated
|
Allow graphviz-formatted graphs to be included in Sphinx-generated
|
||||||
documents inline.
|
documents inline.
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -121,6 +121,7 @@ class Graphviz(SphinxDirective):
|
|||||||
'layout': directives.unchanged,
|
'layout': directives.unchanged,
|
||||||
'graphviz_dot': directives.unchanged, # an old alias of `layout` option
|
'graphviz_dot': directives.unchanged, # an old alias of `layout` option
|
||||||
'name': directives.unchanged,
|
'name': directives.unchanged,
|
||||||
|
'class': directives.class_option,
|
||||||
}
|
}
|
||||||
|
|
||||||
def run(self) -> List[Node]:
|
def run(self) -> List[Node]:
|
||||||
@ -158,6 +159,8 @@ class Graphviz(SphinxDirective):
|
|||||||
node['alt'] = self.options['alt']
|
node['alt'] = self.options['alt']
|
||||||
if 'align' in self.options:
|
if 'align' in self.options:
|
||||||
node['align'] = self.options['align']
|
node['align'] = self.options['align']
|
||||||
|
if 'class' in self.options:
|
||||||
|
node['classes'] = self.options['class']
|
||||||
|
|
||||||
if 'caption' not in self.options:
|
if 'caption' not in self.options:
|
||||||
self.add_name(node)
|
self.add_name(node)
|
||||||
@ -182,6 +185,7 @@ class GraphvizSimple(SphinxDirective):
|
|||||||
'caption': directives.unchanged,
|
'caption': directives.unchanged,
|
||||||
'graphviz_dot': directives.unchanged,
|
'graphviz_dot': directives.unchanged,
|
||||||
'name': directives.unchanged,
|
'name': directives.unchanged,
|
||||||
|
'class': directives.class_option,
|
||||||
}
|
}
|
||||||
|
|
||||||
def run(self) -> List[Node]:
|
def run(self) -> List[Node]:
|
||||||
@ -195,6 +199,8 @@ class GraphvizSimple(SphinxDirective):
|
|||||||
node['alt'] = self.options['alt']
|
node['alt'] = self.options['alt']
|
||||||
if 'align' in self.options:
|
if 'align' in self.options:
|
||||||
node['align'] = self.options['align']
|
node['align'] = self.options['align']
|
||||||
|
if 'class' in self.options:
|
||||||
|
node['classes'] = self.options['class']
|
||||||
|
|
||||||
if 'caption' not in self.options:
|
if 'caption' not in self.options:
|
||||||
self.add_name(node)
|
self.add_name(node)
|
||||||
@ -267,10 +273,8 @@ def render_dot_html(self: HTMLTranslator, node: graphviz, code: str, options: Di
|
|||||||
logger.warning(__('dot code %r: %s'), code, exc)
|
logger.warning(__('dot code %r: %s'), code, exc)
|
||||||
raise nodes.SkipNode
|
raise nodes.SkipNode
|
||||||
|
|
||||||
if imgcls:
|
classes = [imgcls, 'graphviz'] + node.get('classes', [])
|
||||||
imgcls += " graphviz"
|
imgcls = ' '.join(filter(None, classes))
|
||||||
else:
|
|
||||||
imgcls = "graphviz"
|
|
||||||
|
|
||||||
if fname is None:
|
if fname is None:
|
||||||
self.body.append(self.encode(code))
|
self.body.append(self.encode(code))
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
namespace of the project configuration (that is, all variables from
|
namespace of the project configuration (that is, all variables from
|
||||||
``conf.py`` are available.)
|
``conf.py`` are available.)
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
Image converter extension for Sphinx
|
Image converter extension for Sphinx
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
Render math in HTML via dvipng or dvisvgm.
|
Render math in HTML via dvipng or dvisvgm.
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ r"""
|
|||||||
The graph is inserted as a PNG+image map into HTML and a PDF in
|
The graph is inserted as a PNG+image map into HTML and a PDF in
|
||||||
LaTeX.
|
LaTeX.
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
also be specified individually, e.g. if the docs should be buildable
|
also be specified individually, e.g. if the docs should be buildable
|
||||||
without Internet access.
|
without Internet access.
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
Set up everything for use of JSMath to display math in HTML
|
Set up everything for use of JSMath to display math in HTML
|
||||||
via JavaScript.
|
via JavaScript.
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
Add external links to module code in Python object descriptions.
|
Add external links to module code in Python object descriptions.
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
Sphinx's HTML writer -- requires the MathJax JavaScript library on your
|
Sphinx's HTML writer -- requires the MathJax JavaScript library on your
|
||||||
webserver/computer.
|
webserver/computer.
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
Support for NumPy and Google style docstrings.
|
Support for NumPy and Google style docstrings.
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -265,7 +265,7 @@ class Config:
|
|||||||
'napoleon_custom_sections': (None, 'env')
|
'napoleon_custom_sections': (None, 'env')
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, **settings) -> None:
|
def __init__(self, **settings: Any) -> None:
|
||||||
for name, (default, rebuild) in self._config_values.items():
|
for name, (default, rebuild) in self._config_values.items():
|
||||||
setattr(self, name, default)
|
setattr(self, name, default)
|
||||||
for name, value in settings.items():
|
for name, value in settings.items():
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
Classes for docstring parsing and formatting.
|
Classes for docstring parsing and formatting.
|
||||||
|
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
A collection of helpful iterators.
|
A collection of helpful iterators.
|
||||||
|
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ class peek_iter:
|
|||||||
be set to a new object instance: ``object()``.
|
be set to a new object instance: ``object()``.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
def __init__(self, *args) -> None:
|
def __init__(self, *args: Any) -> None:
|
||||||
"""__init__(o, sentinel=None)"""
|
"""__init__(o, sentinel=None)"""
|
||||||
self._iterable = iter(*args) # type: Iterable
|
self._iterable = iter(*args) # type: Iterable
|
||||||
self._cache = collections.deque() # type: collections.deque
|
self._cache = collections.deque() # type: collections.deque
|
||||||
@ -206,7 +206,7 @@ class modify_iter(peek_iter):
|
|||||||
"whitespace."
|
"whitespace."
|
||||||
|
|
||||||
"""
|
"""
|
||||||
def __init__(self, *args, **kwargs) -> None:
|
def __init__(self, *args: Any, **kwargs: Any) -> None:
|
||||||
"""__init__(o, sentinel=None, modifier=lambda x: x)"""
|
"""__init__(o, sentinel=None, modifier=lambda x: x)"""
|
||||||
if 'modifier' in kwargs:
|
if 'modifier' in kwargs:
|
||||||
self.modifier = kwargs['modifier']
|
self.modifier = kwargs['modifier']
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
all todos of your project and lists them along with a backlink to the
|
all todos of your project and lists them along with a backlink to the
|
||||||
original location.
|
original location.
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
Add links to module code in Python object descriptions.
|
Add links to module code in Python object descriptions.
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
Utilities for Sphinx extensions.
|
Utilities for Sphinx extensions.
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -23,7 +23,7 @@ logger = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
class Extension:
|
class Extension:
|
||||||
def __init__(self, name: str, module: Any, **kwargs) -> None:
|
def __init__(self, name: str, module: Any, **kwargs: Any) -> None:
|
||||||
self.name = name
|
self.name = name
|
||||||
self.module = module
|
self.module = module
|
||||||
self.metadata = kwargs
|
self.metadata = kwargs
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
Highlight code blocks using Pygments.
|
Highlight code blocks using Pygments.
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -84,7 +84,7 @@ class PygmentsBridge:
|
|||||||
else:
|
else:
|
||||||
return get_style_by_name(stylename)
|
return get_style_by_name(stylename)
|
||||||
|
|
||||||
def get_formatter(self, **kwargs) -> Formatter:
|
def get_formatter(self, **kwargs: Any) -> Formatter:
|
||||||
kwargs.update(self.formatter_args)
|
kwargs.update(self.formatter_args)
|
||||||
return self.formatter(**kwargs)
|
return self.formatter(**kwargs)
|
||||||
|
|
||||||
@ -133,7 +133,7 @@ class PygmentsBridge:
|
|||||||
return lexer
|
return lexer
|
||||||
|
|
||||||
def highlight_block(self, source: str, lang: str, opts: Dict = None,
|
def highlight_block(self, source: str, lang: str, opts: Dict = None,
|
||||||
force: bool = False, location: Any = None, **kwargs) -> str:
|
force: bool = False, location: Any = None, **kwargs: Any) -> str:
|
||||||
if not isinstance(source, str):
|
if not isinstance(source, str):
|
||||||
source = source.decode()
|
source = source.decode()
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
Input/Output files
|
Input/Output files
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
import codecs
|
import codecs
|
||||||
@ -55,7 +55,7 @@ class SphinxBaseReader(standalone.Reader):
|
|||||||
|
|
||||||
transforms = [] # type: List[Type[Transform]]
|
transforms = [] # type: List[Type[Transform]]
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs) -> None:
|
def __init__(self, *args: Any, **kwargs: Any) -> None:
|
||||||
from sphinx.application import Sphinx
|
from sphinx.application import Sphinx
|
||||||
if len(args) > 0 and isinstance(args[0], Sphinx):
|
if len(args) > 0 and isinstance(args[0], Sphinx):
|
||||||
self._app = args[0]
|
self._app = args[0]
|
||||||
@ -166,14 +166,14 @@ class SphinxDummyWriter(UnfilteredWriter):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def SphinxDummySourceClass(source: Any, *args, **kwargs) -> Any:
|
def SphinxDummySourceClass(source: Any, *args: Any, **kwargs: Any) -> Any:
|
||||||
"""Bypass source object as is to cheat Publisher."""
|
"""Bypass source object as is to cheat Publisher."""
|
||||||
return source
|
return source
|
||||||
|
|
||||||
|
|
||||||
class SphinxFileInput(FileInput):
|
class SphinxFileInput(FileInput):
|
||||||
"""A basic FileInput for Sphinx."""
|
"""A basic FileInput for Sphinx."""
|
||||||
def __init__(self, *args, **kwargs) -> None:
|
def __init__(self, *args: Any, **kwargs: Any) -> None:
|
||||||
kwargs['error_handler'] = 'sphinx'
|
kwargs['error_handler'] = 'sphinx'
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
Glue code for the jinja2 templating engine.
|
Glue code for the jinja2 templating engine.
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -103,7 +103,7 @@ class idgen:
|
|||||||
|
|
||||||
|
|
||||||
@contextfunction
|
@contextfunction
|
||||||
def warning(context: Dict, message: str, *args, **kwargs) -> str:
|
def warning(context: Dict, message: str, *args: Any, **kwargs: Any) -> str:
|
||||||
if 'pagename' in context:
|
if 'pagename' in context:
|
||||||
filename = context.get('pagename') + context.get('file_suffix', '')
|
filename = context.get('pagename') + context.get('file_suffix', '')
|
||||||
message = 'in rendering %s: %s' % (filename, message)
|
message = 'in rendering %s: %s' % (filename, message)
|
||||||
|
@ -222,7 +222,7 @@ def get_translation(catalog, namespace='general'):
|
|||||||
|
|
||||||
.. versionadded:: 1.8
|
.. versionadded:: 1.8
|
||||||
"""
|
"""
|
||||||
def gettext(message: str, *args) -> str:
|
def gettext(message: str, *args: Any) -> str:
|
||||||
if not is_translator_registered(catalog, namespace):
|
if not is_translator_registered(catalog, namespace):
|
||||||
# not initialized yet
|
# not initialized yet
|
||||||
return _TranslationProxy(_lazy_translate, catalog, namespace, message) # type: ignore # NOQA
|
return _TranslationProxy(_lazy_translate, catalog, namespace, message) # type: ignore # NOQA
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
A Base class for additional parsers.
|
A Base class for additional parsers.
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
Utility function and classes for Sphinx projects.
|
Utility function and classes for Sphinx projects.
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -4,25 +4,76 @@
|
|||||||
|
|
||||||
Utilities parsing and analyzing Python code.
|
Utilities parsing and analyzing Python code.
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
import tokenize
|
||||||
|
import warnings
|
||||||
|
from importlib import import_module
|
||||||
from io import StringIO
|
from io import StringIO
|
||||||
from os import path
|
from os import path
|
||||||
from typing import Any, Dict, IO, List, Tuple
|
from typing import Any, Dict, IO, List, Tuple, Optional
|
||||||
from zipfile import ZipFile
|
from zipfile import ZipFile
|
||||||
|
|
||||||
|
from sphinx.deprecation import RemovedInSphinx40Warning
|
||||||
from sphinx.errors import PycodeError
|
from sphinx.errors import PycodeError
|
||||||
from sphinx.pycode.parser import Parser
|
from sphinx.pycode.parser import Parser
|
||||||
from sphinx.util import get_module_source, detect_encoding
|
|
||||||
|
|
||||||
|
|
||||||
class ModuleAnalyzer:
|
class ModuleAnalyzer:
|
||||||
# cache for analyzer objects -- caches both by module and file name
|
# cache for analyzer objects -- caches both by module and file name
|
||||||
cache = {} # type: Dict[Tuple[str, str], Any]
|
cache = {} # type: Dict[Tuple[str, str], Any]
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_module_source(modname: str) -> Tuple[Optional[str], Optional[str]]:
|
||||||
|
"""Try to find the source code for a module.
|
||||||
|
|
||||||
|
Returns ('filename', 'source'). One of it can be None if
|
||||||
|
no filename or source found
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
mod = import_module(modname)
|
||||||
|
except Exception as err:
|
||||||
|
raise PycodeError('error importing %r' % modname, err)
|
||||||
|
loader = getattr(mod, '__loader__', None)
|
||||||
|
filename = getattr(mod, '__file__', None)
|
||||||
|
if loader and getattr(loader, 'get_source', None):
|
||||||
|
# prefer Native loader, as it respects #coding directive
|
||||||
|
try:
|
||||||
|
source = loader.get_source(modname)
|
||||||
|
if source:
|
||||||
|
# no exception and not None - it must be module source
|
||||||
|
return filename, source
|
||||||
|
except ImportError:
|
||||||
|
pass # Try other "source-mining" methods
|
||||||
|
if filename is None and loader and getattr(loader, 'get_filename', None):
|
||||||
|
# have loader, but no filename
|
||||||
|
try:
|
||||||
|
filename = loader.get_filename(modname)
|
||||||
|
except ImportError as err:
|
||||||
|
raise PycodeError('error getting filename for %r' % modname, err)
|
||||||
|
if filename is None:
|
||||||
|
# all methods for getting filename failed, so raise...
|
||||||
|
raise PycodeError('no source found for module %r' % modname)
|
||||||
|
filename = path.normpath(path.abspath(filename))
|
||||||
|
if filename.lower().endswith(('.pyo', '.pyc')):
|
||||||
|
filename = filename[:-1]
|
||||||
|
if not path.isfile(filename) and path.isfile(filename + 'w'):
|
||||||
|
filename += 'w'
|
||||||
|
elif not filename.lower().endswith(('.py', '.pyw')):
|
||||||
|
raise PycodeError('source is not a .py file: %r' % filename)
|
||||||
|
elif ('.egg' + path.sep) in filename:
|
||||||
|
pat = '(?<=\\.egg)' + re.escape(path.sep)
|
||||||
|
eggpath, _ = re.split(pat, filename, 1)
|
||||||
|
if path.isfile(eggpath):
|
||||||
|
return filename, None
|
||||||
|
|
||||||
|
if not path.isfile(filename):
|
||||||
|
raise PycodeError('source file is not present: %r' % filename)
|
||||||
|
return filename, None
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def for_string(cls, string: str, modname: str, srcname: str = '<string>'
|
def for_string(cls, string: str, modname: str, srcname: str = '<string>'
|
||||||
) -> "ModuleAnalyzer":
|
) -> "ModuleAnalyzer":
|
||||||
@ -33,8 +84,8 @@ class ModuleAnalyzer:
|
|||||||
if ('file', filename) in cls.cache:
|
if ('file', filename) in cls.cache:
|
||||||
return cls.cache['file', filename]
|
return cls.cache['file', filename]
|
||||||
try:
|
try:
|
||||||
with open(filename, 'rb') as f:
|
with tokenize.open(filename) as f:
|
||||||
obj = cls(f, modname, filename)
|
obj = cls(f, modname, filename, decoded=True)
|
||||||
cls.cache['file', filename] = obj
|
cls.cache['file', filename] = obj
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
if '.egg' + path.sep in filename:
|
if '.egg' + path.sep in filename:
|
||||||
@ -63,11 +114,11 @@ class ModuleAnalyzer:
|
|||||||
return entry
|
return entry
|
||||||
|
|
||||||
try:
|
try:
|
||||||
type, source = get_module_source(modname)
|
filename, source = cls.get_module_source(modname)
|
||||||
if type == 'string':
|
if source is not None:
|
||||||
obj = cls.for_string(source, modname)
|
obj = cls.for_string(source, modname, filename or '<string>')
|
||||||
else:
|
elif filename is not None:
|
||||||
obj = cls.for_file(source, modname)
|
obj = cls.for_file(filename, modname)
|
||||||
except PycodeError as err:
|
except PycodeError as err:
|
||||||
cls.cache['module', modname] = err
|
cls.cache['module', modname] = err
|
||||||
raise
|
raise
|
||||||
@ -81,11 +132,13 @@ class ModuleAnalyzer:
|
|||||||
# cache the source code as well
|
# cache the source code as well
|
||||||
pos = source.tell()
|
pos = source.tell()
|
||||||
if not decoded:
|
if not decoded:
|
||||||
self.encoding = detect_encoding(source.readline)
|
warnings.warn('decode option for ModuleAnalyzer is deprecated.',
|
||||||
|
RemovedInSphinx40Warning)
|
||||||
|
self._encoding, _ = tokenize.detect_encoding(source.readline)
|
||||||
source.seek(pos)
|
source.seek(pos)
|
||||||
self.code = source.read().decode(self.encoding)
|
self.code = source.read().decode(self._encoding)
|
||||||
else:
|
else:
|
||||||
self.encoding = None
|
self._encoding = None
|
||||||
self.code = source.read()
|
self.code = source.read()
|
||||||
|
|
||||||
# will be filled by parse()
|
# will be filled by parse()
|
||||||
@ -96,7 +149,7 @@ class ModuleAnalyzer:
|
|||||||
def parse(self) -> None:
|
def parse(self) -> None:
|
||||||
"""Parse the source code."""
|
"""Parse the source code."""
|
||||||
try:
|
try:
|
||||||
parser = Parser(self.code, self.encoding)
|
parser = Parser(self.code, self._encoding)
|
||||||
parser.parse()
|
parser.parse()
|
||||||
|
|
||||||
self.attr_docs = {}
|
self.attr_docs = {}
|
||||||
@ -124,3 +177,9 @@ class ModuleAnalyzer:
|
|||||||
self.parse()
|
self.parse()
|
||||||
|
|
||||||
return self.tags
|
return self.tags
|
||||||
|
|
||||||
|
@property
|
||||||
|
def encoding(self) -> str:
|
||||||
|
warnings.warn('ModuleAnalyzer.encoding is deprecated.',
|
||||||
|
RemovedInSphinx40Warning)
|
||||||
|
return self._encoding
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
Utilities parsing and analyzing Python code.
|
Utilities parsing and analyzing Python code.
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
import ast
|
import ast
|
||||||
@ -117,7 +117,7 @@ class Token:
|
|||||||
else:
|
else:
|
||||||
raise ValueError('Unknown value: %r' % other)
|
raise ValueError('Unknown value: %r' % other)
|
||||||
|
|
||||||
def match(self, *conditions) -> bool:
|
def match(self, *conditions: Any) -> bool:
|
||||||
return any(self == candidate for candidate in conditions)
|
return any(self == candidate for candidate in conditions)
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
Sphinx theme specific highlighting styles.
|
Sphinx theme specific highlighting styles.
|
||||||
|
|
||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -257,7 +257,7 @@ class SphinxComponentRegistry:
|
|||||||
else:
|
else:
|
||||||
self.source_suffix[suffix] = filetype
|
self.source_suffix[suffix] = filetype
|
||||||
|
|
||||||
def add_source_parser(self, parser: "Type[Parser]", **kwargs) -> None:
|
def add_source_parser(self, parser: "Type[Parser]", **kwargs: Any) -> None:
|
||||||
logger.debug('[app] adding search source_parser: %r', parser)
|
logger.debug('[app] adding search source_parser: %r', parser)
|
||||||
|
|
||||||
# create a map from filetype to parser
|
# create a map from filetype to parser
|
||||||
@ -301,7 +301,8 @@ class SphinxComponentRegistry:
|
|||||||
raise ExtensionError(__('Translator for %r already exists') % name)
|
raise ExtensionError(__('Translator for %r already exists') % name)
|
||||||
self.translators[name] = translator
|
self.translators[name] = translator
|
||||||
|
|
||||||
def add_translation_handlers(self, node: "Type[Element]", **kwargs) -> None:
|
def add_translation_handlers(self, node: "Type[Element]",
|
||||||
|
**kwargs: Tuple[Callable, Callable]) -> None:
|
||||||
logger.debug('[app] adding translation_handlers: %r, %r', node, kwargs)
|
logger.debug('[app] adding translation_handlers: %r, %r', node, kwargs)
|
||||||
for builder_name, handlers in kwargs.items():
|
for builder_name, handlers in kwargs.items():
|
||||||
translation_handlers = self.translation_handlers.setdefault(builder_name, {})
|
translation_handlers = self.translation_handlers.setdefault(builder_name, {})
|
||||||
@ -310,13 +311,13 @@ class SphinxComponentRegistry:
|
|||||||
translation_handlers[node.__name__] = (visit, depart)
|
translation_handlers[node.__name__] = (visit, depart)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
raise ExtensionError(__('kwargs for add_node() must be a (visit, depart) '
|
raise ExtensionError(__('kwargs for add_node() must be a (visit, depart) '
|
||||||
'function tuple: %r=%r') % builder_name, handlers)
|
'function tuple: %r=%r') % (builder_name, handlers))
|
||||||
|
|
||||||
def get_translator_class(self, builder: Builder) -> "Type[nodes.NodeVisitor]":
|
def get_translator_class(self, builder: Builder) -> "Type[nodes.NodeVisitor]":
|
||||||
return self.translators.get(builder.name,
|
return self.translators.get(builder.name,
|
||||||
builder.default_translator_class)
|
builder.default_translator_class)
|
||||||
|
|
||||||
def create_translator(self, builder: Builder, *args) -> nodes.NodeVisitor:
|
def create_translator(self, builder: Builder, *args: Any) -> nodes.NodeVisitor:
|
||||||
translator_class = self.get_translator_class(builder)
|
translator_class = self.get_translator_class(builder)
|
||||||
assert translator_class, "translator not found for %s" % builder.name
|
assert translator_class, "translator not found for %s" % builder.name
|
||||||
translator = translator_class(*args)
|
translator = translator_class(*args)
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user