Sphinx 7.1.2__py3-none-any.whl → 7.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of Sphinx might be problematic. Click here for more details.
- sphinx/__init__.py +6 -6
- sphinx/__main__.py +3 -1
- sphinx/addnodes.py +35 -22
- sphinx/application.py +40 -38
- sphinx/builders/__init__.py +16 -12
- sphinx/builders/_epub_base.py +15 -11
- sphinx/builders/changes.py +6 -4
- sphinx/builders/dirhtml.py +4 -2
- sphinx/builders/dummy.py +6 -4
- sphinx/builders/epub3.py +16 -8
- sphinx/builders/gettext.py +40 -43
- sphinx/builders/html/__init__.py +166 -196
- sphinx/builders/html/_assets.py +116 -0
- sphinx/builders/html/transforms.py +4 -2
- sphinx/builders/latex/__init__.py +12 -7
- sphinx/builders/latex/theming.py +5 -2
- sphinx/builders/latex/transforms.py +6 -3
- sphinx/builders/linkcheck.py +18 -11
- sphinx/builders/manpage.py +6 -4
- sphinx/builders/singlehtml.py +16 -9
- sphinx/builders/texinfo.py +11 -6
- sphinx/builders/text.py +8 -3
- sphinx/builders/xml.py +9 -4
- sphinx/cmd/build.py +27 -14
- sphinx/cmd/make_mode.py +13 -4
- sphinx/cmd/quickstart.py +13 -4
- sphinx/config.py +17 -14
- sphinx/deprecation.py +4 -2
- sphinx/directives/__init__.py +44 -12
- sphinx/directives/code.py +5 -4
- sphinx/directives/other.py +92 -44
- sphinx/directives/patches.py +1 -1
- sphinx/domains/__init__.py +11 -8
- sphinx/domains/c.py +67 -57
- sphinx/domains/changeset.py +3 -2
- sphinx/domains/citation.py +2 -1
- sphinx/domains/cpp.py +136 -93
- sphinx/domains/index.py +9 -5
- sphinx/domains/javascript.py +32 -19
- sphinx/domains/math.py +5 -3
- sphinx/domains/python.py +69 -57
- sphinx/domains/rst.py +20 -11
- sphinx/domains/std.py +21 -15
- sphinx/environment/__init__.py +97 -65
- sphinx/environment/adapters/indexentries.py +13 -10
- sphinx/environment/adapters/toctree.py +485 -308
- sphinx/environment/collectors/__init__.py +3 -4
- sphinx/environment/collectors/asset.py +10 -4
- sphinx/environment/collectors/dependencies.py +7 -4
- sphinx/environment/collectors/metadata.py +7 -5
- sphinx/environment/collectors/title.py +5 -3
- sphinx/environment/collectors/toctree.py +13 -8
- sphinx/errors.py +1 -1
- sphinx/events.py +5 -5
- sphinx/ext/apidoc.py +49 -27
- sphinx/ext/autodoc/__init__.py +179 -161
- sphinx/ext/autodoc/directive.py +10 -6
- sphinx/ext/autodoc/importer.py +22 -13
- sphinx/ext/autodoc/mock.py +4 -1
- sphinx/ext/autodoc/preserve_defaults.py +80 -12
- sphinx/ext/autodoc/type_comment.py +14 -10
- sphinx/ext/autodoc/typehints.py +7 -3
- sphinx/ext/autosectionlabel.py +6 -3
- sphinx/ext/autosummary/__init__.py +21 -15
- sphinx/ext/autosummary/generate.py +176 -126
- sphinx/ext/coverage.py +93 -8
- sphinx/ext/doctest.py +28 -17
- sphinx/ext/duration.py +19 -17
- sphinx/ext/extlinks.py +11 -6
- sphinx/ext/githubpages.py +8 -7
- sphinx/ext/graphviz.py +61 -17
- sphinx/ext/ifconfig.py +7 -4
- sphinx/ext/imgconverter.py +4 -2
- sphinx/ext/imgmath.py +29 -23
- sphinx/ext/inheritance_diagram.py +41 -27
- sphinx/ext/intersphinx.py +45 -38
- sphinx/ext/linkcode.py +8 -5
- sphinx/ext/mathjax.py +13 -9
- sphinx/ext/napoleon/__init__.py +3 -3
- sphinx/ext/napoleon/docstring.py +40 -31
- sphinx/ext/todo.py +10 -7
- sphinx/ext/viewcode.py +46 -25
- sphinx/extension.py +1 -1
- sphinx/highlighting.py +20 -12
- sphinx/io.py +5 -4
- sphinx/jinja2glue.py +24 -19
- sphinx/locale/__init__.py +8 -2
- sphinx/locale/ar/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/ar/LC_MESSAGES/sphinx.po +756 -740
- sphinx/locale/bg/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/bg/LC_MESSAGES/sphinx.po +754 -738
- sphinx/locale/bn/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/bn/LC_MESSAGES/sphinx.po +755 -739
- sphinx/locale/ca/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/ca/LC_MESSAGES/sphinx.po +768 -752
- sphinx/locale/cak/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/cak/LC_MESSAGES/sphinx.po +754 -738
- sphinx/locale/cs/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/cs/LC_MESSAGES/sphinx.po +758 -742
- sphinx/locale/cy/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/cy/LC_MESSAGES/sphinx.po +759 -743
- sphinx/locale/da/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/da/LC_MESSAGES/sphinx.po +760 -744
- sphinx/locale/de/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/de/LC_MESSAGES/sphinx.po +759 -743
- sphinx/locale/de_DE/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/de_DE/LC_MESSAGES/sphinx.po +754 -738
- sphinx/locale/el/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/el/LC_MESSAGES/sphinx.po +763 -747
- sphinx/locale/en_DE/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/en_DE/LC_MESSAGES/sphinx.po +754 -738
- sphinx/locale/en_FR/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/en_FR/LC_MESSAGES/sphinx.po +754 -738
- sphinx/locale/en_GB/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/en_GB/LC_MESSAGES/sphinx.po +768 -752
- sphinx/locale/en_HK/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/en_HK/LC_MESSAGES/sphinx.po +754 -738
- sphinx/locale/eo/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/eo/LC_MESSAGES/sphinx.po +754 -738
- sphinx/locale/es/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/es/LC_MESSAGES/sphinx.po +767 -751
- sphinx/locale/es_CO/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/es_CO/LC_MESSAGES/sphinx.po +754 -738
- sphinx/locale/et/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/et/LC_MESSAGES/sphinx.po +762 -746
- sphinx/locale/eu/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/eu/LC_MESSAGES/sphinx.po +755 -739
- sphinx/locale/fa/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/fa/LC_MESSAGES/sphinx.po +766 -750
- sphinx/locale/fi/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/fi/LC_MESSAGES/sphinx.po +754 -738
- sphinx/locale/fr/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/fr/LC_MESSAGES/sphinx.po +768 -752
- sphinx/locale/fr_FR/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/fr_FR/LC_MESSAGES/sphinx.po +754 -738
- sphinx/locale/gl/LC_MESSAGES/sphinx.js +60 -0
- sphinx/locale/gl/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/gl/LC_MESSAGES/sphinx.po +3695 -0
- sphinx/locale/he/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/he/LC_MESSAGES/sphinx.po +755 -739
- sphinx/locale/hi/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/hi/LC_MESSAGES/sphinx.po +763 -747
- sphinx/locale/hi_IN/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/hi_IN/LC_MESSAGES/sphinx.po +754 -738
- sphinx/locale/hr/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/hr/LC_MESSAGES/sphinx.po +760 -744
- sphinx/locale/hu/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/hu/LC_MESSAGES/sphinx.po +759 -743
- sphinx/locale/id/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/id/LC_MESSAGES/sphinx.po +765 -749
- sphinx/locale/is/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/is/LC_MESSAGES/sphinx.po +760 -744
- sphinx/locale/it/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/it/LC_MESSAGES/sphinx.po +760 -744
- sphinx/locale/ja/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/ja/LC_MESSAGES/sphinx.po +767 -751
- sphinx/locale/ka/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/ka/LC_MESSAGES/sphinx.po +759 -743
- sphinx/locale/ko/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/ko/LC_MESSAGES/sphinx.po +767 -751
- sphinx/locale/lt/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/lt/LC_MESSAGES/sphinx.po +755 -739
- sphinx/locale/lv/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/lv/LC_MESSAGES/sphinx.po +755 -739
- sphinx/locale/mk/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/mk/LC_MESSAGES/sphinx.po +754 -738
- sphinx/locale/nb_NO/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/nb_NO/LC_MESSAGES/sphinx.po +755 -739
- sphinx/locale/ne/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/ne/LC_MESSAGES/sphinx.po +755 -739
- sphinx/locale/nl/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/nl/LC_MESSAGES/sphinx.po +760 -744
- sphinx/locale/pl/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/pl/LC_MESSAGES/sphinx.po +762 -745
- sphinx/locale/pt/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/pt/LC_MESSAGES/sphinx.po +754 -738
- sphinx/locale/pt_BR/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/pt_BR/LC_MESSAGES/sphinx.po +768 -752
- sphinx/locale/pt_PT/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/pt_PT/LC_MESSAGES/sphinx.po +755 -739
- sphinx/locale/ro/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/ro/LC_MESSAGES/sphinx.po +759 -743
- sphinx/locale/ru/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/ru/LC_MESSAGES/sphinx.po +760 -744
- sphinx/locale/si/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/si/LC_MESSAGES/sphinx.po +754 -738
- sphinx/locale/sk/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/sk/LC_MESSAGES/sphinx.po +765 -749
- sphinx/locale/sl/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/sl/LC_MESSAGES/sphinx.po +755 -739
- sphinx/locale/sphinx.pot +748 -740
- sphinx/locale/sq/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/sq/LC_MESSAGES/sphinx.po +768 -752
- sphinx/locale/sr/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/sr/LC_MESSAGES/sphinx.po +754 -738
- sphinx/locale/sr@latin/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/sr@latin/LC_MESSAGES/sphinx.po +754 -738
- sphinx/locale/sr_RS/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/sr_RS/LC_MESSAGES/sphinx.po +754 -738
- sphinx/locale/sv/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/sv/LC_MESSAGES/sphinx.po +755 -739
- sphinx/locale/ta/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/ta/LC_MESSAGES/sphinx.po +754 -738
- sphinx/locale/te/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/te/LC_MESSAGES/sphinx.po +754 -738
- sphinx/locale/tr/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/tr/LC_MESSAGES/sphinx.po +763 -747
- sphinx/locale/uk_UA/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/uk_UA/LC_MESSAGES/sphinx.po +760 -749
- sphinx/locale/ur/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/ur/LC_MESSAGES/sphinx.po +759 -748
- sphinx/locale/vi/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/vi/LC_MESSAGES/sphinx.po +754 -738
- sphinx/locale/yue/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/yue/LC_MESSAGES/sphinx.po +754 -738
- sphinx/locale/zh_CN/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/zh_CN/LC_MESSAGES/sphinx.po +768 -752
- sphinx/locale/zh_HK/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/zh_HK/LC_MESSAGES/sphinx.po +754 -738
- sphinx/locale/zh_TW/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/zh_TW/LC_MESSAGES/sphinx.po +767 -751
- sphinx/locale/zh_TW.Big5/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/zh_TW.Big5/LC_MESSAGES/sphinx.po +754 -738
- sphinx/parsers.py +5 -4
- sphinx/project.py +52 -34
- sphinx/pycode/__init__.py +2 -1
- sphinx/pycode/ast.py +7 -13
- sphinx/pycode/parser.py +42 -38
- sphinx/registry.py +35 -29
- sphinx/roles.py +9 -4
- sphinx/search/__init__.py +5 -17
- sphinx/search/da.py +1 -1
- sphinx/search/de.py +1 -1
- sphinx/search/en.py +1 -1
- sphinx/search/es.py +1 -1
- sphinx/search/fi.py +1 -1
- sphinx/search/fr.py +1 -1
- sphinx/search/hu.py +1 -1
- sphinx/search/it.py +1 -1
- sphinx/search/ja.py +1 -1
- sphinx/search/nl.py +1 -1
- sphinx/search/no.py +1 -1
- sphinx/search/pt.py +1 -1
- sphinx/search/ro.py +1 -1
- sphinx/search/ru.py +1 -1
- sphinx/search/sv.py +1 -1
- sphinx/search/tr.py +1 -1
- sphinx/search/zh.py +1 -1
- sphinx/testing/fixtures.py +23 -30
- sphinx/testing/path.py +9 -0
- sphinx/testing/restructuredtext.py +13 -5
- sphinx/testing/util.py +20 -63
- sphinx/texinputs/sphinxlatexobjects.sty +15 -15
- sphinx/themes/agogo/static/agogo.css_t +10 -4
- sphinx/themes/basic/layout.html +1 -1
- sphinx/themes/basic/static/basic.css_t +4 -0
- sphinx/themes/basic/static/documentation_options.js_t +1 -2
- sphinx/themes/basic/static/searchtools.js +17 -9
- sphinx/themes/basic/static/sphinx_highlight.js +13 -3
- sphinx/themes/bizstyle/static/bizstyle.css_t +4 -0
- sphinx/themes/classic/theme.conf +1 -1
- sphinx/themes/epub/static/epub.css_t +6 -1
- sphinx/themes/haiku/theme.conf +1 -1
- sphinx/themes/nature/static/nature.css_t +4 -0
- sphinx/themes/nonav/static/nonav.css_t +6 -1
- sphinx/themes/pyramid/static/pyramid.css_t +4 -0
- sphinx/themes/scrolls/static/scrolls.css_t +4 -0
- sphinx/themes/scrolls/theme.conf +1 -1
- sphinx/themes/sphinxdoc/static/sphinxdoc.css_t +4 -0
- sphinx/theming.py +9 -7
- sphinx/transforms/__init__.py +79 -3
- sphinx/transforms/compact_bullet_list.py +6 -3
- sphinx/transforms/i18n.py +26 -10
- sphinx/transforms/post_transforms/__init__.py +21 -8
- sphinx/transforms/post_transforms/code.py +6 -3
- sphinx/transforms/post_transforms/images.py +13 -9
- sphinx/util/__init__.py +21 -92
- sphinx/util/cfamily.py +7 -4
- sphinx/util/display.py +3 -2
- sphinx/util/docfields.py +7 -6
- sphinx/util/docstrings.py +1 -1
- sphinx/util/docutils.py +41 -31
- sphinx/util/fileutil.py +9 -6
- sphinx/util/i18n.py +21 -18
- sphinx/util/images.py +2 -1
- sphinx/util/index_entries.py +27 -0
- sphinx/util/inspect.py +83 -67
- sphinx/util/inventory.py +4 -2
- sphinx/util/logging.py +9 -6
- sphinx/util/matching.py +5 -2
- sphinx/util/math.py +6 -3
- sphinx/util/nodes.py +70 -31
- sphinx/util/osutil.py +22 -40
- sphinx/util/parallel.py +4 -1
- sphinx/util/rst.py +7 -3
- sphinx/util/tags.py +11 -4
- sphinx/util/template.py +17 -14
- sphinx/util/typing.py +61 -20
- sphinx/versioning.py +6 -4
- sphinx/writers/html.py +1 -1
- sphinx/writers/html5.py +32 -24
- sphinx/writers/latex.py +67 -53
- sphinx/writers/manpage.py +9 -5
- sphinx/writers/texinfo.py +11 -9
- sphinx/writers/text.py +14 -9
- sphinx/writers/xml.py +3 -2
- {sphinx-7.1.2.dist-info → sphinx-7.2.0.dist-info}/METADATA +7 -5
- sphinx-7.2.0.dist-info/RECORD +568 -0
- sphinx/testing/comparer.py +0 -97
- sphinx-7.1.2.dist-info/RECORD +0 -564
- {sphinx-7.1.2.dist-info → sphinx-7.2.0.dist-info}/LICENSE +0 -0
- {sphinx-7.1.2.dist-info → sphinx-7.2.0.dist-info}/WHEEL +0 -0
- {sphinx-7.1.2.dist-info → sphinx-7.2.0.dist-info}/entry_points.txt +0 -0
sphinx/domains/index.py
CHANGED
|
@@ -2,22 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
-
from typing import TYPE_CHECKING, Any
|
|
5
|
+
from typing import TYPE_CHECKING, Any
|
|
6
6
|
|
|
7
7
|
from docutils import nodes
|
|
8
|
-
from docutils.nodes import Node, system_message
|
|
9
8
|
from docutils.parsers.rst import directives
|
|
10
9
|
|
|
11
10
|
from sphinx import addnodes
|
|
12
11
|
from sphinx.domains import Domain
|
|
13
|
-
from sphinx.
|
|
14
|
-
from sphinx.util import logging, split_index_msg
|
|
12
|
+
from sphinx.util import logging
|
|
15
13
|
from sphinx.util.docutils import ReferenceRole, SphinxDirective
|
|
14
|
+
from sphinx.util.index_entries import split_index_msg
|
|
16
15
|
from sphinx.util.nodes import process_index_entry
|
|
17
|
-
from sphinx.util.typing import OptionSpec
|
|
18
16
|
|
|
19
17
|
if TYPE_CHECKING:
|
|
18
|
+
from collections.abc import Iterable
|
|
19
|
+
|
|
20
|
+
from docutils.nodes import Node, system_message
|
|
21
|
+
|
|
20
22
|
from sphinx.application import Sphinx
|
|
23
|
+
from sphinx.environment import BuildEnvironment
|
|
24
|
+
from sphinx.util.typing import OptionSpec
|
|
21
25
|
|
|
22
26
|
|
|
23
27
|
logger = logging.getLogger(__name__)
|
sphinx/domains/javascript.py
CHANGED
|
@@ -2,32 +2,38 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
import contextlib
|
|
6
|
+
from typing import TYPE_CHECKING, Any, cast
|
|
6
7
|
|
|
7
8
|
from docutils import nodes
|
|
8
|
-
from docutils.nodes import Element, Node
|
|
9
9
|
from docutils.parsers.rst import directives
|
|
10
10
|
|
|
11
11
|
from sphinx import addnodes
|
|
12
|
-
from sphinx.addnodes import desc_signature, pending_xref
|
|
13
|
-
from sphinx.application import Sphinx
|
|
14
|
-
from sphinx.builders import Builder
|
|
15
12
|
from sphinx.directives import ObjectDescription
|
|
16
13
|
from sphinx.domains import Domain, ObjType
|
|
17
14
|
from sphinx.domains.python import _pseudo_parse_arglist
|
|
18
|
-
from sphinx.environment import BuildEnvironment
|
|
19
15
|
from sphinx.locale import _, __
|
|
20
16
|
from sphinx.roles import XRefRole
|
|
21
17
|
from sphinx.util import logging
|
|
22
18
|
from sphinx.util.docfields import Field, GroupedField, TypedField
|
|
23
19
|
from sphinx.util.docutils import SphinxDirective
|
|
24
20
|
from sphinx.util.nodes import make_id, make_refnode, nested_parse_with_titles
|
|
25
|
-
|
|
21
|
+
|
|
22
|
+
if TYPE_CHECKING:
|
|
23
|
+
from collections.abc import Iterator
|
|
24
|
+
|
|
25
|
+
from docutils.nodes import Element, Node
|
|
26
|
+
|
|
27
|
+
from sphinx.addnodes import desc_signature, pending_xref
|
|
28
|
+
from sphinx.application import Sphinx
|
|
29
|
+
from sphinx.builders import Builder
|
|
30
|
+
from sphinx.environment import BuildEnvironment
|
|
31
|
+
from sphinx.util.typing import OptionSpec
|
|
26
32
|
|
|
27
33
|
logger = logging.getLogger(__name__)
|
|
28
34
|
|
|
29
35
|
|
|
30
|
-
class JSObject(ObjectDescription[
|
|
36
|
+
class JSObject(ObjectDescription[tuple[str, str]]):
|
|
31
37
|
"""
|
|
32
38
|
Description of a JavaScript object.
|
|
33
39
|
"""
|
|
@@ -40,6 +46,10 @@ class JSObject(ObjectDescription[Tuple[str, str]]):
|
|
|
40
46
|
allow_nesting = False
|
|
41
47
|
|
|
42
48
|
option_spec: OptionSpec = {
|
|
49
|
+
'no-index': directives.flag,
|
|
50
|
+
'no-index-entry': directives.flag,
|
|
51
|
+
'no-contents-entry': directives.flag,
|
|
52
|
+
'no-typesetting': directives.flag,
|
|
43
53
|
'noindex': directives.flag,
|
|
44
54
|
'noindexentry': directives.flag,
|
|
45
55
|
'nocontentsentry': directives.flag,
|
|
@@ -142,7 +152,7 @@ class JSObject(ObjectDescription[Tuple[str, str]]):
|
|
|
142
152
|
domain = cast(JavaScriptDomain, self.env.get_domain('js'))
|
|
143
153
|
domain.note_object(fullname, self.objtype, node_id, location=signode)
|
|
144
154
|
|
|
145
|
-
if '
|
|
155
|
+
if 'no-index-entry' not in self.options:
|
|
146
156
|
indextext = self.get_index_text(mod_name, name_obj) # type: ignore[arg-type]
|
|
147
157
|
if indextext:
|
|
148
158
|
self.indexnode['entries'].append(('single', indextext, node_id, '', None))
|
|
@@ -209,10 +219,9 @@ class JSObject(ObjectDescription[Tuple[str, str]]):
|
|
|
209
219
|
"""
|
|
210
220
|
objects = self.env.ref_context.setdefault('js:objects', [])
|
|
211
221
|
if self.allow_nesting:
|
|
212
|
-
|
|
222
|
+
with contextlib.suppress(IndexError):
|
|
213
223
|
objects.pop()
|
|
214
|
-
|
|
215
|
-
pass
|
|
224
|
+
|
|
216
225
|
self.env.ref_context['js:object'] = (objects[-1] if len(objects) > 0
|
|
217
226
|
else None)
|
|
218
227
|
|
|
@@ -274,8 +283,8 @@ class JSModule(SphinxDirective):
|
|
|
274
283
|
Options
|
|
275
284
|
-------
|
|
276
285
|
|
|
277
|
-
|
|
278
|
-
If the
|
|
286
|
+
no-index
|
|
287
|
+
If the ``:no-index:`` option is specified, no linkable elements will be
|
|
279
288
|
created, and the module won't be added to the global module index. This
|
|
280
289
|
is useful for splitting up the module definition across multiple
|
|
281
290
|
sections or files.
|
|
@@ -288,6 +297,9 @@ class JSModule(SphinxDirective):
|
|
|
288
297
|
optional_arguments = 0
|
|
289
298
|
final_argument_whitespace = False
|
|
290
299
|
option_spec: OptionSpec = {
|
|
300
|
+
'no-index': directives.flag,
|
|
301
|
+
'no-contents-entry': directives.flag,
|
|
302
|
+
'no-typesetting': directives.flag,
|
|
291
303
|
'noindex': directives.flag,
|
|
292
304
|
'nocontentsentry': directives.flag,
|
|
293
305
|
}
|
|
@@ -295,7 +307,7 @@ class JSModule(SphinxDirective):
|
|
|
295
307
|
def run(self) -> list[Node]:
|
|
296
308
|
mod_name = self.arguments[0].strip()
|
|
297
309
|
self.env.ref_context['js:module'] = mod_name
|
|
298
|
-
|
|
310
|
+
no_index = 'no-index' in self.options
|
|
299
311
|
|
|
300
312
|
content_node: Element = nodes.section()
|
|
301
313
|
# necessary so that the child nodes get the right source/line set
|
|
@@ -303,7 +315,7 @@ class JSModule(SphinxDirective):
|
|
|
303
315
|
nested_parse_with_titles(self.state, self.content, content_node, self.content_offset)
|
|
304
316
|
|
|
305
317
|
ret: list[Node] = []
|
|
306
|
-
if not
|
|
318
|
+
if not no_index:
|
|
307
319
|
domain = cast(JavaScriptDomain, self.env.get_domain('js'))
|
|
308
320
|
|
|
309
321
|
node_id = make_id(self.env, self.state.document, 'module', mod_name)
|
|
@@ -313,12 +325,13 @@ class JSModule(SphinxDirective):
|
|
|
313
325
|
domain.note_object(mod_name, 'module', node_id,
|
|
314
326
|
location=(self.env.docname, self.lineno))
|
|
315
327
|
|
|
316
|
-
|
|
317
|
-
self.state.document.note_explicit_target(target)
|
|
318
|
-
ret.append(target)
|
|
328
|
+
# The node order is: index node first, then target node
|
|
319
329
|
indextext = _('%s (module)') % mod_name
|
|
320
330
|
inode = addnodes.index(entries=[('single', indextext, node_id, '', None)])
|
|
321
331
|
ret.append(inode)
|
|
332
|
+
target = nodes.target('', '', ids=[node_id], ismod=True)
|
|
333
|
+
self.state.document.note_explicit_target(target)
|
|
334
|
+
ret.append(target)
|
|
322
335
|
ret.extend(content_node.children)
|
|
323
336
|
return ret
|
|
324
337
|
|
sphinx/domains/math.py
CHANGED
|
@@ -2,22 +2,24 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
-
from typing import TYPE_CHECKING, Any
|
|
5
|
+
from typing import TYPE_CHECKING, Any
|
|
6
6
|
|
|
7
7
|
from docutils import nodes
|
|
8
8
|
from docutils.nodes import Element, Node, make_id, system_message
|
|
9
9
|
|
|
10
|
-
from sphinx.addnodes import pending_xref
|
|
11
10
|
from sphinx.domains import Domain
|
|
12
|
-
from sphinx.environment import BuildEnvironment
|
|
13
11
|
from sphinx.locale import __
|
|
14
12
|
from sphinx.roles import XRefRole
|
|
15
13
|
from sphinx.util import logging
|
|
16
14
|
from sphinx.util.nodes import make_refnode
|
|
17
15
|
|
|
18
16
|
if TYPE_CHECKING:
|
|
17
|
+
from collections.abc import Iterable
|
|
18
|
+
|
|
19
|
+
from sphinx.addnodes import pending_xref
|
|
19
20
|
from sphinx.application import Sphinx
|
|
20
21
|
from sphinx.builders import Builder
|
|
22
|
+
from sphinx.environment import BuildEnvironment
|
|
21
23
|
|
|
22
24
|
|
|
23
25
|
logger = logging.getLogger(__name__)
|
sphinx/domains/python.py
CHANGED
|
@@ -4,25 +4,21 @@ from __future__ import annotations
|
|
|
4
4
|
|
|
5
5
|
import ast
|
|
6
6
|
import builtins
|
|
7
|
+
import contextlib
|
|
7
8
|
import inspect
|
|
8
9
|
import re
|
|
9
10
|
import token
|
|
10
11
|
import typing
|
|
11
12
|
from inspect import Parameter
|
|
12
|
-
from typing import
|
|
13
|
+
from typing import TYPE_CHECKING, Any, NamedTuple, cast
|
|
13
14
|
|
|
14
15
|
from docutils import nodes
|
|
15
|
-
from docutils.nodes import Element, Node
|
|
16
16
|
from docutils.parsers.rst import directives
|
|
17
|
-
from docutils.parsers.rst.states import Inliner
|
|
18
17
|
|
|
19
18
|
from sphinx import addnodes
|
|
20
19
|
from sphinx.addnodes import desc_signature, pending_xref, pending_xref_condition
|
|
21
|
-
from sphinx.application import Sphinx
|
|
22
|
-
from sphinx.builders import Builder
|
|
23
20
|
from sphinx.directives import ObjectDescription
|
|
24
21
|
from sphinx.domains import Domain, Index, IndexEntry, ObjType
|
|
25
|
-
from sphinx.environment import BuildEnvironment
|
|
26
22
|
from sphinx.locale import _, __
|
|
27
23
|
from sphinx.pycode.parser import Token, TokenProcessor
|
|
28
24
|
from sphinx.roles import XRefRole
|
|
@@ -36,7 +32,17 @@ from sphinx.util.nodes import (
|
|
|
36
32
|
make_refnode,
|
|
37
33
|
nested_parse_with_titles,
|
|
38
34
|
)
|
|
39
|
-
|
|
35
|
+
|
|
36
|
+
if TYPE_CHECKING:
|
|
37
|
+
from collections.abc import Iterable, Iterator
|
|
38
|
+
|
|
39
|
+
from docutils.nodes import Element, Node
|
|
40
|
+
from docutils.parsers.rst.states import Inliner
|
|
41
|
+
|
|
42
|
+
from sphinx.application import Sphinx
|
|
43
|
+
from sphinx.builders import Builder
|
|
44
|
+
from sphinx.environment import BuildEnvironment
|
|
45
|
+
from sphinx.util.typing import OptionSpec, TextlikeNode
|
|
40
46
|
|
|
41
47
|
logger = logging.getLogger(__name__)
|
|
42
48
|
|
|
@@ -105,7 +111,7 @@ def parse_reftarget(reftarget: str, suppress_prefix: bool = False,
|
|
|
105
111
|
return reftype, reftarget, title, refspecific
|
|
106
112
|
|
|
107
113
|
|
|
108
|
-
def type_to_xref(target: str, env: BuildEnvironment
|
|
114
|
+
def type_to_xref(target: str, env: BuildEnvironment, *,
|
|
109
115
|
suppress_prefix: bool = False) -> addnodes.pending_xref:
|
|
110
116
|
"""Convert a type string to a cross reference node."""
|
|
111
117
|
if env:
|
|
@@ -131,7 +137,7 @@ def type_to_xref(target: str, env: BuildEnvironment | None = None,
|
|
|
131
137
|
refspecific=refspecific, **kwargs)
|
|
132
138
|
|
|
133
139
|
|
|
134
|
-
def _parse_annotation(annotation: str, env: BuildEnvironment
|
|
140
|
+
def _parse_annotation(annotation: str, env: BuildEnvironment) -> list[Node]:
|
|
135
141
|
"""Parse type annotation."""
|
|
136
142
|
short_literals = env.config.python_display_short_literal_types
|
|
137
143
|
|
|
@@ -162,8 +168,6 @@ def _parse_annotation(annotation: str, env: BuildEnvironment | None) -> list[Nod
|
|
|
162
168
|
return [nodes.Text(repr(node.value))]
|
|
163
169
|
if isinstance(node, ast.Expr):
|
|
164
170
|
return unparse(node.value)
|
|
165
|
-
if isinstance(node, ast.Index):
|
|
166
|
-
return unparse(node.value)
|
|
167
171
|
if isinstance(node, ast.Invert):
|
|
168
172
|
return [addnodes.desc_sig_punctuation('', '~')]
|
|
169
173
|
if isinstance(node, ast.List):
|
|
@@ -220,9 +224,6 @@ def _parse_annotation(annotation: str, env: BuildEnvironment | None) -> list[Nod
|
|
|
220
224
|
|
|
221
225
|
def _unparse_pep_604_annotation(node: ast.Subscript) -> list[Node]:
|
|
222
226
|
subscript = node.slice
|
|
223
|
-
if isinstance(subscript, ast.Index):
|
|
224
|
-
# py38 only
|
|
225
|
-
subscript = subscript.value # type: ignore[assignment]
|
|
226
227
|
|
|
227
228
|
flattened: list[Node] = []
|
|
228
229
|
if isinstance(subscript, ast.Tuple):
|
|
@@ -271,25 +272,25 @@ class _TypeParameterListParser(TokenProcessor):
|
|
|
271
272
|
|
|
272
273
|
def fetch_type_param_spec(self) -> list[Token]:
|
|
273
274
|
tokens = []
|
|
274
|
-
while self.fetch_token():
|
|
275
|
-
tokens.append(
|
|
275
|
+
while current := self.fetch_token():
|
|
276
|
+
tokens.append(current)
|
|
276
277
|
for ldelim, rdelim in ('(', ')'), ('{', '}'), ('[', ']'):
|
|
277
|
-
if
|
|
278
|
+
if current == [token.OP, ldelim]:
|
|
278
279
|
tokens += self.fetch_until([token.OP, rdelim])
|
|
279
280
|
break
|
|
280
281
|
else:
|
|
281
|
-
if
|
|
282
|
+
if current == token.INDENT:
|
|
282
283
|
tokens += self.fetch_until(token.DEDENT)
|
|
283
|
-
elif
|
|
284
|
+
elif current.match(
|
|
284
285
|
[token.OP, ':'], [token.OP, '='], [token.OP, ',']):
|
|
285
286
|
tokens.pop()
|
|
286
287
|
break
|
|
287
288
|
return tokens
|
|
288
289
|
|
|
289
290
|
def parse(self) -> None:
|
|
290
|
-
while self.fetch_token():
|
|
291
|
-
if
|
|
292
|
-
tp_name =
|
|
291
|
+
while current := self.fetch_token():
|
|
292
|
+
if current == token.NAME:
|
|
293
|
+
tp_name = current.value.strip()
|
|
293
294
|
if self.previous and self.previous.match([token.OP, '*'], [token.OP, '**']):
|
|
294
295
|
if self.previous == [token.OP, '*']:
|
|
295
296
|
tp_kind = Parameter.VAR_POSITIONAL
|
|
@@ -301,19 +302,20 @@ class _TypeParameterListParser(TokenProcessor):
|
|
|
301
302
|
tp_ann: Any = Parameter.empty
|
|
302
303
|
tp_default: Any = Parameter.empty
|
|
303
304
|
|
|
304
|
-
self.fetch_token()
|
|
305
|
-
if
|
|
306
|
-
if
|
|
305
|
+
current = self.fetch_token()
|
|
306
|
+
if current and current.match([token.OP, ':'], [token.OP, '=']):
|
|
307
|
+
if current == [token.OP, ':']:
|
|
307
308
|
tokens = self.fetch_type_param_spec()
|
|
308
309
|
tp_ann = self._build_identifier(tokens)
|
|
309
310
|
|
|
310
|
-
if self.current == [token.OP, '=']:
|
|
311
|
+
if self.current and self.current == [token.OP, '=']:
|
|
311
312
|
tokens = self.fetch_type_param_spec()
|
|
312
313
|
tp_default = self._build_identifier(tokens)
|
|
313
314
|
|
|
314
315
|
if tp_kind != Parameter.POSITIONAL_OR_KEYWORD and tp_ann != Parameter.empty:
|
|
315
|
-
|
|
316
|
-
|
|
316
|
+
msg = ('type parameter bound or constraint is not allowed '
|
|
317
|
+
f'for {tp_kind.description} parameters')
|
|
318
|
+
raise SyntaxError(msg)
|
|
317
319
|
|
|
318
320
|
type_param = (tp_name, tp_kind, tp_default, tp_ann)
|
|
319
321
|
self.type_params.append(type_param)
|
|
@@ -331,7 +333,7 @@ class _TypeParameterListParser(TokenProcessor):
|
|
|
331
333
|
yield a, b, c
|
|
332
334
|
|
|
333
335
|
idents: list[str] = []
|
|
334
|
-
tokens: Iterable[Token] = iter(tokens) # type: ignore
|
|
336
|
+
tokens: Iterable[Token] = iter(tokens) # type: ignore[no-redef]
|
|
335
337
|
# do not format opening brackets
|
|
336
338
|
for tok in tokens:
|
|
337
339
|
if not tok.match([token.OP, '('], [token.OP, '['], [token.OP, '{']):
|
|
@@ -397,7 +399,7 @@ class _TypeParameterListParser(TokenProcessor):
|
|
|
397
399
|
|
|
398
400
|
|
|
399
401
|
def _parse_type_list(
|
|
400
|
-
tp_list: str, env: BuildEnvironment
|
|
402
|
+
tp_list: str, env: BuildEnvironment,
|
|
401
403
|
multi_line_parameter_list: bool = False,
|
|
402
404
|
) -> addnodes.desc_type_parameter_list:
|
|
403
405
|
"""Parse a list of type parameters according to PEP 695."""
|
|
@@ -410,8 +412,9 @@ def _parse_type_list(
|
|
|
410
412
|
for (tp_name, tp_kind, tp_default, tp_ann) in parser.type_params:
|
|
411
413
|
# no positional-only or keyword-only allowed in a type parameters list
|
|
412
414
|
if tp_kind in {Parameter.POSITIONAL_ONLY, Parameter.KEYWORD_ONLY}:
|
|
413
|
-
|
|
414
|
-
|
|
415
|
+
msg = ('positional-only or keyword-only parameters '
|
|
416
|
+
'are prohibited in type parameter lists')
|
|
417
|
+
raise SyntaxError(msg)
|
|
415
418
|
|
|
416
419
|
node = addnodes.desc_type_parameter()
|
|
417
420
|
if tp_kind == Parameter.VAR_POSITIONAL:
|
|
@@ -458,7 +461,7 @@ def _parse_type_list(
|
|
|
458
461
|
|
|
459
462
|
|
|
460
463
|
def _parse_arglist(
|
|
461
|
-
arglist: str, env: BuildEnvironment
|
|
464
|
+
arglist: str, env: BuildEnvironment, multi_line_parameter_list: bool = False,
|
|
462
465
|
) -> addnodes.desc_parameterlist:
|
|
463
466
|
"""Parse a list of arguments using AST parser"""
|
|
464
467
|
params = addnodes.desc_parameterlist(arglist)
|
|
@@ -489,7 +492,7 @@ def _parse_arglist(
|
|
|
489
492
|
children = _parse_annotation(param.annotation, env)
|
|
490
493
|
node += addnodes.desc_sig_punctuation('', ':')
|
|
491
494
|
node += addnodes.desc_sig_space()
|
|
492
|
-
node += addnodes.desc_sig_name('', '', *children) # type: ignore
|
|
495
|
+
node += addnodes.desc_sig_name('', '', *children) # type: ignore[arg-type]
|
|
493
496
|
if param.default is not param.empty:
|
|
494
497
|
if param.annotation is not param.empty:
|
|
495
498
|
node += addnodes.desc_sig_space()
|
|
@@ -578,10 +581,11 @@ class PyXrefMixin:
|
|
|
578
581
|
) -> Node:
|
|
579
582
|
# we use inliner=None to make sure we get the old behaviour with a single
|
|
580
583
|
# pending_xref node
|
|
581
|
-
result = super().make_xref(rolename, domain, target, # type: ignore
|
|
584
|
+
result = super().make_xref(rolename, domain, target, # type: ignore[misc]
|
|
582
585
|
innernode, contnode,
|
|
583
586
|
env, inliner=None, location=None)
|
|
584
587
|
if isinstance(result, pending_xref):
|
|
588
|
+
assert env is not None
|
|
585
589
|
result['refspecific'] = True
|
|
586
590
|
result['py:module'] = env.ref_context.get('py:module')
|
|
587
591
|
result['py:class'] = env.ref_context.get('py:class')
|
|
@@ -652,7 +656,7 @@ class PyTypedField(PyXrefMixin, TypedField):
|
|
|
652
656
|
pass
|
|
653
657
|
|
|
654
658
|
|
|
655
|
-
class PyObject(ObjectDescription[
|
|
659
|
+
class PyObject(ObjectDescription[tuple[str, str]]):
|
|
656
660
|
"""
|
|
657
661
|
Description of a general Python object.
|
|
658
662
|
|
|
@@ -660,6 +664,10 @@ class PyObject(ObjectDescription[Tuple[str, str]]):
|
|
|
660
664
|
:vartype allow_nesting: bool
|
|
661
665
|
"""
|
|
662
666
|
option_spec: OptionSpec = {
|
|
667
|
+
'no-index': directives.flag,
|
|
668
|
+
'no-index-entry': directives.flag,
|
|
669
|
+
'no-contents-entry': directives.flag,
|
|
670
|
+
'no-typesetting': directives.flag,
|
|
663
671
|
'noindex': directives.flag,
|
|
664
672
|
'noindexentry': directives.flag,
|
|
665
673
|
'nocontentsentry': directives.flag,
|
|
@@ -771,10 +779,10 @@ class PyObject(ObjectDescription[Tuple[str, str]]):
|
|
|
771
779
|
sig_prefix = self.get_signature_prefix(sig)
|
|
772
780
|
if sig_prefix:
|
|
773
781
|
if type(sig_prefix) is str:
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
782
|
+
msg = ("Python directive method get_signature_prefix()"
|
|
783
|
+
" must return a list of nodes."
|
|
784
|
+
f" Return value was '{sig_prefix}'.")
|
|
785
|
+
raise TypeError(msg)
|
|
778
786
|
signode += addnodes.desc_annotation(str(sig_prefix), '', *sig_prefix)
|
|
779
787
|
|
|
780
788
|
if prefix:
|
|
@@ -836,7 +844,8 @@ class PyObject(ObjectDescription[Tuple[str, str]]):
|
|
|
836
844
|
|
|
837
845
|
def get_index_text(self, modname: str, name: tuple[str, str]) -> str:
|
|
838
846
|
"""Return the text for the index entry of the object."""
|
|
839
|
-
|
|
847
|
+
msg = 'must be implemented in subclasses'
|
|
848
|
+
raise NotImplementedError(msg)
|
|
840
849
|
|
|
841
850
|
def add_target_and_index(self, name_cls: tuple[str, str], sig: str,
|
|
842
851
|
signode: desc_signature) -> None:
|
|
@@ -854,7 +863,7 @@ class PyObject(ObjectDescription[Tuple[str, str]]):
|
|
|
854
863
|
domain.note_object(canonical_name, self.objtype, node_id, aliased=True,
|
|
855
864
|
location=signode)
|
|
856
865
|
|
|
857
|
-
if '
|
|
866
|
+
if 'no-index-entry' not in self.options:
|
|
858
867
|
indextext = self.get_index_text(modname, name_cls)
|
|
859
868
|
if indextext:
|
|
860
869
|
self.indexnode['entries'].append(('single', indextext, node_id, '', None))
|
|
@@ -904,10 +913,9 @@ class PyObject(ObjectDescription[Tuple[str, str]]):
|
|
|
904
913
|
"""
|
|
905
914
|
classes = self.env.ref_context.setdefault('py:classes', [])
|
|
906
915
|
if self.allow_nesting:
|
|
907
|
-
|
|
916
|
+
with contextlib.suppress(IndexError):
|
|
908
917
|
classes.pop()
|
|
909
|
-
|
|
910
|
-
pass
|
|
918
|
+
|
|
911
919
|
self.env.ref_context['py:class'] = (classes[-1] if len(classes) > 0
|
|
912
920
|
else None)
|
|
913
921
|
if 'module' in self.options:
|
|
@@ -958,7 +966,7 @@ class PyFunction(PyObject):
|
|
|
958
966
|
def add_target_and_index(self, name_cls: tuple[str, str], sig: str,
|
|
959
967
|
signode: desc_signature) -> None:
|
|
960
968
|
super().add_target_and_index(name_cls, sig, signode)
|
|
961
|
-
if '
|
|
969
|
+
if 'no-index-entry' not in self.options:
|
|
962
970
|
modname = self.options.get('module', self.env.ref_context.get('py:module'))
|
|
963
971
|
node_id = signode['ids'][0]
|
|
964
972
|
|
|
@@ -970,9 +978,9 @@ class PyFunction(PyObject):
|
|
|
970
978
|
text = f'built-in function; {name}()'
|
|
971
979
|
self.indexnode['entries'].append(('pair', text, node_id, '', None))
|
|
972
980
|
|
|
973
|
-
def get_index_text(self, modname: str, name_cls: tuple[str, str]) -> str
|
|
981
|
+
def get_index_text(self, modname: str, name_cls: tuple[str, str]) -> str:
|
|
974
982
|
# add index in own add_target_and_index() instead.
|
|
975
|
-
return
|
|
983
|
+
return ''
|
|
976
984
|
|
|
977
985
|
|
|
978
986
|
class PyDecoratorFunction(PyFunction):
|
|
@@ -1261,6 +1269,9 @@ class PyModule(SphinxDirective):
|
|
|
1261
1269
|
option_spec: OptionSpec = {
|
|
1262
1270
|
'platform': lambda x: x,
|
|
1263
1271
|
'synopsis': lambda x: x,
|
|
1272
|
+
'no-index': directives.flag,
|
|
1273
|
+
'no-contents-entry': directives.flag,
|
|
1274
|
+
'no-typesetting': directives.flag,
|
|
1264
1275
|
'noindex': directives.flag,
|
|
1265
1276
|
'nocontentsentry': directives.flag,
|
|
1266
1277
|
'deprecated': directives.flag,
|
|
@@ -1270,7 +1281,7 @@ class PyModule(SphinxDirective):
|
|
|
1270
1281
|
domain = cast(PythonDomain, self.env.get_domain('py'))
|
|
1271
1282
|
|
|
1272
1283
|
modname = self.arguments[0].strip()
|
|
1273
|
-
|
|
1284
|
+
no_index = 'no-index' in self.options
|
|
1274
1285
|
self.env.ref_context['py:module'] = modname
|
|
1275
1286
|
|
|
1276
1287
|
content_node: Element = nodes.section()
|
|
@@ -1279,7 +1290,7 @@ class PyModule(SphinxDirective):
|
|
|
1279
1290
|
nested_parse_with_titles(self.state, self.content, content_node, self.content_offset)
|
|
1280
1291
|
|
|
1281
1292
|
ret: list[Node] = []
|
|
1282
|
-
if not
|
|
1293
|
+
if not no_index:
|
|
1283
1294
|
# note module to the domain
|
|
1284
1295
|
node_id = make_id(self.env, self.state.document, 'module', modname)
|
|
1285
1296
|
target = nodes.target('', '', ids=[node_id], ismod=True)
|
|
@@ -1295,10 +1306,11 @@ class PyModule(SphinxDirective):
|
|
|
1295
1306
|
|
|
1296
1307
|
# the platform and synopsis aren't printed; in fact, they are only
|
|
1297
1308
|
# used in the modindex currently
|
|
1298
|
-
ret.append(target)
|
|
1299
1309
|
indextext = f'module; {modname}'
|
|
1300
1310
|
inode = addnodes.index(entries=[('pair', indextext, node_id, '', None)])
|
|
1311
|
+
# The node order is: index node first, then target node.
|
|
1301
1312
|
ret.append(inode)
|
|
1313
|
+
ret.append(target)
|
|
1302
1314
|
ret.extend(content_node.children)
|
|
1303
1315
|
return ret
|
|
1304
1316
|
|
|
@@ -1354,7 +1366,7 @@ def filter_meta_fields(app: Sphinx, domain: str, objtype: str, content: Element)
|
|
|
1354
1366
|
|
|
1355
1367
|
for node in content:
|
|
1356
1368
|
if isinstance(node, nodes.field_list):
|
|
1357
|
-
fields = cast(
|
|
1369
|
+
fields = cast(list[nodes.field], node)
|
|
1358
1370
|
# removing list items while iterating the list needs reversed()
|
|
1359
1371
|
for field in reversed(fields):
|
|
1360
1372
|
field_name = cast(nodes.field_body, field[0]).astext().strip()
|
|
@@ -1506,7 +1518,7 @@ class PythonDomain(Domain):
|
|
|
1506
1518
|
else:
|
|
1507
1519
|
# duplicated
|
|
1508
1520
|
logger.warning(__('duplicate object description of %s, '
|
|
1509
|
-
'other instance in %s, use :
|
|
1521
|
+
'other instance in %s, use :no-index: for one of them'),
|
|
1510
1522
|
name, other.docname, location=location)
|
|
1511
1523
|
self.objects[name] = ObjectEntry(self.env.docname, node_id, objtype, aliased)
|
|
1512
1524
|
|
|
@@ -1558,7 +1570,7 @@ class PythonDomain(Domain):
|
|
|
1558
1570
|
newname = None
|
|
1559
1571
|
if searchmode == 1:
|
|
1560
1572
|
if type is None:
|
|
1561
|
-
objtypes = list(self.object_types)
|
|
1573
|
+
objtypes: list[str] | None = list(self.object_types)
|
|
1562
1574
|
else:
|
|
1563
1575
|
objtypes = self.objtypes_for_role(type)
|
|
1564
1576
|
if objtypes is not None:
|
|
@@ -1673,9 +1685,9 @@ class PythonDomain(Domain):
|
|
|
1673
1685
|
# if not found, use contnode
|
|
1674
1686
|
children = [contnode]
|
|
1675
1687
|
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1688
|
+
role = 'py:' + self.role_for_objtype(obj[2]) # type: ignore[operator]
|
|
1689
|
+
results.append((role, make_refnode(builder, fromdocname, obj[0], obj[1],
|
|
1690
|
+
children, name)))
|
|
1679
1691
|
return results
|
|
1680
1692
|
|
|
1681
1693
|
def _make_module_refnode(self, builder: Builder, fromdocname: str, name: str,
|
sphinx/domains/rst.py
CHANGED
|
@@ -3,23 +3,28 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
5
|
import re
|
|
6
|
-
from typing import
|
|
6
|
+
from typing import TYPE_CHECKING, Any, cast
|
|
7
7
|
|
|
8
|
-
from docutils.nodes import Element
|
|
9
8
|
from docutils.parsers.rst import directives
|
|
10
9
|
|
|
11
10
|
from sphinx import addnodes
|
|
12
|
-
from sphinx.addnodes import desc_signature, pending_xref
|
|
13
|
-
from sphinx.application import Sphinx
|
|
14
|
-
from sphinx.builders import Builder
|
|
15
11
|
from sphinx.directives import ObjectDescription
|
|
16
12
|
from sphinx.domains import Domain, ObjType
|
|
17
|
-
from sphinx.environment import BuildEnvironment
|
|
18
13
|
from sphinx.locale import _, __
|
|
19
14
|
from sphinx.roles import XRefRole
|
|
20
15
|
from sphinx.util import logging
|
|
21
16
|
from sphinx.util.nodes import make_id, make_refnode
|
|
22
|
-
|
|
17
|
+
|
|
18
|
+
if TYPE_CHECKING:
|
|
19
|
+
from collections.abc import Iterator
|
|
20
|
+
|
|
21
|
+
from docutils.nodes import Element
|
|
22
|
+
|
|
23
|
+
from sphinx.addnodes import desc_signature, pending_xref
|
|
24
|
+
from sphinx.application import Sphinx
|
|
25
|
+
from sphinx.builders import Builder
|
|
26
|
+
from sphinx.environment import BuildEnvironment
|
|
27
|
+
from sphinx.util.typing import OptionSpec
|
|
23
28
|
|
|
24
29
|
logger = logging.getLogger(__name__)
|
|
25
30
|
|
|
@@ -31,6 +36,10 @@ class ReSTMarkup(ObjectDescription[str]):
|
|
|
31
36
|
Description of generic reST markup.
|
|
32
37
|
"""
|
|
33
38
|
option_spec: OptionSpec = {
|
|
39
|
+
'no-index': directives.flag,
|
|
40
|
+
'no-index-entry': directives.flag,
|
|
41
|
+
'no-contents-entry': directives.flag,
|
|
42
|
+
'no-typesetting': directives.flag,
|
|
34
43
|
'noindex': directives.flag,
|
|
35
44
|
'noindexentry': directives.flag,
|
|
36
45
|
'nocontentsentry': directives.flag,
|
|
@@ -44,7 +53,7 @@ class ReSTMarkup(ObjectDescription[str]):
|
|
|
44
53
|
domain = cast(ReSTDomain, self.env.get_domain('rst'))
|
|
45
54
|
domain.note_object(self.objtype, name, node_id, location=signode)
|
|
46
55
|
|
|
47
|
-
if '
|
|
56
|
+
if 'no-index-entry' not in self.options:
|
|
48
57
|
indextext = self.get_index_text(self.objtype, name)
|
|
49
58
|
if indextext:
|
|
50
59
|
self.indexnode['entries'].append(('single', indextext, node_id, '', None))
|
|
@@ -137,7 +146,7 @@ class ReSTDirectiveOption(ReSTMarkup):
|
|
|
137
146
|
|
|
138
147
|
def handle_signature(self, sig: str, signode: desc_signature) -> str:
|
|
139
148
|
try:
|
|
140
|
-
name, argument = re.split(r'\s*:\s+', sig.strip(), 1)
|
|
149
|
+
name, argument = re.split(r'\s*:\s+', sig.strip(), maxsplit=1)
|
|
141
150
|
except ValueError:
|
|
142
151
|
name, argument = sig, None
|
|
143
152
|
|
|
@@ -206,9 +215,9 @@ class ReSTDomain(Domain):
|
|
|
206
215
|
label = 'reStructuredText'
|
|
207
216
|
|
|
208
217
|
object_types = {
|
|
209
|
-
'directive': ObjType(_('directive'),
|
|
218
|
+
'directive': ObjType(_('directive'), 'dir'),
|
|
210
219
|
'directive:option': ObjType(_('directive-option'), 'dir'),
|
|
211
|
-
'role': ObjType(_('role'),
|
|
220
|
+
'role': ObjType(_('role'), 'role'),
|
|
212
221
|
}
|
|
213
222
|
directives = {
|
|
214
223
|
'directive': ReSTDirective,
|