Sphinx 7.1.1__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 +21 -13
- 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.1.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.1.dist-info/RECORD +0 -564
- {sphinx-7.1.1.dist-info → sphinx-7.2.0.dist-info}/LICENSE +0 -0
- {sphinx-7.1.1.dist-info → sphinx-7.2.0.dist-info}/WHEEL +0 -0
- {sphinx-7.1.1.dist-info → sphinx-7.2.0.dist-info}/entry_points.txt +0 -0
|
@@ -4,12 +4,11 @@ from __future__ import annotations
|
|
|
4
4
|
|
|
5
5
|
from typing import TYPE_CHECKING
|
|
6
6
|
|
|
7
|
-
from docutils import nodes
|
|
8
|
-
|
|
9
|
-
from sphinx.environment import BuildEnvironment
|
|
10
|
-
|
|
11
7
|
if TYPE_CHECKING:
|
|
8
|
+
from docutils import nodes
|
|
9
|
+
|
|
12
10
|
from sphinx.application import Sphinx
|
|
11
|
+
from sphinx.environment import BuildEnvironment
|
|
13
12
|
|
|
14
13
|
|
|
15
14
|
class EnvironmentCollector:
|
|
@@ -5,21 +5,24 @@ from __future__ import annotations
|
|
|
5
5
|
import os
|
|
6
6
|
from glob import glob
|
|
7
7
|
from os import path
|
|
8
|
-
from typing import Any
|
|
8
|
+
from typing import TYPE_CHECKING, Any
|
|
9
9
|
|
|
10
10
|
from docutils import nodes
|
|
11
|
-
from docutils.nodes import Node
|
|
12
11
|
from docutils.utils import relative_path
|
|
13
12
|
|
|
14
13
|
from sphinx import addnodes
|
|
15
|
-
from sphinx.application import Sphinx
|
|
16
|
-
from sphinx.environment import BuildEnvironment
|
|
17
14
|
from sphinx.environment.collectors import EnvironmentCollector
|
|
18
15
|
from sphinx.locale import __
|
|
19
16
|
from sphinx.util import logging
|
|
20
17
|
from sphinx.util.i18n import get_image_filename_for_language, search_image_for_language
|
|
21
18
|
from sphinx.util.images import guess_mimetype
|
|
22
19
|
|
|
20
|
+
if TYPE_CHECKING:
|
|
21
|
+
from docutils.nodes import Node
|
|
22
|
+
|
|
23
|
+
from sphinx.application import Sphinx
|
|
24
|
+
from sphinx.environment import BuildEnvironment
|
|
25
|
+
|
|
23
26
|
logger = logging.getLogger(__name__)
|
|
24
27
|
|
|
25
28
|
|
|
@@ -71,8 +74,11 @@ class ImageCollector(EnvironmentCollector):
|
|
|
71
74
|
|
|
72
75
|
# Update `node['uri']` to a relative path from srcdir
|
|
73
76
|
# from a relative path from current document.
|
|
77
|
+
original_uri = node['uri']
|
|
74
78
|
node['uri'], _ = app.env.relfn2path(imguri, docname)
|
|
75
79
|
candidates['*'] = node['uri']
|
|
80
|
+
if node['uri'] != original_uri:
|
|
81
|
+
node['original_uri'] = original_uri
|
|
76
82
|
|
|
77
83
|
# map image paths to unique image names (so that they can be put
|
|
78
84
|
# into a single directory)
|
|
@@ -4,16 +4,19 @@ from __future__ import annotations
|
|
|
4
4
|
|
|
5
5
|
import os
|
|
6
6
|
from os import path
|
|
7
|
-
from typing import Any
|
|
7
|
+
from typing import TYPE_CHECKING, Any
|
|
8
8
|
|
|
9
|
-
from docutils import nodes
|
|
10
9
|
from docutils.utils import relative_path
|
|
11
10
|
|
|
12
|
-
from sphinx.application import Sphinx
|
|
13
|
-
from sphinx.environment import BuildEnvironment
|
|
14
11
|
from sphinx.environment.collectors import EnvironmentCollector
|
|
15
12
|
from sphinx.util.osutil import fs_encoding
|
|
16
13
|
|
|
14
|
+
if TYPE_CHECKING:
|
|
15
|
+
from docutils import nodes
|
|
16
|
+
|
|
17
|
+
from sphinx.application import Sphinx
|
|
18
|
+
from sphinx.environment import BuildEnvironment
|
|
19
|
+
|
|
17
20
|
|
|
18
21
|
class DependenciesCollector(EnvironmentCollector):
|
|
19
22
|
"""dependencies collector for sphinx.environment."""
|
|
@@ -2,14 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
-
from typing import
|
|
5
|
+
from typing import TYPE_CHECKING, Any, cast
|
|
6
6
|
|
|
7
7
|
from docutils import nodes
|
|
8
8
|
|
|
9
|
-
from sphinx.application import Sphinx
|
|
10
|
-
from sphinx.environment import BuildEnvironment
|
|
11
9
|
from sphinx.environment.collectors import EnvironmentCollector
|
|
12
10
|
|
|
11
|
+
if TYPE_CHECKING:
|
|
12
|
+
from sphinx.application import Sphinx
|
|
13
|
+
from sphinx.environment import BuildEnvironment
|
|
14
|
+
|
|
13
15
|
|
|
14
16
|
class MetadataCollector(EnvironmentCollector):
|
|
15
17
|
"""metadata collector for sphinx.environment."""
|
|
@@ -32,10 +34,10 @@ class MetadataCollector(EnvironmentCollector):
|
|
|
32
34
|
return
|
|
33
35
|
elif isinstance(doctree[index], nodes.docinfo):
|
|
34
36
|
md = app.env.metadata[app.env.docname]
|
|
35
|
-
for node in doctree[index]: # type: ignore
|
|
37
|
+
for node in doctree[index]: # type: ignore[attr-defined]
|
|
36
38
|
# nodes are multiply inherited...
|
|
37
39
|
if isinstance(node, nodes.authors):
|
|
38
|
-
authors = cast(
|
|
40
|
+
authors = cast(list[nodes.author], node)
|
|
39
41
|
md['authors'] = [author.astext() for author in authors]
|
|
40
42
|
elif isinstance(node, nodes.field):
|
|
41
43
|
assert len(node) == 2
|
|
@@ -2,15 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
-
from typing import Any
|
|
5
|
+
from typing import TYPE_CHECKING, Any
|
|
6
6
|
|
|
7
7
|
from docutils import nodes
|
|
8
8
|
|
|
9
|
-
from sphinx.application import Sphinx
|
|
10
|
-
from sphinx.environment import BuildEnvironment
|
|
11
9
|
from sphinx.environment.collectors import EnvironmentCollector
|
|
12
10
|
from sphinx.transforms import SphinxContentsFilter
|
|
13
11
|
|
|
12
|
+
if TYPE_CHECKING:
|
|
13
|
+
from sphinx.application import Sphinx
|
|
14
|
+
from sphinx.environment import BuildEnvironment
|
|
15
|
+
|
|
14
16
|
|
|
15
17
|
class TitleCollector(EnvironmentCollector):
|
|
16
18
|
"""title collector for sphinx.environment."""
|
|
@@ -2,20 +2,25 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
-
from typing import
|
|
5
|
+
from typing import TYPE_CHECKING, Any, TypeVar, cast
|
|
6
6
|
|
|
7
7
|
from docutils import nodes
|
|
8
|
-
from docutils.nodes import Element, Node
|
|
9
8
|
|
|
10
9
|
from sphinx import addnodes
|
|
11
|
-
from sphinx.
|
|
12
|
-
from sphinx.environment import BuildEnvironment
|
|
13
|
-
from sphinx.environment.adapters.toctree import TocTree
|
|
10
|
+
from sphinx.environment.adapters.toctree import note_toctree
|
|
14
11
|
from sphinx.environment.collectors import EnvironmentCollector
|
|
15
12
|
from sphinx.locale import __
|
|
16
13
|
from sphinx.transforms import SphinxContentsFilter
|
|
17
14
|
from sphinx.util import logging, url_re
|
|
18
15
|
|
|
16
|
+
if TYPE_CHECKING:
|
|
17
|
+
from collections.abc import Sequence
|
|
18
|
+
|
|
19
|
+
from docutils.nodes import Element, Node
|
|
20
|
+
|
|
21
|
+
from sphinx.application import Sphinx
|
|
22
|
+
from sphinx.environment import BuildEnvironment
|
|
23
|
+
|
|
19
24
|
N = TypeVar('N')
|
|
20
25
|
|
|
21
26
|
logger = logging.getLogger(__name__)
|
|
@@ -105,7 +110,7 @@ class TocTreeCollector(EnvironmentCollector):
|
|
|
105
110
|
item = toctreenode.copy()
|
|
106
111
|
entries.append(item)
|
|
107
112
|
# important: do the inventory stuff
|
|
108
|
-
|
|
113
|
+
note_toctree(app.env, docname, toctreenode)
|
|
109
114
|
# add object signatures within a section to the ToC
|
|
110
115
|
elif isinstance(toctreenode, addnodes.desc):
|
|
111
116
|
for sig_node in toctreenode:
|
|
@@ -115,9 +120,9 @@ class TocTreeCollector(EnvironmentCollector):
|
|
|
115
120
|
if not sig_node.get('_toc_name', ''):
|
|
116
121
|
continue
|
|
117
122
|
# Skip if explicitly disabled
|
|
118
|
-
if sig_node.parent.get('
|
|
123
|
+
if sig_node.parent.get('no-contents-entry'):
|
|
119
124
|
continue
|
|
120
|
-
# Skip entries with no ID (e.g. with :
|
|
125
|
+
# Skip entries with no ID (e.g. with :no-index: set)
|
|
121
126
|
ids = sig_node['ids']
|
|
122
127
|
if not ids:
|
|
123
128
|
continue
|
sphinx/errors.py
CHANGED
sphinx/events.py
CHANGED
|
@@ -5,6 +5,7 @@ Gracefully adapted from the TextPress system by Armin.
|
|
|
5
5
|
|
|
6
6
|
from __future__ import annotations
|
|
7
7
|
|
|
8
|
+
import contextlib
|
|
8
9
|
from collections import defaultdict
|
|
9
10
|
from operator import attrgetter
|
|
10
11
|
from typing import TYPE_CHECKING, Any, Callable, NamedTuple
|
|
@@ -82,12 +83,11 @@ class EventManager:
|
|
|
82
83
|
def emit(self, name: str, *args: Any,
|
|
83
84
|
allowed_exceptions: tuple[type[Exception], ...] = ()) -> list:
|
|
84
85
|
"""Emit a Sphinx event."""
|
|
85
|
-
|
|
86
|
+
|
|
87
|
+
# not every object likes to be repr()'d (think
|
|
88
|
+
# random stuff coming via autodoc)
|
|
89
|
+
with contextlib.suppress(Exception):
|
|
86
90
|
logger.debug('[app] emitting event: %r%s', name, repr(args)[:100])
|
|
87
|
-
except Exception:
|
|
88
|
-
# not every object likes to be repr()'d (think
|
|
89
|
-
# random stuff coming via autodoc)
|
|
90
|
-
pass
|
|
91
91
|
|
|
92
92
|
results = []
|
|
93
93
|
listeners = sorted(self.listeners[name], key=attrgetter("priority"))
|
sphinx/ext/apidoc.py
CHANGED
|
@@ -12,23 +12,30 @@ https://sat.qc.ca/
|
|
|
12
12
|
from __future__ import annotations
|
|
13
13
|
|
|
14
14
|
import argparse
|
|
15
|
+
import fnmatch
|
|
15
16
|
import glob
|
|
16
17
|
import locale
|
|
17
18
|
import os
|
|
19
|
+
import re
|
|
18
20
|
import sys
|
|
19
21
|
from copy import copy
|
|
20
|
-
from fnmatch import fnmatch
|
|
21
22
|
from importlib.machinery import EXTENSION_SUFFIXES
|
|
22
23
|
from os import path
|
|
23
|
-
from typing import
|
|
24
|
+
from typing import TYPE_CHECKING, Any
|
|
24
25
|
|
|
25
26
|
import sphinx.locale
|
|
26
27
|
from sphinx import __display_version__, package_dir
|
|
27
28
|
from sphinx.cmd.quickstart import EXTENSIONS
|
|
28
29
|
from sphinx.locale import __
|
|
30
|
+
from sphinx.util import logging
|
|
29
31
|
from sphinx.util.osutil import FileAvoidWrite, ensuredir
|
|
30
32
|
from sphinx.util.template import ReSTRenderer
|
|
31
33
|
|
|
34
|
+
if TYPE_CHECKING:
|
|
35
|
+
from collections.abc import Generator, Sequence
|
|
36
|
+
|
|
37
|
+
logger = logging.getLogger(__name__)
|
|
38
|
+
|
|
32
39
|
# automodule options
|
|
33
40
|
if 'SPHINX_APIDOC_OPTIONS' in os.environ:
|
|
34
41
|
OPTIONS = os.environ['SPHINX_APIDOC_OPTIONS'].split(',')
|
|
@@ -54,7 +61,7 @@ def is_initpy(filename: str) -> bool:
|
|
|
54
61
|
)
|
|
55
62
|
|
|
56
63
|
|
|
57
|
-
def module_join(*modnames: str) -> str:
|
|
64
|
+
def module_join(*modnames: str | None) -> str:
|
|
58
65
|
"""Join module names with dots."""
|
|
59
66
|
return '.'.join(filter(None, modnames))
|
|
60
67
|
|
|
@@ -76,19 +83,19 @@ def write_file(name: str, text: str, opts: Any) -> None:
|
|
|
76
83
|
fname = path.join(opts.destdir, f'{name}.{opts.suffix}')
|
|
77
84
|
if opts.dryrun:
|
|
78
85
|
if not quiet:
|
|
79
|
-
|
|
86
|
+
logger.info(__('Would create file %s.'), fname)
|
|
80
87
|
return
|
|
81
88
|
if not opts.force and path.isfile(fname):
|
|
82
89
|
if not quiet:
|
|
83
|
-
|
|
90
|
+
logger.info(__('File %s already exists, skipping.'), fname)
|
|
84
91
|
else:
|
|
85
92
|
if not quiet:
|
|
86
|
-
|
|
93
|
+
logger.info(__('Creating file %s.'), fname)
|
|
87
94
|
with FileAvoidWrite(fname) as f:
|
|
88
95
|
f.write(text)
|
|
89
96
|
|
|
90
97
|
|
|
91
|
-
def create_module_file(package: str, basename: str, opts: Any,
|
|
98
|
+
def create_module_file(package: str | None, basename: str, opts: Any,
|
|
92
99
|
user_template_dir: str | None = None) -> None:
|
|
93
100
|
"""Build the text of the file and write the file."""
|
|
94
101
|
options = copy(OPTIONS)
|
|
@@ -102,13 +109,19 @@ def create_module_file(package: str, basename: str, opts: Any,
|
|
|
102
109
|
'qualname': qualname,
|
|
103
110
|
'automodule_options': options,
|
|
104
111
|
}
|
|
105
|
-
|
|
112
|
+
if user_template_dir is not None:
|
|
113
|
+
template_path = [user_template_dir, template_dir]
|
|
114
|
+
else:
|
|
115
|
+
template_path = [template_dir]
|
|
116
|
+
text = ReSTRenderer(template_path).render('module.rst_t', context)
|
|
106
117
|
write_file(qualname, text, opts)
|
|
107
118
|
|
|
108
119
|
|
|
109
|
-
def create_package_file(root: str, master_package: str
|
|
120
|
+
def create_package_file(root: str, master_package: str | None, subroot: str,
|
|
121
|
+
py_files: list[str],
|
|
110
122
|
opts: Any, subs: list[str], is_namespace: bool,
|
|
111
|
-
excludes:
|
|
123
|
+
excludes: Sequence[re.Pattern[str]] = (),
|
|
124
|
+
user_template_dir: str | None = None,
|
|
112
125
|
) -> None:
|
|
113
126
|
"""Build the text of the file and write the file."""
|
|
114
127
|
# build a list of sub packages (directories containing an __init__ file)
|
|
@@ -138,7 +151,11 @@ def create_package_file(root: str, master_package: str, subroot: str, py_files:
|
|
|
138
151
|
'show_headings': not opts.noheadings,
|
|
139
152
|
'maxdepth': opts.maxdepth,
|
|
140
153
|
}
|
|
141
|
-
|
|
154
|
+
if user_template_dir is not None:
|
|
155
|
+
template_path = [user_template_dir, template_dir]
|
|
156
|
+
else:
|
|
157
|
+
template_path = [template_dir]
|
|
158
|
+
text = ReSTRenderer(template_path).render('package.rst_t', context)
|
|
142
159
|
write_file(pkgname, text, opts)
|
|
143
160
|
|
|
144
161
|
if submodules and opts.separatemodules:
|
|
@@ -163,11 +180,16 @@ def create_modules_toc_file(modules: list[str], opts: Any, name: str = 'modules'
|
|
|
163
180
|
'maxdepth': opts.maxdepth,
|
|
164
181
|
'docnames': modules,
|
|
165
182
|
}
|
|
166
|
-
|
|
183
|
+
if user_template_dir is not None:
|
|
184
|
+
template_path = [user_template_dir, template_dir]
|
|
185
|
+
else:
|
|
186
|
+
template_path = [template_dir]
|
|
187
|
+
text = ReSTRenderer(template_path).render('toc.rst_t', context)
|
|
167
188
|
write_file(name, text, opts)
|
|
168
189
|
|
|
169
190
|
|
|
170
|
-
def is_skipped_package(dirname: str, opts: Any,
|
|
191
|
+
def is_skipped_package(dirname: str, opts: Any,
|
|
192
|
+
excludes: Sequence[re.Pattern[str]] = ()) -> bool:
|
|
171
193
|
"""Check if we want to skip this module."""
|
|
172
194
|
if not path.isdir(dirname):
|
|
173
195
|
return False
|
|
@@ -182,7 +204,7 @@ def is_skipped_package(dirname: str, opts: Any, excludes: list[str] = []) -> boo
|
|
|
182
204
|
return all(is_excluded(path.join(dirname, f), excludes) for f in files)
|
|
183
205
|
|
|
184
206
|
|
|
185
|
-
def is_skipped_module(filename: str, opts: Any,
|
|
207
|
+
def is_skipped_module(filename: str, opts: Any, _excludes: Sequence[re.Pattern[str]]) -> bool:
|
|
186
208
|
"""Check if we want to skip this module."""
|
|
187
209
|
if not path.exists(filename):
|
|
188
210
|
# skip if the file doesn't exist
|
|
@@ -193,7 +215,7 @@ def is_skipped_module(filename: str, opts: Any, excludes: list[str]) -> bool:
|
|
|
193
215
|
return False
|
|
194
216
|
|
|
195
217
|
|
|
196
|
-
def walk(rootpath: str, excludes:
|
|
218
|
+
def walk(rootpath: str, excludes: Sequence[re.Pattern[str]], opts: Any,
|
|
197
219
|
) -> Generator[tuple[str, list[str], list[str]], None, None]:
|
|
198
220
|
"""Walk through the directory and list files and subdirectories up."""
|
|
199
221
|
followlinks = getattr(opts, 'followlinks', False)
|
|
@@ -218,7 +240,7 @@ def walk(rootpath: str, excludes: list[str], opts: Any,
|
|
|
218
240
|
yield root, subs, files
|
|
219
241
|
|
|
220
242
|
|
|
221
|
-
def has_child_module(rootpath: str, excludes:
|
|
243
|
+
def has_child_module(rootpath: str, excludes: Sequence[re.Pattern[str]], opts: Any) -> bool:
|
|
222
244
|
"""Check the given directory contains child module/s (at least one)."""
|
|
223
245
|
return any(
|
|
224
246
|
files
|
|
@@ -226,7 +248,7 @@ def has_child_module(rootpath: str, excludes: list[str], opts: Any) -> bool:
|
|
|
226
248
|
)
|
|
227
249
|
|
|
228
250
|
|
|
229
|
-
def recurse_tree(rootpath: str, excludes:
|
|
251
|
+
def recurse_tree(rootpath: str, excludes: Sequence[re.Pattern[str]], opts: Any,
|
|
230
252
|
user_template_dir: str | None = None) -> list[str]:
|
|
231
253
|
"""
|
|
232
254
|
Look for every file in the directory tree and create the corresponding
|
|
@@ -281,16 +303,13 @@ def recurse_tree(rootpath: str, excludes: list[str], opts: Any,
|
|
|
281
303
|
return toplevels
|
|
282
304
|
|
|
283
305
|
|
|
284
|
-
def is_excluded(root: str, excludes:
|
|
306
|
+
def is_excluded(root: str, excludes: Sequence[re.Pattern[str]]) -> bool:
|
|
285
307
|
"""Check if the directory is in the exclude list.
|
|
286
308
|
|
|
287
309
|
Note: by having trailing slashes, we avoid common prefix issues, like
|
|
288
310
|
e.g. an exclude "foo" also accidentally excluding "foobar".
|
|
289
311
|
"""
|
|
290
|
-
return any(
|
|
291
|
-
fnmatch(root, exclude)
|
|
292
|
-
for exclude in excludes
|
|
293
|
-
)
|
|
312
|
+
return any(exclude.match(root) for exclude in excludes)
|
|
294
313
|
|
|
295
314
|
|
|
296
315
|
def get_parser() -> argparse.ArgumentParser:
|
|
@@ -390,13 +409,13 @@ Note: By default this script will not overwrite already created files."""))
|
|
|
390
409
|
return parser
|
|
391
410
|
|
|
392
411
|
|
|
393
|
-
def main(argv:
|
|
412
|
+
def main(argv: Sequence[str] = (), /) -> int:
|
|
394
413
|
"""Parse and check the command line arguments."""
|
|
395
414
|
locale.setlocale(locale.LC_ALL, '')
|
|
396
415
|
sphinx.locale.init_console()
|
|
397
416
|
|
|
398
417
|
parser = get_parser()
|
|
399
|
-
args = parser.parse_args(argv)
|
|
418
|
+
args = parser.parse_args(argv or sys.argv[1:])
|
|
400
419
|
|
|
401
420
|
rootpath = path.abspath(args.module_path)
|
|
402
421
|
|
|
@@ -407,11 +426,14 @@ def main(argv: list[str] = sys.argv[1:]) -> int:
|
|
|
407
426
|
if args.suffix.startswith('.'):
|
|
408
427
|
args.suffix = args.suffix[1:]
|
|
409
428
|
if not path.isdir(rootpath):
|
|
410
|
-
|
|
429
|
+
logger.error(__('%s is not a directory.'), rootpath)
|
|
411
430
|
raise SystemExit(1)
|
|
412
431
|
if not args.dryrun:
|
|
413
432
|
ensuredir(args.destdir)
|
|
414
|
-
excludes =
|
|
433
|
+
excludes = tuple(
|
|
434
|
+
re.compile(fnmatch.translate(path.abspath(exclude)))
|
|
435
|
+
for exclude in dict.fromkeys(args.exclude_pattern)
|
|
436
|
+
)
|
|
415
437
|
modules = recurse_tree(rootpath, excludes, args, args.templatedir)
|
|
416
438
|
|
|
417
439
|
if args.full:
|
|
@@ -467,4 +489,4 @@ def main(argv: list[str] = sys.argv[1:]) -> int:
|
|
|
467
489
|
|
|
468
490
|
# So program can be started with "python -m sphinx.apidoc ..."
|
|
469
491
|
if __name__ == "__main__":
|
|
470
|
-
main()
|
|
492
|
+
raise SystemExit(main(sys.argv[1:]))
|