Sphinx 7.4.7__py3-none-any.whl → 8.0.0rc1__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 +2 -2
- sphinx/_cli/__init__.py +4 -4
- sphinx/application.py +7 -7
- sphinx/builders/__init__.py +2 -3
- sphinx/builders/_epub_base.py +33 -12
- sphinx/builders/changes.py +13 -5
- sphinx/builders/epub3.py +6 -2
- sphinx/builders/html/__init__.py +88 -58
- sphinx/builders/latex/__init__.py +38 -12
- sphinx/builders/latex/transforms.py +1 -1
- sphinx/builders/linkcheck.py +8 -49
- sphinx/builders/texinfo.py +12 -6
- sphinx/builders/text.py +7 -3
- sphinx/builders/xml.py +7 -3
- sphinx/cmd/quickstart.py +10 -20
- sphinx/config.py +12 -12
- sphinx/deprecation.py +8 -8
- sphinx/directives/other.py +2 -3
- sphinx/directives/patches.py +2 -2
- sphinx/domains/__init__.py +4 -2
- sphinx/domains/c/__init__.py +2 -2
- sphinx/domains/c/_ast.py +3 -2
- sphinx/domains/c/_parser.py +4 -3
- sphinx/domains/cpp/__init__.py +2 -2
- sphinx/domains/cpp/_ast.py +1 -2
- sphinx/domains/cpp/_parser.py +2 -2
- sphinx/domains/cpp/_symbol.py +2 -2
- sphinx/domains/math.py +1 -1
- sphinx/domains/python/_object.py +0 -1
- sphinx/domains/std/__init__.py +7 -8
- sphinx/environment/__init__.py +14 -32
- sphinx/environment/adapters/indexentries.py +4 -6
- sphinx/environment/adapters/toctree.py +4 -4
- sphinx/environment/collectors/title.py +1 -1
- sphinx/environment/collectors/toctree.py +1 -1
- sphinx/events.py +3 -1
- sphinx/ext/autodoc/__init__.py +17 -63
- sphinx/ext/autodoc/directive.py +7 -5
- sphinx/ext/autodoc/importer.py +2 -1
- sphinx/ext/autodoc/preserve_defaults.py +2 -2
- sphinx/ext/autosummary/__init__.py +7 -6
- sphinx/ext/autosummary/generate.py +5 -4
- sphinx/ext/doctest.py +5 -5
- sphinx/ext/graphviz.py +1 -1
- sphinx/ext/imgmath.py +1 -1
- sphinx/ext/inheritance_diagram.py +1 -1
- sphinx/ext/intersphinx/__init__.py +25 -5
- sphinx/ext/intersphinx/_cli.py +7 -6
- sphinx/ext/intersphinx/_load.py +240 -115
- sphinx/ext/intersphinx/_resolve.py +12 -11
- sphinx/ext/intersphinx/_shared.py +102 -9
- sphinx/ext/mathjax.py +1 -1
- sphinx/ext/napoleon/docstring.py +2 -2
- sphinx/ext/todo.py +2 -2
- sphinx/ext/viewcode.py +2 -1
- sphinx/highlighting.py +3 -3
- sphinx/io.py +2 -2
- sphinx/jinja2glue.py +13 -6
- sphinx/locale/__init__.py +4 -3
- sphinx/project.py +23 -19
- sphinx/pycode/ast.py +2 -2
- sphinx/pycode/parser.py +2 -2
- sphinx/pygments_styles.py +3 -3
- sphinx/registry.py +3 -8
- sphinx/search/__init__.py +1 -1
- sphinx/testing/path.py +2 -1
- sphinx/testing/util.py +1 -1
- sphinx/texinputs/Makefile.jinja +2 -1
- sphinx/texinputs_win/Makefile.jinja +2 -1
- sphinx/theming.py +3 -12
- sphinx/transforms/__init__.py +5 -5
- sphinx/transforms/references.py +1 -1
- sphinx/util/__init__.py +11 -35
- sphinx/util/_timestamps.py +12 -0
- sphinx/util/cfamily.py +5 -5
- sphinx/util/console.py +4 -3
- sphinx/util/display.py +3 -3
- sphinx/util/docfields.py +1 -1
- sphinx/util/docutils.py +44 -10
- sphinx/util/fileutil.py +25 -20
- sphinx/util/i18n.py +9 -4
- sphinx/util/images.py +3 -2
- sphinx/util/inspect.py +28 -43
- sphinx/util/inventory.py +2 -2
- sphinx/util/matching.py +2 -2
- sphinx/util/math.py +1 -1
- sphinx/util/nodes.py +8 -8
- sphinx/util/osutil.py +29 -28
- sphinx/util/parallel.py +2 -2
- sphinx/util/requests.py +1 -1
- sphinx/util/template.py +3 -3
- sphinx/util/typing.py +36 -72
- sphinx/writers/html.py +1 -1
- sphinx/writers/html5.py +1 -1
- sphinx/writers/latex.py +4 -4
- sphinx/writers/manpage.py +2 -2
- sphinx/writers/texinfo.py +5 -5
- sphinx/writers/text.py +4 -4
- sphinx/writers/xml.py +2 -2
- {sphinx-7.4.7.dist-info → sphinx-8.0.0rc1.dist-info}/METADATA +10 -9
- {sphinx-7.4.7.dist-info → sphinx-8.0.0rc1.dist-info}/RECORD +104 -106
- sphinx/templates/quickstart/Makefile.jinja +0 -98
- sphinx/templates/quickstart/make.bat.jinja +0 -110
- sphinx/util/_pathlib.py +0 -120
- {sphinx-7.4.7.dist-info → sphinx-8.0.0rc1.dist-info}/LICENSE.rst +0 -0
- {sphinx-7.4.7.dist-info → sphinx-8.0.0rc1.dist-info}/WHEEL +0 -0
- {sphinx-7.4.7.dist-info → sphinx-8.0.0rc1.dist-info}/entry_points.txt +0 -0
|
@@ -20,13 +20,13 @@ from sphinx.environment.adapters.asset import ImageAdapter
|
|
|
20
20
|
from sphinx.errors import NoUri, SphinxError
|
|
21
21
|
from sphinx.locale import _, __
|
|
22
22
|
from sphinx.util import logging, texescape
|
|
23
|
-
from sphinx.util.console import
|
|
23
|
+
from sphinx.util.console import darkgreen
|
|
24
24
|
from sphinx.util.display import progress_message, status_iterator
|
|
25
25
|
from sphinx.util.docutils import SphinxFileOutput, new_document
|
|
26
26
|
from sphinx.util.fileutil import copy_asset_file
|
|
27
27
|
from sphinx.util.i18n import format_date
|
|
28
28
|
from sphinx.util.nodes import inline_all_toctrees
|
|
29
|
-
from sphinx.util.osutil import SEP, make_filename_from_project
|
|
29
|
+
from sphinx.util.osutil import SEP, copyfile, make_filename_from_project
|
|
30
30
|
from sphinx.util.template import LaTeXRenderer
|
|
31
31
|
from sphinx.writers.latex import LaTeXTranslator, LaTeXWriter
|
|
32
32
|
|
|
@@ -407,24 +407,36 @@ class LaTeXBuilder(Builder):
|
|
|
407
407
|
'xindy_lang_option': xindy_lang_option,
|
|
408
408
|
'xindy_cyrillic': xindy_cyrillic,
|
|
409
409
|
}
|
|
410
|
-
logger.info(bold(__('copying TeX support files...')))
|
|
411
410
|
staticdirname = path.join(package_dir, 'texinputs')
|
|
412
411
|
for filename in os.listdir(staticdirname):
|
|
413
412
|
if not filename.startswith('.'):
|
|
414
|
-
copy_asset_file(
|
|
415
|
-
|
|
413
|
+
copy_asset_file(
|
|
414
|
+
path.join(staticdirname, filename),
|
|
415
|
+
self.outdir,
|
|
416
|
+
context=context,
|
|
417
|
+
force=True,
|
|
418
|
+
)
|
|
416
419
|
|
|
417
420
|
# use pre-1.6.x Makefile for make latexpdf on Windows
|
|
418
421
|
if os.name == 'nt':
|
|
419
422
|
staticdirname = path.join(package_dir, 'texinputs_win')
|
|
420
|
-
copy_asset_file(
|
|
421
|
-
|
|
423
|
+
copy_asset_file(
|
|
424
|
+
path.join(staticdirname, 'Makefile.jinja'),
|
|
425
|
+
self.outdir,
|
|
426
|
+
context=context,
|
|
427
|
+
force=True,
|
|
428
|
+
)
|
|
422
429
|
|
|
423
430
|
@progress_message(__('copying additional files'))
|
|
424
431
|
def copy_latex_additional_files(self) -> None:
|
|
425
432
|
for filename in self.config.latex_additional_files:
|
|
426
433
|
logger.info(' ' + filename, nonl=True)
|
|
427
|
-
|
|
434
|
+
source = self.confdir / filename
|
|
435
|
+
copyfile(
|
|
436
|
+
source,
|
|
437
|
+
self.outdir / source.name,
|
|
438
|
+
force=True,
|
|
439
|
+
)
|
|
428
440
|
|
|
429
441
|
def copy_image_files(self) -> None:
|
|
430
442
|
if self.images:
|
|
@@ -434,15 +446,23 @@ class LaTeXBuilder(Builder):
|
|
|
434
446
|
stringify_func=stringify_func):
|
|
435
447
|
dest = self.images[src]
|
|
436
448
|
try:
|
|
437
|
-
|
|
438
|
-
|
|
449
|
+
copyfile(
|
|
450
|
+
self.srcdir / src,
|
|
451
|
+
self.outdir / dest,
|
|
452
|
+
force=True,
|
|
453
|
+
)
|
|
439
454
|
except Exception as err:
|
|
440
455
|
logger.warning(__('cannot copy image file %r: %s'),
|
|
441
456
|
path.join(self.srcdir, src), err)
|
|
442
457
|
if self.config.latex_logo:
|
|
443
458
|
if not path.isfile(path.join(self.confdir, self.config.latex_logo)):
|
|
444
459
|
raise SphinxError(__('logo file %r does not exist') % self.config.latex_logo)
|
|
445
|
-
|
|
460
|
+
source = self.confdir / self.config.latex_logo
|
|
461
|
+
copyfile(
|
|
462
|
+
source,
|
|
463
|
+
self.outdir / source.name,
|
|
464
|
+
force=True,
|
|
465
|
+
)
|
|
446
466
|
|
|
447
467
|
def write_message_catalog(self) -> None:
|
|
448
468
|
formats = self.config.numfig_format
|
|
@@ -457,7 +477,13 @@ class LaTeXBuilder(Builder):
|
|
|
457
477
|
context['addtocaptions'] = r'\addto\captions%s' % self.babel.get_language()
|
|
458
478
|
|
|
459
479
|
filename = path.join(package_dir, 'templates', 'latex', 'sphinxmessages.sty.jinja')
|
|
460
|
-
copy_asset_file(
|
|
480
|
+
copy_asset_file(
|
|
481
|
+
filename,
|
|
482
|
+
self.outdir,
|
|
483
|
+
context=context,
|
|
484
|
+
renderer=LaTeXRenderer(),
|
|
485
|
+
force=True,
|
|
486
|
+
)
|
|
461
487
|
|
|
462
488
|
|
|
463
489
|
def validate_config_values(app: Sphinx, config: Config) -> None:
|
|
@@ -417,7 +417,7 @@ class LaTeXFootnoteVisitor(nodes.NodeVisitor):
|
|
|
417
417
|
self.unrestrict(node)
|
|
418
418
|
|
|
419
419
|
def visit_title(self, node: nodes.title) -> None:
|
|
420
|
-
if isinstance(node.parent,
|
|
420
|
+
if isinstance(node.parent, nodes.section | nodes.table):
|
|
421
421
|
self.restrict(node)
|
|
422
422
|
|
|
423
423
|
def depart_title(self, node: nodes.title) -> None:
|
sphinx/builders/linkcheck.py
CHANGED
|
@@ -7,7 +7,6 @@ import json
|
|
|
7
7
|
import re
|
|
8
8
|
import socket
|
|
9
9
|
import time
|
|
10
|
-
import warnings
|
|
11
10
|
from html.parser import HTMLParser
|
|
12
11
|
from os import path
|
|
13
12
|
from queue import PriorityQueue, Queue
|
|
@@ -20,7 +19,6 @@ from requests.exceptions import ConnectionError, HTTPError, SSLError, TooManyRed
|
|
|
20
19
|
from requests.exceptions import Timeout as RequestTimeout
|
|
21
20
|
|
|
22
21
|
from sphinx.builders.dummy import DummyBuilder
|
|
23
|
-
from sphinx.deprecation import RemovedInSphinx80Warning
|
|
24
22
|
from sphinx.locale import __
|
|
25
23
|
from sphinx.transforms.post_transforms import SphinxPostTransform
|
|
26
24
|
from sphinx.util import encode_uri, logging, requests
|
|
@@ -29,8 +27,9 @@ from sphinx.util.http_date import rfc1123_to_epoch
|
|
|
29
27
|
from sphinx.util.nodes import get_node_line
|
|
30
28
|
|
|
31
29
|
if TYPE_CHECKING:
|
|
32
|
-
from collections.abc import Iterator
|
|
33
|
-
from
|
|
30
|
+
from collections.abc import Callable, Iterator
|
|
31
|
+
from pathlib import Path
|
|
32
|
+
from typing import Any
|
|
34
33
|
|
|
35
34
|
from requests import Response
|
|
36
35
|
|
|
@@ -66,25 +65,6 @@ class CheckExternalLinksBuilder(DummyBuilder):
|
|
|
66
65
|
# set a timeout for non-responding servers
|
|
67
66
|
socket.setdefaulttimeout(5.0)
|
|
68
67
|
|
|
69
|
-
if not self.config.linkcheck_allow_unauthorized:
|
|
70
|
-
deprecation_msg = (
|
|
71
|
-
"The default value for 'linkcheck_allow_unauthorized' will change "
|
|
72
|
-
"from `True` in Sphinx 7.3+ to `False`, meaning that HTTP 401 "
|
|
73
|
-
"unauthorized responses will be reported as broken by default. "
|
|
74
|
-
"See https://github.com/sphinx-doc/sphinx/issues/11433 for details."
|
|
75
|
-
)
|
|
76
|
-
warnings.warn(deprecation_msg, RemovedInSphinx80Warning, stacklevel=1)
|
|
77
|
-
|
|
78
|
-
if self.config.linkcheck_report_timeouts_as_broken:
|
|
79
|
-
deprecation_msg = (
|
|
80
|
-
"The default value for 'linkcheck_report_timeouts_as_broken' will change "
|
|
81
|
-
'to False in Sphinx 8, meaning that request timeouts '
|
|
82
|
-
"will be reported with a new 'timeout' status, instead of as 'broken'. "
|
|
83
|
-
'This is intended to provide more detail as to the failure mode. '
|
|
84
|
-
'See https://github.com/sphinx-doc/sphinx/issues/11868 for details.'
|
|
85
|
-
)
|
|
86
|
-
warnings.warn(deprecation_msg, RemovedInSphinx80Warning, stacklevel=1)
|
|
87
|
-
|
|
88
68
|
def finish(self) -> None:
|
|
89
69
|
checker = HyperlinkAvailabilityChecker(self.config)
|
|
90
70
|
logger.info('')
|
|
@@ -103,7 +83,7 @@ class CheckExternalLinksBuilder(DummyBuilder):
|
|
|
103
83
|
filename = self.env.doc2path(result.docname, False)
|
|
104
84
|
|
|
105
85
|
linkstat: dict[str, str | int] = {
|
|
106
|
-
'filename': filename, 'lineno': result.lineno,
|
|
86
|
+
'filename': str(filename), 'lineno': result.lineno,
|
|
107
87
|
'status': result.status, 'code': result.code,
|
|
108
88
|
'uri': result.uri, 'info': result.message,
|
|
109
89
|
}
|
|
@@ -170,7 +150,7 @@ class CheckExternalLinksBuilder(DummyBuilder):
|
|
|
170
150
|
self.json_outfile.write(json.dumps(data))
|
|
171
151
|
self.json_outfile.write('\n')
|
|
172
152
|
|
|
173
|
-
def write_entry(self, what: str, docname: str, filename:
|
|
153
|
+
def write_entry(self, what: str, docname: str, filename: Path, line: int,
|
|
174
154
|
uri: str) -> None:
|
|
175
155
|
self.txt_outfile.write(f'{filename}:{line}: [{what}] {uri}\n')
|
|
176
156
|
|
|
@@ -246,7 +226,7 @@ class HyperlinkCollector(SphinxPostTransform):
|
|
|
246
226
|
class Hyperlink(NamedTuple):
|
|
247
227
|
uri: str
|
|
248
228
|
docname: str
|
|
249
|
-
docpath:
|
|
229
|
+
docpath: Path
|
|
250
230
|
lineno: int
|
|
251
231
|
|
|
252
232
|
|
|
@@ -510,27 +490,6 @@ class HyperlinkAvailabilityCheckWorker(Thread):
|
|
|
510
490
|
|
|
511
491
|
# Unauthorized: the client did not provide required credentials
|
|
512
492
|
if status_code == 401:
|
|
513
|
-
if self._allow_unauthorized:
|
|
514
|
-
deprecation_msg = (
|
|
515
|
-
"\n---\n"
|
|
516
|
-
"The linkcheck builder encountered an HTTP 401 "
|
|
517
|
-
"(unauthorized) response, and will report it as "
|
|
518
|
-
"'working' in this version of Sphinx to maintain "
|
|
519
|
-
"backwards-compatibility."
|
|
520
|
-
"\n"
|
|
521
|
-
"This logic will change in Sphinx 8.0 which will "
|
|
522
|
-
"report the hyperlink as 'broken'."
|
|
523
|
-
"\n"
|
|
524
|
-
"To explicitly continue treating unauthorized "
|
|
525
|
-
"hyperlink responses as 'working', set the "
|
|
526
|
-
"'linkcheck_allow_unauthorized' config option to "
|
|
527
|
-
"``True``."
|
|
528
|
-
"\n"
|
|
529
|
-
"See https://github.com/sphinx-doc/sphinx/issues/11433 "
|
|
530
|
-
"for details."
|
|
531
|
-
"\n---"
|
|
532
|
-
)
|
|
533
|
-
warnings.warn(deprecation_msg, RemovedInSphinx80Warning, stacklevel=1)
|
|
534
493
|
status = 'working' if self._allow_unauthorized else 'broken'
|
|
535
494
|
return status, 'unauthorized', 0
|
|
536
495
|
|
|
@@ -717,8 +676,8 @@ def setup(app: Sphinx) -> ExtensionMetadata:
|
|
|
717
676
|
app.add_config_value('linkcheck_anchors_ignore', ['^!'], '')
|
|
718
677
|
app.add_config_value('linkcheck_anchors_ignore_for_url', (), '', (tuple, list))
|
|
719
678
|
app.add_config_value('linkcheck_rate_limit_timeout', 300.0, '', (int, float))
|
|
720
|
-
app.add_config_value('linkcheck_allow_unauthorized',
|
|
721
|
-
app.add_config_value('linkcheck_report_timeouts_as_broken',
|
|
679
|
+
app.add_config_value('linkcheck_allow_unauthorized', False, '')
|
|
680
|
+
app.add_config_value('linkcheck_report_timeouts_as_broken', False, '', bool)
|
|
722
681
|
|
|
723
682
|
app.add_event('linkcheck-process-uri')
|
|
724
683
|
|
sphinx/builders/texinfo.py
CHANGED
|
@@ -20,9 +20,8 @@ from sphinx.util import logging
|
|
|
20
20
|
from sphinx.util.console import darkgreen
|
|
21
21
|
from sphinx.util.display import progress_message, status_iterator
|
|
22
22
|
from sphinx.util.docutils import new_document
|
|
23
|
-
from sphinx.util.fileutil import copy_asset_file
|
|
24
23
|
from sphinx.util.nodes import inline_all_toctrees
|
|
25
|
-
from sphinx.util.osutil import SEP, ensuredir, make_filename_from_project
|
|
24
|
+
from sphinx.util.osutil import SEP, copyfile, ensuredir, make_filename_from_project
|
|
26
25
|
from sphinx.writers.texinfo import TexinfoTranslator, TexinfoWriter
|
|
27
26
|
|
|
28
27
|
if TYPE_CHECKING:
|
|
@@ -189,10 +188,13 @@ class TexinfoBuilder(Builder):
|
|
|
189
188
|
stringify_func=stringify_func):
|
|
190
189
|
dest = self.images[src]
|
|
191
190
|
try:
|
|
192
|
-
imagedir =
|
|
191
|
+
imagedir = self.outdir / f'{targetname}-figures'
|
|
193
192
|
ensuredir(imagedir)
|
|
194
|
-
|
|
195
|
-
|
|
193
|
+
copyfile(
|
|
194
|
+
self.srcdir / src,
|
|
195
|
+
imagedir / dest,
|
|
196
|
+
force=True,
|
|
197
|
+
)
|
|
196
198
|
except Exception as err:
|
|
197
199
|
logger.warning(__('cannot copy image file %r: %s'),
|
|
198
200
|
path.join(self.srcdir, src), err)
|
|
@@ -201,7 +203,11 @@ class TexinfoBuilder(Builder):
|
|
|
201
203
|
try:
|
|
202
204
|
with progress_message(__('copying Texinfo support files')):
|
|
203
205
|
logger.info('Makefile ', nonl=True)
|
|
204
|
-
|
|
206
|
+
copyfile(
|
|
207
|
+
os.path.join(template_dir, 'Makefile'),
|
|
208
|
+
self.outdir / 'Makefile',
|
|
209
|
+
force=True,
|
|
210
|
+
)
|
|
205
211
|
except OSError as err:
|
|
206
212
|
logger.warning(__("error writing file Makefile: %s"), err)
|
|
207
213
|
|
sphinx/builders/text.py
CHANGED
|
@@ -10,7 +10,11 @@ from docutils.io import StringOutput
|
|
|
10
10
|
from sphinx.builders import Builder
|
|
11
11
|
from sphinx.locale import __
|
|
12
12
|
from sphinx.util import logging
|
|
13
|
-
from sphinx.util.osutil import
|
|
13
|
+
from sphinx.util.osutil import (
|
|
14
|
+
_last_modified_time,
|
|
15
|
+
ensuredir,
|
|
16
|
+
os_path,
|
|
17
|
+
)
|
|
14
18
|
from sphinx.writers.text import TextTranslator, TextWriter
|
|
15
19
|
|
|
16
20
|
if TYPE_CHECKING:
|
|
@@ -46,11 +50,11 @@ class TextBuilder(Builder):
|
|
|
46
50
|
continue
|
|
47
51
|
targetname = path.join(self.outdir, docname + self.out_suffix)
|
|
48
52
|
try:
|
|
49
|
-
targetmtime =
|
|
53
|
+
targetmtime = _last_modified_time(targetname)
|
|
50
54
|
except Exception:
|
|
51
55
|
targetmtime = 0
|
|
52
56
|
try:
|
|
53
|
-
srcmtime =
|
|
57
|
+
srcmtime = _last_modified_time(self.env.doc2path(docname))
|
|
54
58
|
if srcmtime > targetmtime:
|
|
55
59
|
yield docname
|
|
56
60
|
except OSError:
|
sphinx/builders/xml.py
CHANGED
|
@@ -12,7 +12,11 @@ from docutils.writers.docutils_xml import XMLTranslator
|
|
|
12
12
|
from sphinx.builders import Builder
|
|
13
13
|
from sphinx.locale import __
|
|
14
14
|
from sphinx.util import logging
|
|
15
|
-
from sphinx.util.osutil import
|
|
15
|
+
from sphinx.util.osutil import (
|
|
16
|
+
_last_modified_time,
|
|
17
|
+
ensuredir,
|
|
18
|
+
os_path,
|
|
19
|
+
)
|
|
16
20
|
from sphinx.writers.xml import PseudoXMLWriter, XMLWriter
|
|
17
21
|
|
|
18
22
|
if TYPE_CHECKING:
|
|
@@ -52,11 +56,11 @@ class XMLBuilder(Builder):
|
|
|
52
56
|
continue
|
|
53
57
|
targetname = path.join(self.outdir, docname + self.out_suffix)
|
|
54
58
|
try:
|
|
55
|
-
targetmtime =
|
|
59
|
+
targetmtime = _last_modified_time(targetname)
|
|
56
60
|
except Exception:
|
|
57
61
|
targetmtime = 0
|
|
58
62
|
try:
|
|
59
|
-
srcmtime =
|
|
63
|
+
srcmtime = _last_modified_time(self.env.doc2path(docname))
|
|
60
64
|
if srcmtime > targetmtime:
|
|
61
65
|
yield docname
|
|
62
66
|
except OSError:
|
sphinx/cmd/quickstart.py
CHANGED
|
@@ -8,7 +8,7 @@ import os
|
|
|
8
8
|
import sys
|
|
9
9
|
import time
|
|
10
10
|
from os import path
|
|
11
|
-
from typing import TYPE_CHECKING, Any
|
|
11
|
+
from typing import TYPE_CHECKING, Any
|
|
12
12
|
|
|
13
13
|
# try to import readline, unix specific enhancement
|
|
14
14
|
try:
|
|
@@ -36,7 +36,7 @@ from sphinx.util.osutil import ensuredir
|
|
|
36
36
|
from sphinx.util.template import SphinxRenderer
|
|
37
37
|
|
|
38
38
|
if TYPE_CHECKING:
|
|
39
|
-
from collections.abc import Sequence
|
|
39
|
+
from collections.abc import Callable, Sequence
|
|
40
40
|
|
|
41
41
|
EXTENSIONS = {
|
|
42
42
|
'autodoc': __('automatically insert docstrings from modules'),
|
|
@@ -326,7 +326,10 @@ def ask_user(d: dict[str, Any]) -> None:
|
|
|
326
326
|
|
|
327
327
|
|
|
328
328
|
def generate(
|
|
329
|
-
d: dict,
|
|
329
|
+
d: dict[str, Any],
|
|
330
|
+
overwrite: bool = True,
|
|
331
|
+
silent: bool = False,
|
|
332
|
+
templatedir: str | None = None,
|
|
330
333
|
) -> None:
|
|
331
334
|
"""Generate project based on values in *d*."""
|
|
332
335
|
template = QuickstartRenderer(templatedir or '')
|
|
@@ -389,15 +392,8 @@ def generate(
|
|
|
389
392
|
else:
|
|
390
393
|
write_file(masterfile, template.render('quickstart/root_doc.rst.jinja', d))
|
|
391
394
|
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
batchfile_template = 'quickstart/make.bat.new.jinja'
|
|
395
|
-
else:
|
|
396
|
-
# xref RemovedInSphinx80Warning
|
|
397
|
-
msg = "Support for '--no-use-make-mode' will be removed in Sphinx 8."
|
|
398
|
-
print(colorize('red', msg))
|
|
399
|
-
makefile_template = 'quickstart/Makefile.jinja'
|
|
400
|
-
batchfile_template = 'quickstart/make.bat.jinja'
|
|
395
|
+
makefile_template = 'quickstart/Makefile.new.jinja'
|
|
396
|
+
batchfile_template = 'quickstart/make.bat.new.jinja'
|
|
401
397
|
|
|
402
398
|
if d['makefile'] is True:
|
|
403
399
|
d['rsrcdir'] = 'source' if d['sep'] else '.'
|
|
@@ -428,13 +424,9 @@ def generate(
|
|
|
428
424
|
print(__('where "builder" is one of the supported builders, '
|
|
429
425
|
'e.g. html, latex or linkcheck.'))
|
|
430
426
|
print()
|
|
431
|
-
if not d.get('make_mode'):
|
|
432
|
-
# xref RemovedInSphinx80Warning
|
|
433
|
-
msg = "Support for '--no-use-make-mode' will be removed in Sphinx 8."
|
|
434
|
-
print(colorize('red', msg))
|
|
435
427
|
|
|
436
428
|
|
|
437
|
-
def valid_dir(d: dict) -> bool:
|
|
429
|
+
def valid_dir(d: dict[str, Any]) -> bool:
|
|
438
430
|
dir = d['path']
|
|
439
431
|
if not path.exists(dir):
|
|
440
432
|
return True
|
|
@@ -527,12 +519,10 @@ def get_parser() -> argparse.ArgumentParser:
|
|
|
527
519
|
group.add_argument('--no-batchfile', action='store_false',
|
|
528
520
|
dest='batchfile',
|
|
529
521
|
help=__('do not create batchfile'))
|
|
522
|
+
# --use-make-mode is a no-op from Sphinx 8.
|
|
530
523
|
group.add_argument('-m', '--use-make-mode', action='store_true',
|
|
531
524
|
dest='make_mode', default=True,
|
|
532
525
|
help=__('use make-mode for Makefile/make.bat'))
|
|
533
|
-
group.add_argument('-M', '--no-use-make-mode', action='store_false',
|
|
534
|
-
dest='make_mode',
|
|
535
|
-
help=__('do not use make-mode for Makefile/make.bat'))
|
|
536
526
|
|
|
537
527
|
group = parser.add_argument_group(__('Project templating'))
|
|
538
528
|
group.add_argument('-t', '--templatedir', metavar='TEMPLATEDIR',
|
sphinx/config.py
CHANGED
|
@@ -8,14 +8,13 @@ import traceback
|
|
|
8
8
|
import types
|
|
9
9
|
import warnings
|
|
10
10
|
from os import getenv, path
|
|
11
|
-
from typing import TYPE_CHECKING, Any, Literal, NamedTuple
|
|
11
|
+
from typing import TYPE_CHECKING, Any, Literal, NamedTuple
|
|
12
12
|
|
|
13
13
|
from sphinx.deprecation import RemovedInSphinx90Warning
|
|
14
14
|
from sphinx.errors import ConfigError, ExtensionError
|
|
15
15
|
from sphinx.locale import _, __
|
|
16
16
|
from sphinx.util import logging
|
|
17
17
|
from sphinx.util.osutil import fs_encoding
|
|
18
|
-
from sphinx.util.typing import ExtensionMetadata, NoneType
|
|
19
18
|
|
|
20
19
|
if sys.version_info >= (3, 11):
|
|
21
20
|
from contextlib import chdir
|
|
@@ -25,15 +24,16 @@ else:
|
|
|
25
24
|
if TYPE_CHECKING:
|
|
26
25
|
import os
|
|
27
26
|
from collections.abc import Collection, Iterator, Sequence, Set
|
|
27
|
+
from typing import TypeAlias
|
|
28
28
|
|
|
29
29
|
from sphinx.application import Sphinx
|
|
30
30
|
from sphinx.environment import BuildEnvironment
|
|
31
31
|
from sphinx.util.tags import Tags
|
|
32
|
-
from sphinx.util.typing import _ExtensionSetupFunc
|
|
32
|
+
from sphinx.util.typing import ExtensionMetadata, _ExtensionSetupFunc
|
|
33
33
|
|
|
34
34
|
logger = logging.getLogger(__name__)
|
|
35
35
|
|
|
36
|
-
_ConfigRebuild = Literal[
|
|
36
|
+
_ConfigRebuild: TypeAlias = Literal[
|
|
37
37
|
'', 'env', 'epub', 'gettext', 'html',
|
|
38
38
|
# sphinxcontrib-applehelp
|
|
39
39
|
'applehelp',
|
|
@@ -66,7 +66,7 @@ def is_serializable(obj: object, *, _seen: frozenset[int] = frozenset()) -> bool
|
|
|
66
66
|
is_serializable(key, _seen=seen) and is_serializable(value, _seen=seen)
|
|
67
67
|
for key, value in obj.items()
|
|
68
68
|
)
|
|
69
|
-
elif isinstance(obj,
|
|
69
|
+
elif isinstance(obj, list | tuple | set | frozenset):
|
|
70
70
|
seen = _seen | {id(obj)}
|
|
71
71
|
return all(is_serializable(item, _seen=seen) for item in obj)
|
|
72
72
|
|
|
@@ -87,13 +87,13 @@ class ENUM:
|
|
|
87
87
|
self.candidates = candidates
|
|
88
88
|
|
|
89
89
|
def match(self, value: str | list | tuple) -> bool:
|
|
90
|
-
if isinstance(value,
|
|
90
|
+
if isinstance(value, list | tuple):
|
|
91
91
|
return all(item in self.candidates for item in value)
|
|
92
92
|
else:
|
|
93
93
|
return value in self.candidates
|
|
94
94
|
|
|
95
95
|
|
|
96
|
-
_OptValidTypes =
|
|
96
|
+
_OptValidTypes: TypeAlias = tuple[()] | tuple[type, ...] | frozenset[type] | ENUM
|
|
97
97
|
|
|
98
98
|
|
|
99
99
|
class _Opt:
|
|
@@ -244,12 +244,12 @@ class Config:
|
|
|
244
244
|
'template_bridge': _Opt(None, 'html', frozenset((str,))),
|
|
245
245
|
'keep_warnings': _Opt(False, 'env', ()),
|
|
246
246
|
'suppress_warnings': _Opt([], 'env', ()),
|
|
247
|
-
'show_warning_types': _Opt(
|
|
247
|
+
'show_warning_types': _Opt(True, 'env', frozenset((bool,))),
|
|
248
248
|
'modindex_common_prefix': _Opt([], 'html', ()),
|
|
249
249
|
'rst_epilog': _Opt(None, 'env', frozenset((str,))),
|
|
250
250
|
'rst_prolog': _Opt(None, 'env', frozenset((str,))),
|
|
251
251
|
'trim_doctest_flags': _Opt(True, 'env', ()),
|
|
252
|
-
'primary_domain': _Opt('py', 'env', frozenset((NoneType,))),
|
|
252
|
+
'primary_domain': _Opt('py', 'env', frozenset((types.NoneType,))),
|
|
253
253
|
'needs_sphinx': _Opt(None, '', frozenset((str,))),
|
|
254
254
|
'needs_extensions': _Opt({}, '', ()),
|
|
255
255
|
'manpages_url': _Opt(None, 'env', ()),
|
|
@@ -260,7 +260,7 @@ class Config:
|
|
|
260
260
|
'numfig_secnum_depth': _Opt(1, 'env', ()),
|
|
261
261
|
'numfig_format': _Opt({}, 'env', ()), # will be initialized in init_numfig_format()
|
|
262
262
|
'maximum_signature_line_length': _Opt(
|
|
263
|
-
None, 'env', frozenset((int, NoneType))),
|
|
263
|
+
None, 'env', frozenset((int, types.NoneType))),
|
|
264
264
|
'math_number_all': _Opt(False, 'env', ()),
|
|
265
265
|
'math_eqref_format': _Opt(None, 'env', frozenset((str,))),
|
|
266
266
|
'math_numfig': _Opt(True, 'env', ()),
|
|
@@ -549,7 +549,7 @@ def _validate_valid_types(
|
|
|
549
549
|
) -> tuple[()] | tuple[type, ...] | frozenset[type] | ENUM:
|
|
550
550
|
if not valid_types:
|
|
551
551
|
return ()
|
|
552
|
-
if isinstance(valid_types,
|
|
552
|
+
if isinstance(valid_types, frozenset | ENUM):
|
|
553
553
|
return valid_types
|
|
554
554
|
if isinstance(valid_types, type):
|
|
555
555
|
return frozenset((valid_types,))
|
|
@@ -584,7 +584,7 @@ def convert_source_suffix(app: Sphinx, config: Config) -> None:
|
|
|
584
584
|
config.source_suffix = {source_suffix: 'restructuredtext'}
|
|
585
585
|
logger.info(__("Converting `source_suffix = %r` to `source_suffix = %r`."),
|
|
586
586
|
source_suffix, config.source_suffix)
|
|
587
|
-
elif isinstance(source_suffix,
|
|
587
|
+
elif isinstance(source_suffix, list | tuple):
|
|
588
588
|
# if list, considers as all of them are default filetype
|
|
589
589
|
config.source_suffix = dict.fromkeys(source_suffix, 'restructuredtext')
|
|
590
590
|
logger.info(__("Converting `source_suffix = %r` to `source_suffix = %r`."),
|
sphinx/deprecation.py
CHANGED
|
@@ -5,15 +5,15 @@ from __future__ import annotations
|
|
|
5
5
|
import warnings
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
class
|
|
8
|
+
class RemovedInSphinx90Warning(DeprecationWarning):
|
|
9
9
|
pass
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
class
|
|
12
|
+
class RemovedInSphinx10Warning(PendingDeprecationWarning):
|
|
13
13
|
pass
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
RemovedInNextVersionWarning =
|
|
16
|
+
RemovedInNextVersionWarning = RemovedInSphinx90Warning
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
def _deprecation_warning(
|
|
@@ -40,7 +40,7 @@ def _deprecation_warning(
|
|
|
40
40
|
|
|
41
41
|
# deprecated name -> (object to return, canonical path or empty string, removal version)
|
|
42
42
|
_DEPRECATED_OBJECTS = {
|
|
43
|
-
'deprecated_name': (object_to_return, 'fully_qualified_replacement_name', (
|
|
43
|
+
'deprecated_name': (object_to_return, 'fully_qualified_replacement_name', (9, 0)),
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
|
|
@@ -55,10 +55,10 @@ def _deprecation_warning(
|
|
|
55
55
|
_deprecation_warning(__name__, name, canonical_name, remove=remove)
|
|
56
56
|
return deprecated_object
|
|
57
57
|
"""
|
|
58
|
-
if remove == (
|
|
59
|
-
warning_class: type[Warning] =
|
|
60
|
-
elif remove == (
|
|
61
|
-
warning_class =
|
|
58
|
+
if remove == (9, 0):
|
|
59
|
+
warning_class: type[Warning] = RemovedInSphinx90Warning
|
|
60
|
+
elif remove == (10, 0):
|
|
61
|
+
warning_class = RemovedInSphinx10Warning
|
|
62
62
|
else:
|
|
63
63
|
msg = f'removal version {remove!r} is invalid!'
|
|
64
64
|
raise RuntimeError(msg)
|
sphinx/directives/other.py
CHANGED
|
@@ -13,7 +13,6 @@ from docutils.parsers.rst.directives.misc import Include as BaseInclude
|
|
|
13
13
|
from docutils.statemachine import StateMachine
|
|
14
14
|
|
|
15
15
|
from sphinx import addnodes
|
|
16
|
-
from sphinx.domains.changeset import VersionChange # NoQA: F401 # for compatibility
|
|
17
16
|
from sphinx.domains.std import StandardDomain
|
|
18
17
|
from sphinx.locale import _, __
|
|
19
18
|
from sphinx.util import docname_join, logging, url_re
|
|
@@ -145,7 +144,7 @@ class TocTree(SphinxDirective):
|
|
|
145
144
|
continue
|
|
146
145
|
|
|
147
146
|
if docname not in frozen_all_docnames:
|
|
148
|
-
if excluded(self.env.doc2path(docname, False)):
|
|
147
|
+
if excluded(str(self.env.doc2path(docname, False))):
|
|
149
148
|
message = __('toctree contains reference to excluded document %r')
|
|
150
149
|
subtype = 'excluded'
|
|
151
150
|
else:
|
|
@@ -209,7 +208,7 @@ class Author(SphinxDirective):
|
|
|
209
208
|
return ret
|
|
210
209
|
|
|
211
210
|
|
|
212
|
-
class SeeAlso(BaseAdmonition):
|
|
211
|
+
class SeeAlso(BaseAdmonition): # type: ignore[misc]
|
|
213
212
|
"""
|
|
214
213
|
An admonition mentioning things to look at as reference.
|
|
215
214
|
"""
|
sphinx/directives/patches.py
CHANGED
|
@@ -27,7 +27,7 @@ if TYPE_CHECKING:
|
|
|
27
27
|
logger = logging.getLogger(__name__)
|
|
28
28
|
|
|
29
29
|
|
|
30
|
-
class Figure(images.Figure):
|
|
30
|
+
class Figure(images.Figure): # type: ignore[misc]
|
|
31
31
|
"""The figure directive which applies `:name:` option to the figure node
|
|
32
32
|
instead of the image node.
|
|
33
33
|
"""
|
|
@@ -53,7 +53,7 @@ class Figure(images.Figure):
|
|
|
53
53
|
return [figure_node]
|
|
54
54
|
|
|
55
55
|
|
|
56
|
-
class CSVTable(tables.CSVTable):
|
|
56
|
+
class CSVTable(tables.CSVTable): # type: ignore[misc]
|
|
57
57
|
"""The csv-table directive which searches a CSV file from Sphinx project's source
|
|
58
58
|
directory when an absolute path is given via :file: option.
|
|
59
59
|
"""
|
sphinx/domains/__init__.py
CHANGED
|
@@ -8,7 +8,8 @@ from __future__ import annotations
|
|
|
8
8
|
|
|
9
9
|
import copy
|
|
10
10
|
from abc import ABC, abstractmethod
|
|
11
|
-
from
|
|
11
|
+
from collections.abc import Callable
|
|
12
|
+
from typing import TYPE_CHECKING, Any, NamedTuple, cast
|
|
12
13
|
|
|
13
14
|
from docutils.nodes import Element, Node, system_message
|
|
14
15
|
|
|
@@ -17,6 +18,7 @@ from sphinx.locale import _
|
|
|
17
18
|
|
|
18
19
|
if TYPE_CHECKING:
|
|
19
20
|
from collections.abc import Iterable, Sequence
|
|
21
|
+
from typing import TypeAlias
|
|
20
22
|
|
|
21
23
|
from docutils import nodes
|
|
22
24
|
from docutils.parsers.rst import Directive
|
|
@@ -153,7 +155,7 @@ class Index(ABC):
|
|
|
153
155
|
raise NotImplementedError
|
|
154
156
|
|
|
155
157
|
|
|
156
|
-
TitleGetter = Callable[[Node],
|
|
158
|
+
TitleGetter: TypeAlias = Callable[[Node], str | None]
|
|
157
159
|
|
|
158
160
|
|
|
159
161
|
class Domain:
|
sphinx/domains/c/__init__.py
CHANGED
|
@@ -19,7 +19,7 @@ from sphinx.domains.c._ids import _macroKeywords, _max_id
|
|
|
19
19
|
from sphinx.domains.c._parser import DefinitionParser
|
|
20
20
|
from sphinx.domains.c._symbol import Symbol, _DuplicateSymbolError
|
|
21
21
|
from sphinx.locale import _, __
|
|
22
|
-
from sphinx.roles import
|
|
22
|
+
from sphinx.roles import XRefRole
|
|
23
23
|
from sphinx.transforms import SphinxTransform
|
|
24
24
|
from sphinx.transforms.post_transforms import ReferencesResolver
|
|
25
25
|
from sphinx.util import logging
|
|
@@ -29,7 +29,7 @@ from sphinx.util.cfamily import (
|
|
|
29
29
|
anon_identifier_re,
|
|
30
30
|
)
|
|
31
31
|
from sphinx.util.docfields import Field, GroupedField, TypedField
|
|
32
|
-
from sphinx.util.docutils import SphinxDirective
|
|
32
|
+
from sphinx.util.docutils import SphinxDirective, SphinxRole
|
|
33
33
|
from sphinx.util.nodes import make_refnode
|
|
34
34
|
|
|
35
35
|
if TYPE_CHECKING:
|
sphinx/domains/c/_ast.py
CHANGED
|
@@ -12,19 +12,20 @@ from sphinx.util.cfamily import (
|
|
|
12
12
|
ASTAttributeList,
|
|
13
13
|
ASTBaseBase,
|
|
14
14
|
ASTBaseParenExprList,
|
|
15
|
-
StringifyTransform,
|
|
16
15
|
UnsupportedMultiCharacterCharLiteral,
|
|
17
16
|
verify_description_mode,
|
|
18
17
|
)
|
|
19
18
|
|
|
20
19
|
if TYPE_CHECKING:
|
|
20
|
+
from typing import TypeAlias
|
|
21
21
|
|
|
22
22
|
from docutils.nodes import Element, Node, TextElement
|
|
23
23
|
|
|
24
24
|
from sphinx.domains.c._symbol import Symbol
|
|
25
25
|
from sphinx.environment import BuildEnvironment
|
|
26
|
+
from sphinx.util.cfamily import StringifyTransform
|
|
26
27
|
|
|
27
|
-
DeclarationType = Union[
|
|
28
|
+
DeclarationType: TypeAlias = Union[ # NoQA: UP007
|
|
28
29
|
"ASTStruct", "ASTUnion", "ASTEnum", "ASTEnumerator",
|
|
29
30
|
"ASTType", "ASTTypeWithInit", "ASTMacro",
|
|
30
31
|
]
|