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/cmd/make_mode.py
CHANGED
|
@@ -12,19 +12,15 @@ from __future__ import annotations
|
|
|
12
12
|
import os
|
|
13
13
|
import subprocess
|
|
14
14
|
import sys
|
|
15
|
-
from
|
|
15
|
+
from contextlib import chdir
|
|
16
16
|
from typing import TYPE_CHECKING
|
|
17
17
|
|
|
18
18
|
import sphinx
|
|
19
|
+
from sphinx._cli.util.colour import blue, bold, disable_colour, terminal_supports_colour
|
|
19
20
|
from sphinx.cmd.build import build_main
|
|
20
|
-
from sphinx.util.
|
|
21
|
+
from sphinx.util._pathlib import _StrPath
|
|
21
22
|
from sphinx.util.osutil import rmtree
|
|
22
23
|
|
|
23
|
-
if sys.version_info >= (3, 11):
|
|
24
|
-
from contextlib import chdir
|
|
25
|
-
else:
|
|
26
|
-
from sphinx.util.osutil import _chdir as chdir
|
|
27
|
-
|
|
28
24
|
if TYPE_CHECKING:
|
|
29
25
|
from collections.abc import Sequence
|
|
30
26
|
|
|
@@ -53,7 +49,7 @@ BUILDERS = [
|
|
|
53
49
|
(
|
|
54
50
|
'',
|
|
55
51
|
'doctest',
|
|
56
|
-
'to run all doctests embedded in the documentation
|
|
52
|
+
'to run all doctests embedded in the documentation (if enabled)',
|
|
57
53
|
),
|
|
58
54
|
('', 'coverage', 'to run coverage check of the documentation (if enabled)'),
|
|
59
55
|
('', 'clean', 'to remove everything in the build directory'),
|
|
@@ -61,36 +57,42 @@ BUILDERS = [
|
|
|
61
57
|
|
|
62
58
|
|
|
63
59
|
class Make:
|
|
64
|
-
def __init__(
|
|
65
|
-
self
|
|
66
|
-
|
|
60
|
+
def __init__(
|
|
61
|
+
self,
|
|
62
|
+
*,
|
|
63
|
+
source_dir: str | os.PathLike[str],
|
|
64
|
+
build_dir: str | os.PathLike[str],
|
|
65
|
+
opts: Sequence[str],
|
|
66
|
+
) -> None:
|
|
67
|
+
self.source_dir = _StrPath(source_dir)
|
|
68
|
+
self.build_dir = _StrPath(build_dir)
|
|
67
69
|
self.opts = [*opts]
|
|
68
70
|
|
|
69
|
-
def build_dir_join(self, *comps: str) ->
|
|
70
|
-
return
|
|
71
|
+
def build_dir_join(self, *comps: str | os.PathLike[str]) -> _StrPath:
|
|
72
|
+
return self.build_dir.joinpath(*comps)
|
|
71
73
|
|
|
72
74
|
def build_clean(self) -> int:
|
|
73
|
-
source_dir =
|
|
74
|
-
build_dir =
|
|
75
|
-
if not
|
|
75
|
+
source_dir = self.source_dir.resolve()
|
|
76
|
+
build_dir = self.build_dir.resolve()
|
|
77
|
+
if not self.build_dir.exists():
|
|
76
78
|
return 0
|
|
77
|
-
elif not
|
|
78
|
-
print(
|
|
79
|
+
elif not self.build_dir.is_dir():
|
|
80
|
+
print("Error: '%s' is not a directory!" % self.build_dir)
|
|
79
81
|
return 1
|
|
80
82
|
elif source_dir == build_dir:
|
|
81
|
-
print(
|
|
83
|
+
print("Error: '%s' is same as source directory!" % self.build_dir)
|
|
82
84
|
return 1
|
|
83
|
-
elif
|
|
84
|
-
print(
|
|
85
|
+
elif source_dir.is_relative_to(build_dir):
|
|
86
|
+
print("Error: '%s' directory contains source directory!" % self.build_dir)
|
|
85
87
|
return 1
|
|
86
|
-
print(
|
|
87
|
-
for item in
|
|
88
|
-
rmtree(
|
|
88
|
+
print("Removing everything under '%s'..." % self.build_dir)
|
|
89
|
+
for item in self.build_dir.iterdir():
|
|
90
|
+
rmtree(item)
|
|
89
91
|
return 0
|
|
90
92
|
|
|
91
93
|
def build_help(self) -> None:
|
|
92
|
-
if not
|
|
93
|
-
|
|
94
|
+
if not terminal_supports_colour():
|
|
95
|
+
disable_colour()
|
|
94
96
|
|
|
95
97
|
print(bold('Sphinx v%s' % sphinx.__display_version__))
|
|
96
98
|
print("Please use `make %s' where %s is one of" % ((blue('target'),) * 2))
|
|
@@ -110,7 +112,7 @@ class Make:
|
|
|
110
112
|
try:
|
|
111
113
|
with chdir(self.build_dir_join('latex')):
|
|
112
114
|
if '-Q' in self.opts:
|
|
113
|
-
with open('__LATEXSTDOUT__', 'w') as outfile:
|
|
115
|
+
with open('__LATEXSTDOUT__', 'w', encoding='utf-8') as outfile:
|
|
114
116
|
returncode = subprocess.call(
|
|
115
117
|
[
|
|
116
118
|
makecmd,
|
|
@@ -183,7 +185,9 @@ class Make:
|
|
|
183
185
|
return 1
|
|
184
186
|
return 0
|
|
185
187
|
|
|
186
|
-
def run_generic_build(
|
|
188
|
+
def run_generic_build(
|
|
189
|
+
self, builder: str, doctreedir: str | os.PathLike[str] | None = None
|
|
190
|
+
) -> int:
|
|
187
191
|
# compatibility with old Makefile
|
|
188
192
|
paper_size = os.getenv('PAPER', '')
|
|
189
193
|
if paper_size in {'a4', 'letter'}:
|
|
@@ -195,9 +199,9 @@ class Make:
|
|
|
195
199
|
'--builder',
|
|
196
200
|
builder,
|
|
197
201
|
'--doctree-dir',
|
|
198
|
-
doctreedir,
|
|
199
|
-
self.source_dir,
|
|
200
|
-
self.build_dir_join(builder),
|
|
202
|
+
str(doctreedir),
|
|
203
|
+
str(self.source_dir),
|
|
204
|
+
str(self.build_dir_join(builder)),
|
|
201
205
|
]
|
|
202
206
|
return build_main(args + self.opts)
|
|
203
207
|
|
sphinx/cmd/quickstart.py
CHANGED
|
@@ -5,39 +5,48 @@ from __future__ import annotations
|
|
|
5
5
|
import argparse
|
|
6
6
|
import locale
|
|
7
7
|
import os
|
|
8
|
+
import os.path
|
|
8
9
|
import sys
|
|
9
10
|
import time
|
|
10
|
-
from
|
|
11
|
-
from typing import TYPE_CHECKING, Any
|
|
12
|
-
|
|
13
|
-
# try to import readline, unix specific enhancement
|
|
14
|
-
try:
|
|
15
|
-
import readline
|
|
16
|
-
|
|
17
|
-
if TYPE_CHECKING and sys.platform == 'win32': # always false, for type checking
|
|
18
|
-
raise ImportError
|
|
19
|
-
READLINE_AVAILABLE = True
|
|
20
|
-
if readline.__doc__ and 'libedit' in readline.__doc__:
|
|
21
|
-
readline.parse_and_bind('bind ^I rl_complete')
|
|
22
|
-
USE_LIBEDIT = True
|
|
23
|
-
else:
|
|
24
|
-
readline.parse_and_bind('tab: complete')
|
|
25
|
-
USE_LIBEDIT = False
|
|
26
|
-
except ImportError:
|
|
27
|
-
READLINE_AVAILABLE = False
|
|
28
|
-
USE_LIBEDIT = False
|
|
11
|
+
from typing import TYPE_CHECKING
|
|
29
12
|
|
|
30
13
|
from docutils.utils import column_width
|
|
31
14
|
|
|
32
15
|
import sphinx.locale
|
|
33
16
|
from sphinx import __display_version__, package_dir
|
|
17
|
+
from sphinx._cli.util.colour import (
|
|
18
|
+
_create_input_mode_colour_func,
|
|
19
|
+
bold,
|
|
20
|
+
disable_colour,
|
|
21
|
+
red,
|
|
22
|
+
terminal_supports_colour,
|
|
23
|
+
)
|
|
34
24
|
from sphinx.locale import __
|
|
35
|
-
from sphinx.util.console import bold, color_terminal, colorize, nocolor, red
|
|
36
25
|
from sphinx.util.osutil import ensuredir
|
|
37
26
|
from sphinx.util.template import SphinxRenderer
|
|
38
27
|
|
|
39
28
|
if TYPE_CHECKING:
|
|
40
29
|
from collections.abc import Callable, Sequence
|
|
30
|
+
from typing import Any
|
|
31
|
+
|
|
32
|
+
# try to import readline, unix specific enhancement
|
|
33
|
+
try:
|
|
34
|
+
import readline
|
|
35
|
+
|
|
36
|
+
if TYPE_CHECKING and sys.platform == 'win32':
|
|
37
|
+
# MyPy doesn't realise that this raises a ModuleNotFoundError
|
|
38
|
+
# on Windows, and complains that 'parse_and_bind' is not defined.
|
|
39
|
+
# This condition is always False at runtime, but tricks type checkers.
|
|
40
|
+
raise ImportError # NoQA: TRY301
|
|
41
|
+
except ImportError:
|
|
42
|
+
READLINE_AVAILABLE = USE_LIBEDIT = False
|
|
43
|
+
else:
|
|
44
|
+
READLINE_AVAILABLE = True
|
|
45
|
+
USE_LIBEDIT = 'libedit' in getattr(readline, '__doc__', '')
|
|
46
|
+
if USE_LIBEDIT:
|
|
47
|
+
readline.parse_and_bind('bind ^I rl_complete')
|
|
48
|
+
else:
|
|
49
|
+
readline.parse_and_bind('tab: complete')
|
|
41
50
|
|
|
42
51
|
EXTENSIONS = {
|
|
43
52
|
'autodoc': __('automatically insert docstrings from modules'),
|
|
@@ -66,10 +75,17 @@ DEFAULTS = {
|
|
|
66
75
|
PROMPT_PREFIX = '> '
|
|
67
76
|
|
|
68
77
|
if sys.platform == 'win32':
|
|
69
|
-
# On Windows, show questions as bold because of
|
|
70
|
-
|
|
78
|
+
# On Windows, show questions as bold because of PowerShell's colour scheme
|
|
79
|
+
# See: https://github.com/sphinx-doc/sphinx/issues/5294
|
|
80
|
+
from sphinx._cli.util.colour import bold as _question_colour
|
|
71
81
|
else:
|
|
72
|
-
|
|
82
|
+
from sphinx._cli.util.colour import purple as _question_colour
|
|
83
|
+
|
|
84
|
+
if READLINE_AVAILABLE:
|
|
85
|
+
# Use an input-mode colour function if readline is available
|
|
86
|
+
if escape_code := getattr(_question_colour, '__escape_code', ''):
|
|
87
|
+
_question_colour = _create_input_mode_colour_func(escape_code)
|
|
88
|
+
del escape_code
|
|
73
89
|
|
|
74
90
|
|
|
75
91
|
# function to get input from terminal -- overridden by the test suite
|
|
@@ -89,15 +105,15 @@ class ValidationError(Exception):
|
|
|
89
105
|
|
|
90
106
|
|
|
91
107
|
def is_path(x: str) -> str:
|
|
92
|
-
x = path.expanduser(x)
|
|
93
|
-
if not path.isdir(x):
|
|
108
|
+
x = os.path.expanduser(x)
|
|
109
|
+
if not os.path.isdir(x):
|
|
94
110
|
raise ValidationError(__('Please enter a valid path name.'))
|
|
95
111
|
return x
|
|
96
112
|
|
|
97
113
|
|
|
98
114
|
def is_path_or_empty(x: str) -> str:
|
|
99
|
-
if x
|
|
100
|
-
return
|
|
115
|
+
if not x:
|
|
116
|
+
return ''
|
|
101
117
|
return is_path(x)
|
|
102
118
|
|
|
103
119
|
|
|
@@ -121,9 +137,9 @@ def choice(*l: str) -> Callable[[str], str]:
|
|
|
121
137
|
|
|
122
138
|
|
|
123
139
|
def boolean(x: str) -> bool:
|
|
124
|
-
if x.upper() not in
|
|
140
|
+
if x.upper() not in {'Y', 'YES', 'N', 'NO'}:
|
|
125
141
|
raise ValidationError(__("Please enter either 'y' or 'n'."))
|
|
126
|
-
return x.upper() in
|
|
142
|
+
return x.upper() in {'Y', 'YES'}
|
|
127
143
|
|
|
128
144
|
|
|
129
145
|
def suffix(x: str) -> str:
|
|
@@ -147,15 +163,13 @@ def do_prompt(
|
|
|
147
163
|
else:
|
|
148
164
|
prompt = PROMPT_PREFIX + text + ': '
|
|
149
165
|
if USE_LIBEDIT:
|
|
150
|
-
# Note: libedit has a problem for combination of ``input()``
|
|
151
|
-
#
|
|
152
|
-
# on libedit.
|
|
166
|
+
# Note: libedit has a problem for combination of ``input()``
|
|
167
|
+
# and escape sequences.
|
|
168
|
+
# To avoid the problem, all prompts are not colored on libedit.
|
|
169
|
+
# See https://github.com/sphinx-doc/sphinx/issues/5335
|
|
153
170
|
pass
|
|
154
|
-
elif READLINE_AVAILABLE:
|
|
155
|
-
# pass input_mode=True if readline available
|
|
156
|
-
prompt = colorize(COLOR_QUESTION, prompt, input_mode=True)
|
|
157
171
|
else:
|
|
158
|
-
prompt =
|
|
172
|
+
prompt = _question_colour(prompt)
|
|
159
173
|
x = term_input(prompt).strip()
|
|
160
174
|
if default and not x:
|
|
161
175
|
x = default
|
|
@@ -179,12 +193,14 @@ class QuickstartRenderer(SphinxRenderer):
|
|
|
179
193
|
Note: Please don't use this function from extensions.
|
|
180
194
|
It will be removed in the future without deprecation period.
|
|
181
195
|
"""
|
|
182
|
-
template = path.join(self.templatedir, path.basename(template_name))
|
|
183
|
-
return bool(self.templatedir) and path.exists(template)
|
|
196
|
+
template = os.path.join(self.templatedir, os.path.basename(template_name))
|
|
197
|
+
return bool(self.templatedir) and os.path.exists(template)
|
|
184
198
|
|
|
185
199
|
def render(self, template_name: str, context: dict[str, Any]) -> str:
|
|
186
200
|
if self._has_custom_template(template_name):
|
|
187
|
-
custom_template = path.join(
|
|
201
|
+
custom_template = os.path.join(
|
|
202
|
+
self.templatedir, os.path.basename(template_name)
|
|
203
|
+
)
|
|
188
204
|
return self.render_from_file(custom_template, context)
|
|
189
205
|
else:
|
|
190
206
|
return super().render(template_name, context)
|
|
@@ -228,8 +244,8 @@ def ask_user(d: dict[str, Any]) -> None:
|
|
|
228
244
|
print(__('Enter the root path for documentation.'))
|
|
229
245
|
d['path'] = do_prompt(__('Root path for the documentation'), '.', is_path)
|
|
230
246
|
|
|
231
|
-
while path.isfile(path.join(d['path'], 'conf.py')) or path.isfile(
|
|
232
|
-
path.join(d['path'], 'source', 'conf.py')
|
|
247
|
+
while os.path.isfile(os.path.join(d['path'], 'conf.py')) or os.path.isfile(
|
|
248
|
+
os.path.join(d['path'], 'source', 'conf.py')
|
|
233
249
|
):
|
|
234
250
|
print()
|
|
235
251
|
print(
|
|
@@ -271,7 +287,7 @@ def ask_user(d: dict[str, Any]) -> None:
|
|
|
271
287
|
'for custom HTML templates and "_static" for custom stylesheets and other static\n' # NoQA: E501
|
|
272
288
|
'files. You can enter another prefix (such as ".") to replace the underscore.'
|
|
273
289
|
)
|
|
274
|
-
)
|
|
290
|
+
)
|
|
275
291
|
d['dot'] = do_prompt(__('Name prefix for templates and static dir'), '_', ok)
|
|
276
292
|
|
|
277
293
|
if 'project' not in d:
|
|
@@ -341,8 +357,8 @@ def ask_user(d: dict[str, Any]) -> None:
|
|
|
341
357
|
)
|
|
342
358
|
|
|
343
359
|
while (
|
|
344
|
-
path.isfile(path.join(d['path'], d['master'] + d['suffix']))
|
|
345
|
-
or path.isfile(path.join(d['path'], 'source', d['master'] + d['suffix']))
|
|
360
|
+
os.path.isfile(os.path.join(d['path'], d['master'] + d['suffix']))
|
|
361
|
+
or os.path.isfile(os.path.join(d['path'], 'source', d['master'] + d['suffix']))
|
|
346
362
|
): # fmt: skip
|
|
347
363
|
print()
|
|
348
364
|
print(
|
|
@@ -424,14 +440,14 @@ def generate(
|
|
|
424
440
|
d['path'] = os.path.abspath(d['path'])
|
|
425
441
|
ensuredir(d['path'])
|
|
426
442
|
|
|
427
|
-
srcdir = path.join(d['path'], 'source') if d['sep'] else d['path']
|
|
443
|
+
srcdir = os.path.join(d['path'], 'source') if d['sep'] else d['path']
|
|
428
444
|
|
|
429
445
|
ensuredir(srcdir)
|
|
430
446
|
if d['sep']:
|
|
431
|
-
builddir = path.join(d['path'], 'build')
|
|
447
|
+
builddir = os.path.join(d['path'], 'build')
|
|
432
448
|
d['exclude_patterns'] = ''
|
|
433
449
|
else:
|
|
434
|
-
builddir = path.join(srcdir, d['dot'] + 'build')
|
|
450
|
+
builddir = os.path.join(srcdir, d['dot'] + 'build')
|
|
435
451
|
exclude_patterns = map(
|
|
436
452
|
repr,
|
|
437
453
|
[
|
|
@@ -442,11 +458,11 @@ def generate(
|
|
|
442
458
|
)
|
|
443
459
|
d['exclude_patterns'] = ', '.join(exclude_patterns)
|
|
444
460
|
ensuredir(builddir)
|
|
445
|
-
ensuredir(path.join(srcdir, d['dot'] + 'templates'))
|
|
446
|
-
ensuredir(path.join(srcdir, d['dot'] + 'static'))
|
|
461
|
+
ensuredir(os.path.join(srcdir, d['dot'] + 'templates'))
|
|
462
|
+
ensuredir(os.path.join(srcdir, d['dot'] + 'static'))
|
|
447
463
|
|
|
448
464
|
def write_file(fpath: str, content: str, newline: str | None = None) -> None:
|
|
449
|
-
if overwrite or not path.isfile(fpath):
|
|
465
|
+
if overwrite or not os.path.isfile(fpath):
|
|
450
466
|
if 'quiet' not in d:
|
|
451
467
|
print(__('Creating file %s.') % fpath)
|
|
452
468
|
with open(fpath, 'w', encoding='utf-8', newline=newline) as f:
|
|
@@ -456,16 +472,16 @@ def generate(
|
|
|
456
472
|
print(__('File %s already exists, skipping.') % fpath)
|
|
457
473
|
|
|
458
474
|
conf_path = os.path.join(templatedir, 'conf.py.jinja') if templatedir else None
|
|
459
|
-
if not conf_path or not path.isfile(conf_path):
|
|
475
|
+
if not conf_path or not os.path.isfile(conf_path):
|
|
460
476
|
conf_path = os.path.join(
|
|
461
477
|
package_dir, 'templates', 'quickstart', 'conf.py.jinja'
|
|
462
478
|
)
|
|
463
479
|
with open(conf_path, encoding='utf-8') as f:
|
|
464
480
|
conf_text = f.read()
|
|
465
481
|
|
|
466
|
-
write_file(path.join(srcdir, 'conf.py'), template.render_string(conf_text, d))
|
|
482
|
+
write_file(os.path.join(srcdir, 'conf.py'), template.render_string(conf_text, d))
|
|
467
483
|
|
|
468
|
-
masterfile = path.join(srcdir, d['master'] + d['suffix'])
|
|
484
|
+
masterfile = os.path.join(srcdir, d['master'] + d['suffix'])
|
|
469
485
|
if template._has_custom_template('quickstart/master_doc.rst.jinja'):
|
|
470
486
|
write_file(masterfile, template.render('quickstart/master_doc.rst.jinja', d))
|
|
471
487
|
else:
|
|
@@ -479,7 +495,7 @@ def generate(
|
|
|
479
495
|
d['rbuilddir'] = 'build' if d['sep'] else d['dot'] + 'build'
|
|
480
496
|
# use binary mode, to avoid writing \r\n on Windows
|
|
481
497
|
write_file(
|
|
482
|
-
path.join(d['path'], 'Makefile'),
|
|
498
|
+
os.path.join(d['path'], 'Makefile'),
|
|
483
499
|
template.render(makefile_template, d),
|
|
484
500
|
'\n',
|
|
485
501
|
)
|
|
@@ -488,7 +504,7 @@ def generate(
|
|
|
488
504
|
d['rsrcdir'] = 'source' if d['sep'] else '.'
|
|
489
505
|
d['rbuilddir'] = 'build' if d['sep'] else d['dot'] + 'build'
|
|
490
506
|
write_file(
|
|
491
|
-
path.join(d['path'], 'make.bat'),
|
|
507
|
+
os.path.join(d['path'], 'make.bat'),
|
|
492
508
|
template.render(batchfile_template, d),
|
|
493
509
|
'\r\n',
|
|
494
510
|
)
|
|
@@ -507,7 +523,7 @@ def generate(
|
|
|
507
523
|
end='',
|
|
508
524
|
)
|
|
509
525
|
if d['makefile'] or d['batchfile']:
|
|
510
|
-
print(__('Use the Makefile to build the docs, like so:\n
|
|
526
|
+
print(__('Use the Makefile to build the docs, like so:\n make builder'))
|
|
511
527
|
else:
|
|
512
528
|
print(
|
|
513
529
|
__(
|
|
@@ -527,9 +543,9 @@ def generate(
|
|
|
527
543
|
|
|
528
544
|
def valid_dir(d: dict[str, Any]) -> bool:
|
|
529
545
|
dir = d['path']
|
|
530
|
-
if not path.exists(dir):
|
|
546
|
+
if not os.path.exists(dir):
|
|
531
547
|
return True
|
|
532
|
-
if not path.isdir(dir):
|
|
548
|
+
if not os.path.isdir(dir):
|
|
533
549
|
return False
|
|
534
550
|
|
|
535
551
|
if {'Makefile', 'make.bat'} & set(os.listdir(dir)):
|
|
@@ -537,9 +553,9 @@ def valid_dir(d: dict[str, Any]) -> bool:
|
|
|
537
553
|
|
|
538
554
|
if d['sep']:
|
|
539
555
|
dir = os.path.join('source', dir)
|
|
540
|
-
if not path.exists(dir):
|
|
556
|
+
if not os.path.exists(dir):
|
|
541
557
|
return True
|
|
542
|
-
if not path.isdir(dir):
|
|
558
|
+
if not os.path.isdir(dir):
|
|
543
559
|
return False
|
|
544
560
|
|
|
545
561
|
reserved_names = [
|
|
@@ -721,8 +737,8 @@ def main(argv: Sequence[str] = (), /) -> int:
|
|
|
721
737
|
locale.setlocale(locale.LC_ALL, '')
|
|
722
738
|
sphinx.locale.init_console()
|
|
723
739
|
|
|
724
|
-
if not
|
|
725
|
-
|
|
740
|
+
if not terminal_supports_colour():
|
|
741
|
+
disable_colour()
|
|
726
742
|
|
|
727
743
|
# parse options
|
|
728
744
|
parser = get_parser()
|