Sphinx 8.1.2__py3-none-any.whl → 8.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 +8 -4
- sphinx/__main__.py +2 -0
- sphinx/_cli/__init__.py +2 -5
- sphinx/_cli/util/colour.py +34 -11
- sphinx/_cli/util/errors.py +128 -61
- sphinx/addnodes.py +51 -35
- sphinx/application.py +362 -230
- sphinx/builders/__init__.py +87 -64
- sphinx/builders/_epub_base.py +65 -56
- sphinx/builders/changes.py +17 -23
- sphinx/builders/dirhtml.py +8 -13
- sphinx/builders/epub3.py +70 -38
- sphinx/builders/gettext.py +93 -73
- sphinx/builders/html/__init__.py +240 -186
- sphinx/builders/html/_assets.py +9 -2
- sphinx/builders/html/_build_info.py +3 -0
- sphinx/builders/latex/__init__.py +64 -54
- sphinx/builders/latex/constants.py +14 -11
- sphinx/builders/latex/nodes.py +2 -0
- sphinx/builders/latex/theming.py +8 -9
- sphinx/builders/latex/transforms.py +7 -5
- sphinx/builders/linkcheck.py +193 -149
- sphinx/builders/manpage.py +17 -17
- sphinx/builders/singlehtml.py +28 -16
- sphinx/builders/texinfo.py +28 -21
- sphinx/builders/text.py +10 -15
- sphinx/builders/xml.py +10 -19
- sphinx/cmd/build.py +49 -119
- sphinx/cmd/make_mode.py +35 -31
- sphinx/cmd/quickstart.py +78 -62
- sphinx/config.py +265 -163
- sphinx/directives/__init__.py +51 -54
- sphinx/directives/admonitions.py +107 -0
- sphinx/directives/code.py +24 -19
- sphinx/directives/other.py +21 -42
- sphinx/directives/patches.py +28 -16
- sphinx/domains/__init__.py +54 -31
- sphinx/domains/_domains_container.py +22 -17
- sphinx/domains/_index.py +5 -8
- sphinx/domains/c/__init__.py +366 -245
- sphinx/domains/c/_ast.py +378 -256
- sphinx/domains/c/_ids.py +89 -31
- sphinx/domains/c/_parser.py +283 -214
- sphinx/domains/c/_symbol.py +269 -198
- sphinx/domains/changeset.py +39 -24
- sphinx/domains/citation.py +54 -24
- sphinx/domains/cpp/__init__.py +517 -362
- sphinx/domains/cpp/_ast.py +999 -682
- sphinx/domains/cpp/_ids.py +133 -65
- sphinx/domains/cpp/_parser.py +746 -588
- sphinx/domains/cpp/_symbol.py +692 -489
- sphinx/domains/index.py +10 -8
- sphinx/domains/javascript.py +152 -74
- sphinx/domains/math.py +50 -40
- sphinx/domains/python/__init__.py +402 -211
- sphinx/domains/python/_annotations.py +134 -61
- sphinx/domains/python/_object.py +155 -68
- sphinx/domains/rst.py +94 -49
- sphinx/domains/std/__init__.py +510 -249
- sphinx/environment/__init__.py +345 -61
- sphinx/environment/adapters/asset.py +7 -1
- sphinx/environment/adapters/indexentries.py +15 -20
- sphinx/environment/adapters/toctree.py +19 -9
- sphinx/environment/collectors/__init__.py +3 -1
- sphinx/environment/collectors/asset.py +18 -15
- sphinx/environment/collectors/dependencies.py +8 -10
- sphinx/environment/collectors/metadata.py +6 -4
- sphinx/environment/collectors/title.py +3 -1
- sphinx/environment/collectors/toctree.py +4 -4
- sphinx/errors.py +1 -3
- sphinx/events.py +4 -4
- sphinx/ext/apidoc/__init__.py +66 -0
- sphinx/ext/apidoc/__main__.py +9 -0
- sphinx/ext/apidoc/_cli.py +356 -0
- sphinx/ext/apidoc/_extension.py +262 -0
- sphinx/ext/apidoc/_generate.py +356 -0
- sphinx/ext/apidoc/_shared.py +99 -0
- sphinx/ext/autodoc/__init__.py +837 -483
- sphinx/ext/autodoc/directive.py +57 -21
- sphinx/ext/autodoc/importer.py +184 -67
- sphinx/ext/autodoc/mock.py +25 -10
- sphinx/ext/autodoc/preserve_defaults.py +17 -9
- sphinx/ext/autodoc/type_comment.py +56 -29
- sphinx/ext/autodoc/typehints.py +49 -26
- sphinx/ext/autosectionlabel.py +28 -11
- sphinx/ext/autosummary/__init__.py +281 -142
- sphinx/ext/autosummary/generate.py +121 -51
- sphinx/ext/coverage.py +152 -91
- sphinx/ext/doctest.py +169 -101
- sphinx/ext/duration.py +12 -6
- sphinx/ext/extlinks.py +33 -21
- sphinx/ext/githubpages.py +8 -8
- sphinx/ext/graphviz.py +175 -109
- sphinx/ext/ifconfig.py +11 -6
- sphinx/ext/imgconverter.py +48 -25
- sphinx/ext/imgmath.py +127 -97
- sphinx/ext/inheritance_diagram.py +177 -103
- sphinx/ext/intersphinx/__init__.py +22 -13
- sphinx/ext/intersphinx/__main__.py +3 -1
- sphinx/ext/intersphinx/_cli.py +18 -14
- sphinx/ext/intersphinx/_load.py +91 -82
- sphinx/ext/intersphinx/_resolve.py +108 -74
- sphinx/ext/intersphinx/_shared.py +2 -2
- sphinx/ext/linkcode.py +28 -12
- sphinx/ext/mathjax.py +60 -29
- sphinx/ext/napoleon/__init__.py +19 -7
- sphinx/ext/napoleon/docstring.py +229 -231
- sphinx/ext/todo.py +44 -49
- sphinx/ext/viewcode.py +105 -57
- sphinx/extension.py +3 -1
- sphinx/highlighting.py +13 -7
- sphinx/io.py +9 -13
- sphinx/jinja2glue.py +29 -26
- sphinx/locale/__init__.py +8 -9
- sphinx/locale/ar/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/ar/LC_MESSAGES/sphinx.po +2155 -2050
- sphinx/locale/bg/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/bg/LC_MESSAGES/sphinx.po +2045 -1940
- sphinx/locale/bn/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/bn/LC_MESSAGES/sphinx.po +2175 -2070
- sphinx/locale/ca/LC_MESSAGES/sphinx.js +3 -3
- sphinx/locale/ca/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/ca/LC_MESSAGES/sphinx.po +2690 -2585
- sphinx/locale/ca@valencia/LC_MESSAGES/sphinx.js +63 -0
- sphinx/locale/ca@valencia/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/ca@valencia/LC_MESSAGES/sphinx.po +4216 -0
- sphinx/locale/cak/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/cak/LC_MESSAGES/sphinx.po +2096 -1991
- sphinx/locale/cs/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/cs/LC_MESSAGES/sphinx.po +2248 -2143
- sphinx/locale/cy/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/cy/LC_MESSAGES/sphinx.po +2201 -2096
- sphinx/locale/da/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/da/LC_MESSAGES/sphinx.po +2282 -2177
- sphinx/locale/de/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/de/LC_MESSAGES/sphinx.po +2261 -2156
- sphinx/locale/de_DE/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/de_DE/LC_MESSAGES/sphinx.po +2045 -1940
- sphinx/locale/el/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/el/LC_MESSAGES/sphinx.po +2604 -2499
- sphinx/locale/en_DE/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/en_DE/LC_MESSAGES/sphinx.po +2045 -1940
- sphinx/locale/en_FR/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/en_FR/LC_MESSAGES/sphinx.po +2045 -1940
- sphinx/locale/en_GB/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/en_GB/LC_MESSAGES/sphinx.po +2631 -2526
- sphinx/locale/en_HK/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/en_HK/LC_MESSAGES/sphinx.po +2045 -1940
- sphinx/locale/eo/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/eo/LC_MESSAGES/sphinx.po +2078 -1973
- sphinx/locale/es/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/es/LC_MESSAGES/sphinx.po +2633 -2528
- sphinx/locale/es_CO/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/es_CO/LC_MESSAGES/sphinx.po +2045 -1940
- sphinx/locale/et/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/et/LC_MESSAGES/sphinx.po +2449 -2344
- sphinx/locale/eu/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/eu/LC_MESSAGES/sphinx.po +2241 -2136
- sphinx/locale/fa/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/fa/LC_MESSAGES/sphinx.po +504 -500
- sphinx/locale/fi/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/fi/LC_MESSAGES/sphinx.po +499 -495
- sphinx/locale/fr/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/fr/LC_MESSAGES/sphinx.po +513 -509
- sphinx/locale/fr_FR/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/fr_FR/LC_MESSAGES/sphinx.po +499 -495
- sphinx/locale/gl/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/gl/LC_MESSAGES/sphinx.po +2644 -2539
- sphinx/locale/he/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/he/LC_MESSAGES/sphinx.po +499 -495
- sphinx/locale/hi/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/hi/LC_MESSAGES/sphinx.po +504 -500
- sphinx/locale/hi_IN/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/hi_IN/LC_MESSAGES/sphinx.po +499 -495
- sphinx/locale/hr/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/hr/LC_MESSAGES/sphinx.po +501 -497
- sphinx/locale/hu/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/hu/LC_MESSAGES/sphinx.po +499 -495
- sphinx/locale/id/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/id/LC_MESSAGES/sphinx.po +2609 -2504
- sphinx/locale/is/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/is/LC_MESSAGES/sphinx.po +499 -495
- sphinx/locale/it/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/it/LC_MESSAGES/sphinx.po +2265 -2160
- sphinx/locale/ja/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/ja/LC_MESSAGES/sphinx.po +2621 -2516
- sphinx/locale/ka/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/ka/LC_MESSAGES/sphinx.po +2567 -2462
- sphinx/locale/ko/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/ko/LC_MESSAGES/sphinx.po +2631 -2526
- sphinx/locale/lt/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/lt/LC_MESSAGES/sphinx.po +2214 -2109
- sphinx/locale/lv/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/lv/LC_MESSAGES/sphinx.po +2218 -2113
- sphinx/locale/mk/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/mk/LC_MESSAGES/sphinx.po +2088 -1983
- sphinx/locale/nb_NO/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/nb_NO/LC_MESSAGES/sphinx.po +2247 -2142
- sphinx/locale/ne/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/ne/LC_MESSAGES/sphinx.po +2227 -2122
- sphinx/locale/nl/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/nl/LC_MESSAGES/sphinx.po +2316 -2211
- sphinx/locale/pl/LC_MESSAGES/sphinx.js +2 -2
- sphinx/locale/pl/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/pl/LC_MESSAGES/sphinx.po +2442 -2336
- sphinx/locale/pt/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/pt/LC_MESSAGES/sphinx.po +2045 -1940
- sphinx/locale/pt_BR/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/pt_BR/LC_MESSAGES/sphinx.po +2657 -2552
- sphinx/locale/pt_PT/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/pt_PT/LC_MESSAGES/sphinx.po +2243 -2138
- sphinx/locale/ro/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/ro/LC_MESSAGES/sphinx.po +2244 -2139
- sphinx/locale/ru/LC_MESSAGES/sphinx.js +1 -1
- sphinx/locale/ru/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/ru/LC_MESSAGES/sphinx.po +2660 -2555
- sphinx/locale/si/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/si/LC_MESSAGES/sphinx.po +2134 -2029
- sphinx/locale/sk/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/sk/LC_MESSAGES/sphinx.po +2614 -2509
- sphinx/locale/sl/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/sl/LC_MESSAGES/sphinx.po +2167 -2062
- sphinx/locale/sphinx.pot +2069 -1964
- sphinx/locale/sq/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/sq/LC_MESSAGES/sphinx.po +2661 -2556
- sphinx/locale/sr/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/sr/LC_MESSAGES/sphinx.po +2213 -2108
- sphinx/locale/sv/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/sv/LC_MESSAGES/sphinx.po +2229 -2124
- sphinx/locale/te/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/te/LC_MESSAGES/sphinx.po +2045 -1940
- sphinx/locale/tr/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/tr/LC_MESSAGES/sphinx.po +2608 -2503
- sphinx/locale/uk_UA/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/uk_UA/LC_MESSAGES/sphinx.po +2167 -2062
- sphinx/locale/ur/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/ur/LC_MESSAGES/sphinx.po +2045 -1940
- sphinx/locale/vi/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/vi/LC_MESSAGES/sphinx.po +2204 -2099
- sphinx/locale/yue/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/yue/LC_MESSAGES/sphinx.po +2045 -1940
- sphinx/locale/zh_HK/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/zh_HK/LC_MESSAGES/sphinx.po +2045 -1940
- sphinx/locale/zh_TW/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/zh_TW/LC_MESSAGES/sphinx.po +2659 -2554
- sphinx/locale/zh_TW.Big5/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/zh_TW.Big5/LC_MESSAGES/sphinx.po +2045 -1940
- sphinx/parsers.py +8 -7
- sphinx/project.py +2 -2
- sphinx/pycode/__init__.py +31 -21
- sphinx/pycode/ast.py +6 -3
- sphinx/pycode/parser.py +14 -8
- sphinx/pygments_styles.py +4 -5
- sphinx/registry.py +192 -92
- sphinx/roles.py +58 -7
- sphinx/search/__init__.py +75 -54
- sphinx/search/en.py +11 -13
- sphinx/search/fi.py +1 -1
- sphinx/search/ja.py +8 -6
- sphinx/search/nl.py +1 -1
- sphinx/search/zh.py +19 -21
- sphinx/testing/fixtures.py +26 -29
- sphinx/testing/path.py +26 -62
- sphinx/testing/restructuredtext.py +14 -8
- sphinx/testing/util.py +21 -19
- sphinx/texinputs/make.bat.jinja +50 -50
- sphinx/texinputs/sphinx.sty +4 -3
- sphinx/texinputs/sphinxlatexadmonitions.sty +1 -1
- sphinx/texinputs/sphinxlatexobjects.sty +29 -10
- sphinx/themes/basic/static/searchtools.js +8 -5
- sphinx/theming.py +49 -61
- sphinx/transforms/__init__.py +17 -38
- sphinx/transforms/compact_bullet_list.py +5 -3
- sphinx/transforms/i18n.py +8 -21
- sphinx/transforms/post_transforms/__init__.py +142 -93
- sphinx/transforms/post_transforms/code.py +5 -5
- sphinx/transforms/post_transforms/images.py +28 -24
- sphinx/transforms/references.py +3 -1
- sphinx/util/__init__.py +109 -60
- sphinx/util/_files.py +39 -23
- sphinx/util/_importer.py +4 -1
- sphinx/util/_inventory_file_reader.py +76 -0
- sphinx/util/_io.py +2 -2
- sphinx/util/_lines.py +6 -3
- sphinx/util/_pathlib.py +40 -2
- sphinx/util/build_phase.py +2 -0
- sphinx/util/cfamily.py +19 -14
- sphinx/util/console.py +44 -179
- sphinx/util/display.py +9 -10
- sphinx/util/docfields.py +140 -122
- sphinx/util/docstrings.py +1 -1
- sphinx/util/docutils.py +118 -77
- sphinx/util/fileutil.py +25 -26
- sphinx/util/http_date.py +2 -0
- sphinx/util/i18n.py +77 -64
- sphinx/util/images.py +8 -6
- sphinx/util/inspect.py +147 -38
- sphinx/util/inventory.py +215 -116
- sphinx/util/logging.py +33 -33
- sphinx/util/matching.py +12 -4
- sphinx/util/nodes.py +18 -13
- sphinx/util/osutil.py +38 -39
- sphinx/util/parallel.py +22 -13
- sphinx/util/parsing.py +2 -1
- sphinx/util/png.py +6 -2
- sphinx/util/requests.py +33 -2
- sphinx/util/rst.py +3 -2
- sphinx/util/tags.py +1 -1
- sphinx/util/template.py +18 -10
- sphinx/util/texescape.py +8 -6
- sphinx/util/typing.py +148 -122
- sphinx/versioning.py +3 -3
- sphinx/writers/html.py +3 -1
- sphinx/writers/html5.py +63 -52
- sphinx/writers/latex.py +83 -67
- sphinx/writers/manpage.py +19 -38
- sphinx/writers/texinfo.py +47 -47
- sphinx/writers/text.py +50 -32
- sphinx/writers/xml.py +11 -8
- {sphinx-8.1.2.dist-info → sphinx-8.2.0.dist-info}/LICENSE.rst +1 -1
- {sphinx-8.1.2.dist-info → sphinx-8.2.0.dist-info}/METADATA +25 -15
- sphinx-8.2.0.dist-info/RECORD +606 -0
- {sphinx-8.1.2.dist-info → sphinx-8.2.0.dist-info}/WHEEL +1 -1
- sphinx/builders/html/transforms.py +0 -90
- sphinx/ext/apidoc.py +0 -721
- sphinx/util/exceptions.py +0 -74
- sphinx-8.1.2.dist-info/RECORD +0 -598
- {sphinx-8.1.2.dist-info → sphinx-8.2.0.dist-info}/entry_points.txt +0 -0
sphinx/builders/singlehtml.py
CHANGED
|
@@ -2,21 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
from typing import TYPE_CHECKING
|
|
5
|
+
import warnings
|
|
6
|
+
from typing import TYPE_CHECKING
|
|
7
7
|
|
|
8
8
|
from docutils import nodes
|
|
9
9
|
|
|
10
|
+
from sphinx._cli.util.colour import darkgreen
|
|
10
11
|
from sphinx.builders.html import StandaloneHTMLBuilder
|
|
12
|
+
from sphinx.deprecation import RemovedInSphinx10Warning
|
|
11
13
|
from sphinx.environment.adapters.toctree import global_toctree_for_doc
|
|
12
14
|
from sphinx.locale import __
|
|
13
15
|
from sphinx.util import logging
|
|
14
|
-
from sphinx.util.console import darkgreen
|
|
15
16
|
from sphinx.util.display import progress_message
|
|
16
17
|
from sphinx.util.nodes import inline_all_toctrees
|
|
17
18
|
|
|
18
19
|
if TYPE_CHECKING:
|
|
19
20
|
from collections.abc import Set
|
|
21
|
+
from typing import Any
|
|
20
22
|
|
|
21
23
|
from docutils.nodes import Node
|
|
22
24
|
|
|
@@ -27,10 +29,7 @@ logger = logging.getLogger(__name__)
|
|
|
27
29
|
|
|
28
30
|
|
|
29
31
|
class SingleFileHTMLBuilder(StandaloneHTMLBuilder):
|
|
30
|
-
"""
|
|
31
|
-
A StandaloneHTMLBuilder subclass that puts the whole document tree on one
|
|
32
|
-
HTML page.
|
|
33
|
-
"""
|
|
32
|
+
"""Builds the whole document tree as a single HTML page."""
|
|
34
33
|
|
|
35
34
|
name = 'singlehtml'
|
|
36
35
|
epilog = __('The HTML page is in %(outdir)s.')
|
|
@@ -53,6 +52,14 @@ class SingleFileHTMLBuilder(StandaloneHTMLBuilder):
|
|
|
53
52
|
return self.get_target_uri(to, typ)
|
|
54
53
|
|
|
55
54
|
def fix_refuris(self, tree: Node) -> None:
|
|
55
|
+
deprecation_msg = (
|
|
56
|
+
"The 'SingleFileHTMLBuilder.fix_refuris' method is no longer used "
|
|
57
|
+
'within the builder and is planned for removal in Sphinx 10. '
|
|
58
|
+
'Please report malformed URIs generated by the Sphinx singlehtml '
|
|
59
|
+
'builder as bugreports.'
|
|
60
|
+
)
|
|
61
|
+
warnings.warn(deprecation_msg, RemovedInSphinx10Warning, stacklevel=2)
|
|
62
|
+
|
|
56
63
|
# fix refuris with double anchor
|
|
57
64
|
for refnode in tree.findall(nodes.reference):
|
|
58
65
|
if 'refuri' not in refnode:
|
|
@@ -74,13 +81,11 @@ class SingleFileHTMLBuilder(StandaloneHTMLBuilder):
|
|
|
74
81
|
kwargs['includehidden'] = False
|
|
75
82
|
elif includehidden.lower() == 'true':
|
|
76
83
|
kwargs['includehidden'] = True
|
|
77
|
-
if kwargs.get('maxdepth') == '':
|
|
84
|
+
if kwargs.get('maxdepth') == '': # NoQA: PLC1901
|
|
78
85
|
kwargs.pop('maxdepth')
|
|
79
86
|
toctree = global_toctree_for_doc(
|
|
80
87
|
self.env, docname, self, collapse=collapse, **kwargs
|
|
81
88
|
)
|
|
82
|
-
if toctree is not None:
|
|
83
|
-
self.fix_refuris(toctree)
|
|
84
89
|
return self.render_partial(toctree)['fragment']
|
|
85
90
|
|
|
86
91
|
def assemble_doctree(self) -> nodes.document:
|
|
@@ -90,7 +95,6 @@ class SingleFileHTMLBuilder(StandaloneHTMLBuilder):
|
|
|
90
95
|
tree = inline_all_toctrees(self, set(), master, tree, darkgreen, [master])
|
|
91
96
|
tree['docname'] = master
|
|
92
97
|
self.env.resolve_references(tree, master, self)
|
|
93
|
-
self.fix_refuris(tree)
|
|
94
98
|
return tree
|
|
95
99
|
|
|
96
100
|
def assemble_toc_secnumbers(self) -> dict[str, dict[str, tuple[int, ...]]]:
|
|
@@ -141,7 +145,6 @@ class SingleFileHTMLBuilder(StandaloneHTMLBuilder):
|
|
|
141
145
|
)
|
|
142
146
|
# if there is no toctree, toc is None
|
|
143
147
|
if toctree:
|
|
144
|
-
self.fix_refuris(toctree)
|
|
145
148
|
toc = self.render_partial(toctree)['fragment']
|
|
146
149
|
display_toc = True
|
|
147
150
|
else:
|
|
@@ -189,20 +192,29 @@ class SingleFileHTMLBuilder(StandaloneHTMLBuilder):
|
|
|
189
192
|
|
|
190
193
|
# additional pages from conf.py
|
|
191
194
|
for pagename, template in self.config.html_additional_pages.items():
|
|
192
|
-
logger.info(' '
|
|
195
|
+
logger.info(' %s', pagename, nonl=True)
|
|
193
196
|
self.handle_page(pagename, {}, template)
|
|
194
197
|
|
|
195
198
|
if self.config.html_use_opensearch:
|
|
196
199
|
logger.info(' opensearch', nonl=True)
|
|
197
|
-
|
|
198
|
-
|
|
200
|
+
self.handle_page(
|
|
201
|
+
'opensearch',
|
|
202
|
+
{},
|
|
203
|
+
'opensearch.xml',
|
|
204
|
+
outfilename=self._static_dir / 'opensearch.xml',
|
|
205
|
+
)
|
|
199
206
|
|
|
200
207
|
|
|
201
208
|
def setup(app: Sphinx) -> ExtensionMetadata:
|
|
202
209
|
app.setup_extension('sphinx.builders.html')
|
|
203
210
|
|
|
204
211
|
app.add_builder(SingleFileHTMLBuilder)
|
|
205
|
-
app.add_config_value(
|
|
212
|
+
app.add_config_value(
|
|
213
|
+
'singlehtml_sidebars',
|
|
214
|
+
lambda self: self.html_sidebars,
|
|
215
|
+
'html',
|
|
216
|
+
types=frozenset({dict}),
|
|
217
|
+
)
|
|
206
218
|
|
|
207
219
|
return {
|
|
208
220
|
'version': 'builtin',
|
sphinx/builders/texinfo.py
CHANGED
|
@@ -2,22 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
-
import os
|
|
5
|
+
import os.path
|
|
6
6
|
import warnings
|
|
7
|
-
from
|
|
8
|
-
from typing import TYPE_CHECKING, Any
|
|
7
|
+
from typing import TYPE_CHECKING
|
|
9
8
|
|
|
10
9
|
from docutils import nodes
|
|
11
10
|
from docutils.frontend import OptionParser
|
|
12
11
|
from docutils.io import FileOutput
|
|
13
12
|
|
|
14
13
|
from sphinx import addnodes, package_dir
|
|
14
|
+
from sphinx._cli.util.colour import darkgreen
|
|
15
15
|
from sphinx.builders import Builder
|
|
16
16
|
from sphinx.environment.adapters.asset import ImageAdapter
|
|
17
17
|
from sphinx.errors import NoUri
|
|
18
18
|
from sphinx.locale import _, __
|
|
19
19
|
from sphinx.util import logging
|
|
20
|
-
from sphinx.util.console import darkgreen
|
|
21
20
|
from sphinx.util.display import progress_message, status_iterator
|
|
22
21
|
from sphinx.util.docutils import new_document
|
|
23
22
|
from sphinx.util.nodes import inline_all_toctrees
|
|
@@ -26,6 +25,7 @@ from sphinx.writers.texinfo import TexinfoTranslator, TexinfoWriter
|
|
|
26
25
|
|
|
27
26
|
if TYPE_CHECKING:
|
|
28
27
|
from collections.abc import Iterable, Set
|
|
28
|
+
from typing import Any
|
|
29
29
|
|
|
30
30
|
from docutils.nodes import Node
|
|
31
31
|
|
|
@@ -34,13 +34,11 @@ if TYPE_CHECKING:
|
|
|
34
34
|
from sphinx.util.typing import ExtensionMetadata
|
|
35
35
|
|
|
36
36
|
logger = logging.getLogger(__name__)
|
|
37
|
-
template_dir =
|
|
37
|
+
template_dir = package_dir.joinpath('templates', 'texinfo')
|
|
38
38
|
|
|
39
39
|
|
|
40
40
|
class TexinfoBuilder(Builder):
|
|
41
|
-
"""
|
|
42
|
-
Builds Texinfo output to create Info documentation.
|
|
43
|
-
"""
|
|
41
|
+
"""Builds Texinfo output to create Info documentation."""
|
|
44
42
|
|
|
45
43
|
name = 'texinfo'
|
|
46
44
|
format = 'texinfo'
|
|
@@ -109,7 +107,8 @@ class TexinfoBuilder(Builder):
|
|
|
109
107
|
if len(entry) > 7:
|
|
110
108
|
toctree_only = entry[7]
|
|
111
109
|
destination = FileOutput(
|
|
112
|
-
destination_path=
|
|
110
|
+
destination_path=self.outdir / targetname,
|
|
111
|
+
encoding='utf-8',
|
|
113
112
|
)
|
|
114
113
|
with progress_message(__('processing %s') % targetname, nonl=False):
|
|
115
114
|
appendices = self.config.texinfo_appendices or []
|
|
@@ -185,8 +184,6 @@ class TexinfoBuilder(Builder):
|
|
|
185
184
|
nodes.Text(')'),
|
|
186
185
|
))
|
|
187
186
|
break
|
|
188
|
-
else:
|
|
189
|
-
pass
|
|
190
187
|
pendingnode.replace_self(newnodes)
|
|
191
188
|
return largetree
|
|
192
189
|
|
|
@@ -195,7 +192,7 @@ class TexinfoBuilder(Builder):
|
|
|
195
192
|
|
|
196
193
|
def copy_image_files(self, targetname: str) -> None:
|
|
197
194
|
if self.images:
|
|
198
|
-
stringify_func = ImageAdapter(self.
|
|
195
|
+
stringify_func = ImageAdapter(self.env).get_original_image_uri
|
|
199
196
|
for src in status_iterator(
|
|
200
197
|
self.images,
|
|
201
198
|
__('copying images... '),
|
|
@@ -216,7 +213,7 @@ class TexinfoBuilder(Builder):
|
|
|
216
213
|
except Exception as err:
|
|
217
214
|
logger.warning(
|
|
218
215
|
__('cannot copy image file %r: %s'),
|
|
219
|
-
|
|
216
|
+
self.srcdir / src,
|
|
220
217
|
err,
|
|
221
218
|
)
|
|
222
219
|
|
|
@@ -225,7 +222,7 @@ class TexinfoBuilder(Builder):
|
|
|
225
222
|
with progress_message(__('copying Texinfo support files')):
|
|
226
223
|
logger.info('Makefile ', nonl=True)
|
|
227
224
|
copyfile(
|
|
228
|
-
|
|
225
|
+
template_dir / 'Makefile',
|
|
229
226
|
self.outdir / 'Makefile',
|
|
230
227
|
force=True,
|
|
231
228
|
)
|
|
@@ -254,13 +251,23 @@ def default_texinfo_documents(
|
|
|
254
251
|
def setup(app: Sphinx) -> ExtensionMetadata:
|
|
255
252
|
app.add_builder(TexinfoBuilder)
|
|
256
253
|
|
|
257
|
-
app.add_config_value(
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
app.add_config_value('
|
|
254
|
+
app.add_config_value(
|
|
255
|
+
'texinfo_documents',
|
|
256
|
+
default_texinfo_documents,
|
|
257
|
+
'',
|
|
258
|
+
types=frozenset({list, tuple}),
|
|
259
|
+
)
|
|
260
|
+
app.add_config_value('texinfo_appendices', [], '', types=frozenset({list, tuple}))
|
|
261
|
+
app.add_config_value('texinfo_elements', {}, '', types=frozenset({dict}))
|
|
262
|
+
app.add_config_value(
|
|
263
|
+
'texinfo_domain_indices',
|
|
264
|
+
True,
|
|
265
|
+
'',
|
|
266
|
+
types=frozenset({frozenset, list, set, tuple}),
|
|
267
|
+
)
|
|
268
|
+
app.add_config_value('texinfo_show_urls', 'footnote', '', types=frozenset({str}))
|
|
269
|
+
app.add_config_value('texinfo_no_detailmenu', False, '', types=frozenset({bool}))
|
|
270
|
+
app.add_config_value('texinfo_cross_references', True, '', types=frozenset({bool}))
|
|
264
271
|
|
|
265
272
|
return {
|
|
266
273
|
'version': 'builtin',
|
sphinx/builders/text.py
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
-
from os import path
|
|
6
5
|
from typing import TYPE_CHECKING
|
|
7
6
|
|
|
8
7
|
from docutils.io import StringOutput
|
|
@@ -10,11 +9,7 @@ from docutils.io import StringOutput
|
|
|
10
9
|
from sphinx.builders import Builder
|
|
11
10
|
from sphinx.locale import __
|
|
12
11
|
from sphinx.util import logging
|
|
13
|
-
from sphinx.util.osutil import
|
|
14
|
-
_last_modified_time,
|
|
15
|
-
ensuredir,
|
|
16
|
-
os_path,
|
|
17
|
-
)
|
|
12
|
+
from sphinx.util.osutil import _last_modified_time
|
|
18
13
|
from sphinx.writers.text import TextTranslator, TextWriter
|
|
19
14
|
|
|
20
15
|
if TYPE_CHECKING:
|
|
@@ -48,7 +43,7 @@ class TextBuilder(Builder):
|
|
|
48
43
|
if docname not in self.env.all_docs:
|
|
49
44
|
yield docname
|
|
50
45
|
continue
|
|
51
|
-
targetname =
|
|
46
|
+
targetname = self.outdir / (docname + self.out_suffix)
|
|
52
47
|
try:
|
|
53
48
|
targetmtime = _last_modified_time(targetname)
|
|
54
49
|
except Exception:
|
|
@@ -72,13 +67,13 @@ class TextBuilder(Builder):
|
|
|
72
67
|
self.secnumbers = self.env.toc_secnumbers.get(docname, {})
|
|
73
68
|
destination = StringOutput(encoding='utf-8')
|
|
74
69
|
self.writer.write(doctree, destination)
|
|
75
|
-
|
|
76
|
-
|
|
70
|
+
out_file_name = self.outdir / (docname + self.out_suffix)
|
|
71
|
+
out_file_name.parent.mkdir(parents=True, exist_ok=True)
|
|
77
72
|
try:
|
|
78
|
-
with open(
|
|
73
|
+
with open(out_file_name, 'w', encoding='utf-8') as f:
|
|
79
74
|
f.write(self.writer.output)
|
|
80
75
|
except OSError as err:
|
|
81
|
-
logger.warning(__('error writing file %s: %s'),
|
|
76
|
+
logger.warning(__('error writing file %s: %s'), out_file_name, err)
|
|
82
77
|
|
|
83
78
|
def finish(self) -> None:
|
|
84
79
|
pass
|
|
@@ -87,10 +82,10 @@ class TextBuilder(Builder):
|
|
|
87
82
|
def setup(app: Sphinx) -> ExtensionMetadata:
|
|
88
83
|
app.add_builder(TextBuilder)
|
|
89
84
|
|
|
90
|
-
app.add_config_value('text_sectionchars', '*=-~"+`', 'env')
|
|
91
|
-
app.add_config_value('text_newlines', 'unix', 'env')
|
|
92
|
-
app.add_config_value('text_add_secnumbers', True, 'env')
|
|
93
|
-
app.add_config_value('text_secnumber_suffix', '. ', 'env')
|
|
85
|
+
app.add_config_value('text_sectionchars', '*=-~"+`', 'env', types=frozenset({str}))
|
|
86
|
+
app.add_config_value('text_newlines', 'unix', 'env', types=frozenset({str}))
|
|
87
|
+
app.add_config_value('text_add_secnumbers', True, 'env', types=frozenset({bool}))
|
|
88
|
+
app.add_config_value('text_secnumber_suffix', '. ', 'env', types=frozenset({str}))
|
|
94
89
|
|
|
95
90
|
return {
|
|
96
91
|
'version': 'builtin',
|
sphinx/builders/xml.py
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
-
from os import path
|
|
6
5
|
from typing import TYPE_CHECKING
|
|
7
6
|
|
|
8
7
|
from docutils import nodes
|
|
@@ -12,11 +11,7 @@ from docutils.writers.docutils_xml import XMLTranslator
|
|
|
12
11
|
from sphinx.builders import Builder
|
|
13
12
|
from sphinx.locale import __
|
|
14
13
|
from sphinx.util import logging
|
|
15
|
-
from sphinx.util.osutil import
|
|
16
|
-
_last_modified_time,
|
|
17
|
-
ensuredir,
|
|
18
|
-
os_path,
|
|
19
|
-
)
|
|
14
|
+
from sphinx.util.osutil import _last_modified_time
|
|
20
15
|
from sphinx.writers.xml import PseudoXMLWriter, XMLWriter
|
|
21
16
|
|
|
22
17
|
if TYPE_CHECKING:
|
|
@@ -29,9 +24,7 @@ logger = logging.getLogger(__name__)
|
|
|
29
24
|
|
|
30
25
|
|
|
31
26
|
class XMLBuilder(Builder):
|
|
32
|
-
"""
|
|
33
|
-
Builds Docutils-native XML.
|
|
34
|
-
"""
|
|
27
|
+
"""Builds Docutils-native XML."""
|
|
35
28
|
|
|
36
29
|
name = 'xml'
|
|
37
30
|
format = 'xml'
|
|
@@ -40,7 +33,7 @@ class XMLBuilder(Builder):
|
|
|
40
33
|
out_suffix = '.xml'
|
|
41
34
|
allow_parallel = True
|
|
42
35
|
|
|
43
|
-
_writer_class: type[XMLWriter
|
|
36
|
+
_writer_class: type[XMLWriter | PseudoXMLWriter] = XMLWriter
|
|
44
37
|
writer: XMLWriter | PseudoXMLWriter
|
|
45
38
|
default_translator_class = XMLTranslator
|
|
46
39
|
|
|
@@ -52,7 +45,7 @@ class XMLBuilder(Builder):
|
|
|
52
45
|
if docname not in self.env.all_docs:
|
|
53
46
|
yield docname
|
|
54
47
|
continue
|
|
55
|
-
targetname =
|
|
48
|
+
targetname = self.outdir / (docname + self.out_suffix)
|
|
56
49
|
try:
|
|
57
50
|
targetmtime = _last_modified_time(targetname)
|
|
58
51
|
except Exception:
|
|
@@ -88,22 +81,20 @@ class XMLBuilder(Builder):
|
|
|
88
81
|
value[i] = list(val)
|
|
89
82
|
destination = StringOutput(encoding='utf-8')
|
|
90
83
|
self.writer.write(doctree, destination)
|
|
91
|
-
|
|
92
|
-
|
|
84
|
+
out_file_name = self.outdir / (docname + self.out_suffix)
|
|
85
|
+
out_file_name.parent.mkdir(parents=True, exist_ok=True)
|
|
93
86
|
try:
|
|
94
|
-
with open(
|
|
87
|
+
with open(out_file_name, 'w', encoding='utf-8') as f:
|
|
95
88
|
f.write(self.writer.output)
|
|
96
89
|
except OSError as err:
|
|
97
|
-
logger.warning(__('error writing file %s: %s'),
|
|
90
|
+
logger.warning(__('error writing file %s: %s'), out_file_name, err)
|
|
98
91
|
|
|
99
92
|
def finish(self) -> None:
|
|
100
93
|
pass
|
|
101
94
|
|
|
102
95
|
|
|
103
96
|
class PseudoXMLBuilder(XMLBuilder):
|
|
104
|
-
"""
|
|
105
|
-
Builds pseudo-XML for display purposes.
|
|
106
|
-
"""
|
|
97
|
+
"""Builds pseudo-XML for display purposes."""
|
|
107
98
|
|
|
108
99
|
name = 'pseudoxml'
|
|
109
100
|
format = 'pseudoxml'
|
|
@@ -118,7 +109,7 @@ def setup(app: Sphinx) -> ExtensionMetadata:
|
|
|
118
109
|
app.add_builder(XMLBuilder)
|
|
119
110
|
app.add_builder(PseudoXMLBuilder)
|
|
120
111
|
|
|
121
|
-
app.add_config_value('xml_pretty', True, 'env')
|
|
112
|
+
app.add_config_value('xml_pretty', True, 'env', types=frozenset({bool}))
|
|
122
113
|
|
|
123
114
|
return {
|
|
124
115
|
'version': 'builtin',
|
sphinx/cmd/build.py
CHANGED
|
@@ -3,36 +3,29 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
5
|
import argparse
|
|
6
|
-
import bdb
|
|
7
6
|
import contextlib
|
|
8
7
|
import locale
|
|
9
8
|
import multiprocessing
|
|
10
|
-
import os
|
|
11
|
-
import pdb # NoQA: T100
|
|
12
9
|
import sys
|
|
13
|
-
import
|
|
14
|
-
from
|
|
15
|
-
from typing import TYPE_CHECKING, Any, TextIO
|
|
16
|
-
|
|
17
|
-
from docutils.utils import SystemMessage
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
from typing import TYPE_CHECKING
|
|
18
12
|
|
|
13
|
+
import sphinx._cli.util.errors
|
|
19
14
|
import sphinx.locale
|
|
20
15
|
from sphinx import __display_version__
|
|
16
|
+
from sphinx._cli.util.colour import disable_colour, terminal_supports_colour
|
|
21
17
|
from sphinx.application import Sphinx
|
|
22
|
-
from sphinx.errors import SphinxError, SphinxParallelError
|
|
23
18
|
from sphinx.locale import __
|
|
24
19
|
from sphinx.util._io import TeeStripANSI
|
|
25
|
-
from sphinx.util.
|
|
20
|
+
from sphinx.util._pathlib import _StrPath
|
|
26
21
|
from sphinx.util.docutils import docutils_namespace, patch_docutils
|
|
27
|
-
from sphinx.util.exceptions import format_exception_cut_frames, save_traceback
|
|
28
22
|
from sphinx.util.osutil import ensuredir
|
|
29
23
|
|
|
30
24
|
if TYPE_CHECKING:
|
|
31
|
-
from collections.abc import Sequence
|
|
32
|
-
from typing import
|
|
25
|
+
from collections.abc import Collection, Sequence
|
|
26
|
+
from typing import Any, TextIO
|
|
33
27
|
|
|
34
|
-
|
|
35
|
-
def write(self, text: str, /) -> int | None: ... # NoQA: E704
|
|
28
|
+
from sphinx.extension import Extension
|
|
36
29
|
|
|
37
30
|
|
|
38
31
|
def handle_exception(
|
|
@@ -41,99 +34,26 @@ def handle_exception(
|
|
|
41
34
|
exception: BaseException,
|
|
42
35
|
stderr: TextIO = sys.stderr,
|
|
43
36
|
) -> None:
|
|
44
|
-
if
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
if args.pdb:
|
|
48
|
-
print(
|
|
49
|
-
red(__('Exception occurred while building, starting debugger:')),
|
|
50
|
-
file=stderr,
|
|
51
|
-
)
|
|
52
|
-
traceback.print_exc()
|
|
53
|
-
pdb.post_mortem(sys.exc_info()[2])
|
|
37
|
+
if app is not None:
|
|
38
|
+
message_log: Sequence[str] = app.messagelog
|
|
39
|
+
extensions: Collection[Extension] = app.extensions.values()
|
|
54
40
|
else:
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
if isinstance(exception, KeyboardInterrupt):
|
|
65
|
-
print(__('Interrupted!'), file=stderr)
|
|
66
|
-
elif isinstance(exception, SystemMessage):
|
|
67
|
-
print(red(__('reST markup error:')), file=stderr)
|
|
68
|
-
print(terminal_safe(exception.args[0]), file=stderr)
|
|
69
|
-
elif isinstance(exception, SphinxError):
|
|
70
|
-
print(red('%s:' % exception.category), file=stderr)
|
|
71
|
-
print(str(exception), file=stderr)
|
|
72
|
-
elif isinstance(exception, UnicodeError):
|
|
73
|
-
print(red(__('Encoding error:')), file=stderr)
|
|
74
|
-
print(terminal_safe(str(exception)), file=stderr)
|
|
75
|
-
tbpath = save_traceback(app, exception)
|
|
76
|
-
print(
|
|
77
|
-
red(
|
|
78
|
-
__(
|
|
79
|
-
'The full traceback has been saved in %s, if you want '
|
|
80
|
-
'to report the issue to the developers.'
|
|
81
|
-
)
|
|
82
|
-
% tbpath
|
|
83
|
-
),
|
|
84
|
-
file=stderr,
|
|
85
|
-
)
|
|
86
|
-
elif (
|
|
87
|
-
isinstance(exception, RuntimeError)
|
|
88
|
-
and 'recursion depth' in str(exception)
|
|
89
|
-
): # fmt: skip
|
|
90
|
-
print(red(__('Recursion error:')), file=stderr)
|
|
91
|
-
print(terminal_safe(str(exception)), file=stderr)
|
|
92
|
-
print(file=stderr)
|
|
93
|
-
print(
|
|
94
|
-
__(
|
|
95
|
-
'This can happen with very large or deeply nested source '
|
|
96
|
-
'files. You can carefully increase the default Python '
|
|
97
|
-
'recursion limit of 1000 in conf.py with e.g.:'
|
|
98
|
-
),
|
|
99
|
-
file=stderr,
|
|
100
|
-
)
|
|
101
|
-
print(' import sys; sys.setrecursionlimit(1500)', file=stderr)
|
|
102
|
-
else:
|
|
103
|
-
print(red(__('Exception occurred:')), file=stderr)
|
|
104
|
-
print(format_exception_cut_frames().rstrip(), file=stderr)
|
|
105
|
-
tbpath = save_traceback(app, exception)
|
|
106
|
-
print(
|
|
107
|
-
red(
|
|
108
|
-
__(
|
|
109
|
-
'The full traceback has been saved in %s, if you '
|
|
110
|
-
'want to report the issue to the developers.'
|
|
111
|
-
)
|
|
112
|
-
% tbpath
|
|
113
|
-
),
|
|
114
|
-
file=stderr,
|
|
115
|
-
)
|
|
116
|
-
print(
|
|
117
|
-
__(
|
|
118
|
-
'Please also report this if it was a user error, so '
|
|
119
|
-
'that a better error message can be provided next time.'
|
|
120
|
-
),
|
|
121
|
-
file=stderr,
|
|
122
|
-
)
|
|
123
|
-
print(
|
|
124
|
-
__(
|
|
125
|
-
'A bug report can be filed in the tracker at '
|
|
126
|
-
'<https://github.com/sphinx-doc/sphinx/issues>. Thanks!'
|
|
127
|
-
),
|
|
128
|
-
file=stderr,
|
|
129
|
-
)
|
|
41
|
+
message_log = extensions = ()
|
|
42
|
+
return sphinx._cli.util.errors.handle_exception(
|
|
43
|
+
exception,
|
|
44
|
+
stderr=stderr,
|
|
45
|
+
use_pdb=args.pdb,
|
|
46
|
+
print_traceback=args.verbosity or args.traceback,
|
|
47
|
+
message_log=message_log,
|
|
48
|
+
extensions=extensions,
|
|
49
|
+
)
|
|
130
50
|
|
|
131
51
|
|
|
132
52
|
def jobs_argument(value: str) -> int:
|
|
133
|
-
"""
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
53
|
+
"""Parse the ``--jobs`` flag.
|
|
54
|
+
|
|
55
|
+
Return the number of CPUs if 'auto' is used,
|
|
56
|
+
otherwise ensure *value* is a positive integer.
|
|
137
57
|
"""
|
|
138
58
|
if value == 'auto':
|
|
139
59
|
return multiprocessing.cpu_count()
|
|
@@ -217,14 +137,14 @@ files can be built by specifying individual filenames.
|
|
|
217
137
|
'-a',
|
|
218
138
|
action='store_true',
|
|
219
139
|
dest='force_all',
|
|
220
|
-
help=__('write all files (default: only write new and
|
|
140
|
+
help=__('write all files (default: only write new and changed files)'),
|
|
221
141
|
)
|
|
222
142
|
group.add_argument(
|
|
223
143
|
'--fresh-env',
|
|
224
144
|
'-E',
|
|
225
145
|
action='store_true',
|
|
226
146
|
dest='freshenv',
|
|
227
|
-
help=__("don't use a saved environment, always read
|
|
147
|
+
help=__("don't use a saved environment, always read all files"),
|
|
228
148
|
)
|
|
229
149
|
|
|
230
150
|
group = parser.add_argument_group(__('path options'))
|
|
@@ -243,9 +163,7 @@ files can be built by specifying individual filenames.
|
|
|
243
163
|
'-c',
|
|
244
164
|
metavar='PATH',
|
|
245
165
|
dest='confdir',
|
|
246
|
-
help=__(
|
|
247
|
-
'directory for the configuration file (conf.py) ' '(default: SOURCE_DIR)'
|
|
248
|
-
),
|
|
166
|
+
help=__('directory for the configuration file (conf.py) (default: SOURCE_DIR)'),
|
|
249
167
|
)
|
|
250
168
|
|
|
251
169
|
group = parser.add_argument_group('build configuration options')
|
|
@@ -392,10 +310,10 @@ def _parse_confdir(noconfig: bool, confdir: str, sourcedir: str) -> str | None:
|
|
|
392
310
|
return confdir
|
|
393
311
|
|
|
394
312
|
|
|
395
|
-
def _parse_doctreedir(doctreedir: str, outputdir: str) ->
|
|
313
|
+
def _parse_doctreedir(doctreedir: str, outputdir: str) -> _StrPath:
|
|
396
314
|
if doctreedir:
|
|
397
|
-
return doctreedir
|
|
398
|
-
return
|
|
315
|
+
return _StrPath(doctreedir)
|
|
316
|
+
return _StrPath(outputdir, '.doctrees')
|
|
399
317
|
|
|
400
318
|
|
|
401
319
|
def _validate_filenames(
|
|
@@ -408,8 +326,8 @@ def _validate_filenames(
|
|
|
408
326
|
|
|
409
327
|
|
|
410
328
|
def _validate_colour_support(colour: str) -> None:
|
|
411
|
-
if colour == 'no' or (colour == 'auto' and not
|
|
412
|
-
|
|
329
|
+
if colour == 'no' or (colour == 'auto' and not terminal_supports_colour()):
|
|
330
|
+
disable_colour()
|
|
413
331
|
|
|
414
332
|
|
|
415
333
|
def _parse_logging(
|
|
@@ -431,12 +349,12 @@ def _parse_logging(
|
|
|
431
349
|
warnfp = None
|
|
432
350
|
if warning and warnfile:
|
|
433
351
|
try:
|
|
434
|
-
|
|
435
|
-
ensuredir(
|
|
352
|
+
warn_file = Path(warnfile).resolve()
|
|
353
|
+
ensuredir(warn_file.parent)
|
|
436
354
|
# the caller is responsible for closing this file descriptor
|
|
437
|
-
warnfp = open(
|
|
355
|
+
warnfp = open(warn_file, 'w', encoding='utf-8') # NoQA: SIM115
|
|
438
356
|
except Exception as exc:
|
|
439
|
-
parser.error(__(
|
|
357
|
+
parser.error(__("cannot open warning file '%s': %s") % (warn_file, exc))
|
|
440
358
|
warning = TeeStripANSI(warning, warnfp) # type: ignore[assignment]
|
|
441
359
|
error = warning
|
|
442
360
|
|
|
@@ -514,7 +432,19 @@ def build_main(argv: Sequence[str]) -> int:
|
|
|
514
432
|
app.build(args.force_all, args.filenames)
|
|
515
433
|
return app.statuscode
|
|
516
434
|
except (Exception, KeyboardInterrupt) as exc:
|
|
517
|
-
|
|
435
|
+
if app is not None:
|
|
436
|
+
message_log: Sequence[str] = app.messagelog
|
|
437
|
+
extensions: Collection[Extension] = app.extensions.values()
|
|
438
|
+
else:
|
|
439
|
+
message_log = extensions = ()
|
|
440
|
+
sphinx._cli.util.errors.handle_exception(
|
|
441
|
+
exc,
|
|
442
|
+
stderr=args.error,
|
|
443
|
+
use_pdb=args.pdb,
|
|
444
|
+
print_traceback=args.verbosity or args.traceback,
|
|
445
|
+
message_log=message_log,
|
|
446
|
+
extensions=extensions,
|
|
447
|
+
)
|
|
518
448
|
return 2
|
|
519
449
|
finally:
|
|
520
450
|
if warnfp is not None:
|