Sphinx 7.4.7__py3-none-any.whl → 8.0.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.

Files changed (234) hide show
  1. sphinx/__init__.py +2 -2
  2. sphinx/_cli/__init__.py +4 -4
  3. sphinx/application.py +2 -2
  4. sphinx/builders/__init__.py +2 -3
  5. sphinx/builders/_epub_base.py +33 -12
  6. sphinx/builders/changes.py +13 -5
  7. sphinx/builders/epub3.py +6 -2
  8. sphinx/builders/html/__init__.py +88 -58
  9. sphinx/builders/latex/__init__.py +38 -12
  10. sphinx/builders/latex/transforms.py +1 -1
  11. sphinx/builders/linkcheck.py +8 -49
  12. sphinx/builders/texinfo.py +12 -6
  13. sphinx/builders/text.py +7 -3
  14. sphinx/builders/xml.py +7 -3
  15. sphinx/cmd/quickstart.py +10 -20
  16. sphinx/config.py +13 -13
  17. sphinx/deprecation.py +8 -8
  18. sphinx/directives/other.py +2 -3
  19. sphinx/directives/patches.py +2 -2
  20. sphinx/domains/__init__.py +4 -2
  21. sphinx/domains/c/__init__.py +2 -2
  22. sphinx/domains/c/_ast.py +3 -2
  23. sphinx/domains/c/_parser.py +4 -3
  24. sphinx/domains/cpp/__init__.py +2 -2
  25. sphinx/domains/cpp/_ast.py +1 -2
  26. sphinx/domains/cpp/_parser.py +2 -2
  27. sphinx/domains/cpp/_symbol.py +2 -2
  28. sphinx/domains/math.py +1 -1
  29. sphinx/domains/python/_object.py +0 -1
  30. sphinx/domains/std/__init__.py +7 -8
  31. sphinx/environment/__init__.py +15 -32
  32. sphinx/environment/adapters/indexentries.py +4 -6
  33. sphinx/environment/adapters/toctree.py +4 -4
  34. sphinx/environment/collectors/title.py +1 -1
  35. sphinx/environment/collectors/toctree.py +1 -1
  36. sphinx/events.py +3 -1
  37. sphinx/ext/autodoc/__init__.py +17 -63
  38. sphinx/ext/autodoc/directive.py +7 -5
  39. sphinx/ext/autodoc/importer.py +2 -1
  40. sphinx/ext/autodoc/preserve_defaults.py +2 -2
  41. sphinx/ext/autosummary/__init__.py +7 -6
  42. sphinx/ext/autosummary/generate.py +5 -4
  43. sphinx/ext/doctest.py +5 -5
  44. sphinx/ext/graphviz.py +1 -1
  45. sphinx/ext/imgmath.py +1 -1
  46. sphinx/ext/inheritance_diagram.py +1 -1
  47. sphinx/ext/intersphinx/__init__.py +25 -5
  48. sphinx/ext/intersphinx/_cli.py +7 -6
  49. sphinx/ext/intersphinx/_load.py +240 -115
  50. sphinx/ext/intersphinx/_resolve.py +12 -11
  51. sphinx/ext/intersphinx/_shared.py +102 -9
  52. sphinx/ext/mathjax.py +1 -1
  53. sphinx/ext/napoleon/docstring.py +2 -2
  54. sphinx/ext/todo.py +2 -2
  55. sphinx/ext/viewcode.py +2 -1
  56. sphinx/highlighting.py +3 -3
  57. sphinx/io.py +2 -2
  58. sphinx/jinja2glue.py +13 -6
  59. sphinx/locale/__init__.py +4 -3
  60. sphinx/locale/ar/LC_MESSAGES/sphinx.mo +0 -0
  61. sphinx/locale/ar/LC_MESSAGES/sphinx.po +2383 -2186
  62. sphinx/locale/bg/LC_MESSAGES/sphinx.mo +0 -0
  63. sphinx/locale/bg/LC_MESSAGES/sphinx.po +2249 -2052
  64. sphinx/locale/bn/LC_MESSAGES/sphinx.mo +0 -0
  65. sphinx/locale/bn/LC_MESSAGES/sphinx.po +2412 -2215
  66. sphinx/locale/ca/LC_MESSAGES/sphinx.mo +0 -0
  67. sphinx/locale/ca/LC_MESSAGES/sphinx.po +3029 -2832
  68. sphinx/locale/cak/LC_MESSAGES/sphinx.mo +0 -0
  69. sphinx/locale/cak/LC_MESSAGES/sphinx.po +2308 -2111
  70. sphinx/locale/cs/LC_MESSAGES/sphinx.mo +0 -0
  71. sphinx/locale/cs/LC_MESSAGES/sphinx.po +2469 -2272
  72. sphinx/locale/cy/LC_MESSAGES/sphinx.mo +0 -0
  73. sphinx/locale/cy/LC_MESSAGES/sphinx.po +2393 -2196
  74. sphinx/locale/da/LC_MESSAGES/sphinx.mo +0 -0
  75. sphinx/locale/da/LC_MESSAGES/sphinx.po +2532 -2335
  76. sphinx/locale/de/LC_MESSAGES/sphinx.mo +0 -0
  77. sphinx/locale/de/LC_MESSAGES/sphinx.po +2492 -2295
  78. sphinx/locale/de_DE/LC_MESSAGES/sphinx.mo +0 -0
  79. sphinx/locale/de_DE/LC_MESSAGES/sphinx.po +2250 -2053
  80. sphinx/locale/el/LC_MESSAGES/sphinx.mo +0 -0
  81. sphinx/locale/el/LC_MESSAGES/sphinx.po +2879 -2682
  82. sphinx/locale/en_DE/LC_MESSAGES/sphinx.mo +0 -0
  83. sphinx/locale/en_DE/LC_MESSAGES/sphinx.po +2250 -2053
  84. sphinx/locale/en_FR/LC_MESSAGES/sphinx.mo +0 -0
  85. sphinx/locale/en_FR/LC_MESSAGES/sphinx.po +2250 -2053
  86. sphinx/locale/en_GB/LC_MESSAGES/sphinx.mo +0 -0
  87. sphinx/locale/en_GB/LC_MESSAGES/sphinx.po +2989 -2792
  88. sphinx/locale/en_HK/LC_MESSAGES/sphinx.mo +0 -0
  89. sphinx/locale/en_HK/LC_MESSAGES/sphinx.po +2250 -2053
  90. sphinx/locale/eo/LC_MESSAGES/sphinx.mo +0 -0
  91. sphinx/locale/eo/LC_MESSAGES/sphinx.po +2297 -2100
  92. sphinx/locale/es/LC_MESSAGES/sphinx.mo +0 -0
  93. sphinx/locale/es/LC_MESSAGES/sphinx.po +3017 -2820
  94. sphinx/locale/es_CO/LC_MESSAGES/sphinx.mo +0 -0
  95. sphinx/locale/es_CO/LC_MESSAGES/sphinx.po +2250 -2053
  96. sphinx/locale/et/LC_MESSAGES/sphinx.mo +0 -0
  97. sphinx/locale/et/LC_MESSAGES/sphinx.po +2748 -2551
  98. sphinx/locale/eu/LC_MESSAGES/sphinx.mo +0 -0
  99. sphinx/locale/eu/LC_MESSAGES/sphinx.po +2459 -2262
  100. sphinx/locale/fa/LC_MESSAGES/sphinx.mo +0 -0
  101. sphinx/locale/fa/LC_MESSAGES/sphinx.po +2957 -2760
  102. sphinx/locale/fi/LC_MESSAGES/sphinx.mo +0 -0
  103. sphinx/locale/fi/LC_MESSAGES/sphinx.po +2321 -2124
  104. sphinx/locale/fr/LC_MESSAGES/sphinx.mo +0 -0
  105. sphinx/locale/fr/LC_MESSAGES/sphinx.po +2977 -2780
  106. sphinx/locale/fr_FR/LC_MESSAGES/sphinx.mo +0 -0
  107. sphinx/locale/fr_FR/LC_MESSAGES/sphinx.po +2250 -2053
  108. sphinx/locale/gl/LC_MESSAGES/sphinx.mo +0 -0
  109. sphinx/locale/gl/LC_MESSAGES/sphinx.po +2992 -2795
  110. sphinx/locale/he/LC_MESSAGES/sphinx.mo +0 -0
  111. sphinx/locale/he/LC_MESSAGES/sphinx.po +2375 -2178
  112. sphinx/locale/hi/LC_MESSAGES/sphinx.mo +0 -0
  113. sphinx/locale/hi/LC_MESSAGES/sphinx.po +2937 -2740
  114. sphinx/locale/hi_IN/LC_MESSAGES/sphinx.mo +0 -0
  115. sphinx/locale/hi_IN/LC_MESSAGES/sphinx.po +2250 -2053
  116. sphinx/locale/hr/LC_MESSAGES/sphinx.mo +0 -0
  117. sphinx/locale/hr/LC_MESSAGES/sphinx.po +2532 -2335
  118. sphinx/locale/hu/LC_MESSAGES/sphinx.mo +0 -0
  119. sphinx/locale/hu/LC_MESSAGES/sphinx.po +2505 -2308
  120. sphinx/locale/id/LC_MESSAGES/sphinx.mo +0 -0
  121. sphinx/locale/id/LC_MESSAGES/sphinx.po +2925 -2728
  122. sphinx/locale/is/LC_MESSAGES/sphinx.mo +0 -0
  123. sphinx/locale/is/LC_MESSAGES/sphinx.po +2307 -2110
  124. sphinx/locale/it/LC_MESSAGES/sphinx.mo +0 -0
  125. sphinx/locale/it/LC_MESSAGES/sphinx.po +2514 -2317
  126. sphinx/locale/ja/LC_MESSAGES/sphinx.mo +0 -0
  127. sphinx/locale/ja/LC_MESSAGES/sphinx.po +2970 -2773
  128. sphinx/locale/ka/LC_MESSAGES/sphinx.mo +0 -0
  129. sphinx/locale/ka/LC_MESSAGES/sphinx.po +2868 -2671
  130. sphinx/locale/ko/LC_MESSAGES/sphinx.mo +0 -0
  131. sphinx/locale/ko/LC_MESSAGES/sphinx.po +3016 -2819
  132. sphinx/locale/lt/LC_MESSAGES/sphinx.mo +0 -0
  133. sphinx/locale/lt/LC_MESSAGES/sphinx.po +2476 -2279
  134. sphinx/locale/lv/LC_MESSAGES/sphinx.mo +0 -0
  135. sphinx/locale/lv/LC_MESSAGES/sphinx.po +2477 -2280
  136. sphinx/locale/mk/LC_MESSAGES/sphinx.mo +0 -0
  137. sphinx/locale/mk/LC_MESSAGES/sphinx.po +2292 -2095
  138. sphinx/locale/nb_NO/LC_MESSAGES/sphinx.mo +0 -0
  139. sphinx/locale/nb_NO/LC_MESSAGES/sphinx.po +2479 -2282
  140. sphinx/locale/ne/LC_MESSAGES/sphinx.mo +0 -0
  141. sphinx/locale/ne/LC_MESSAGES/sphinx.po +2481 -2284
  142. sphinx/locale/nl/LC_MESSAGES/sphinx.mo +0 -0
  143. sphinx/locale/nl/LC_MESSAGES/sphinx.po +2557 -2360
  144. sphinx/locale/pl/LC_MESSAGES/sphinx.mo +0 -0
  145. sphinx/locale/pl/LC_MESSAGES/sphinx.po +2696 -2499
  146. sphinx/locale/pt/LC_MESSAGES/sphinx.mo +0 -0
  147. sphinx/locale/pt/LC_MESSAGES/sphinx.po +2250 -2053
  148. sphinx/locale/pt_BR/LC_MESSAGES/sphinx.mo +0 -0
  149. sphinx/locale/pt_BR/LC_MESSAGES/sphinx.po +2979 -2782
  150. sphinx/locale/pt_PT/LC_MESSAGES/sphinx.mo +0 -0
  151. sphinx/locale/pt_PT/LC_MESSAGES/sphinx.po +2469 -2272
  152. sphinx/locale/ro/LC_MESSAGES/sphinx.mo +0 -0
  153. sphinx/locale/ro/LC_MESSAGES/sphinx.po +2473 -2276
  154. sphinx/locale/ru/LC_MESSAGES/sphinx.mo +0 -0
  155. sphinx/locale/ru/LC_MESSAGES/sphinx.po +2746 -2549
  156. sphinx/locale/si/LC_MESSAGES/sphinx.mo +0 -0
  157. sphinx/locale/si/LC_MESSAGES/sphinx.po +2331 -2134
  158. sphinx/locale/sk/LC_MESSAGES/sphinx.mo +0 -0
  159. sphinx/locale/sk/LC_MESSAGES/sphinx.po +2966 -2769
  160. sphinx/locale/sl/LC_MESSAGES/sphinx.mo +0 -0
  161. sphinx/locale/sl/LC_MESSAGES/sphinx.po +2404 -2207
  162. sphinx/locale/sphinx.pot +2262 -2065
  163. sphinx/locale/sq/LC_MESSAGES/sphinx.mo +0 -0
  164. sphinx/locale/sq/LC_MESSAGES/sphinx.po +2972 -2775
  165. sphinx/locale/sr/LC_MESSAGES/sphinx.mo +0 -0
  166. sphinx/locale/sr/LC_MESSAGES/sphinx.po +2440 -2243
  167. sphinx/locale/sv/LC_MESSAGES/sphinx.mo +0 -0
  168. sphinx/locale/sv/LC_MESSAGES/sphinx.po +2483 -2286
  169. sphinx/locale/te/LC_MESSAGES/sphinx.mo +0 -0
  170. sphinx/locale/te/LC_MESSAGES/sphinx.po +2250 -2053
  171. sphinx/locale/tr/LC_MESSAGES/sphinx.mo +0 -0
  172. sphinx/locale/tr/LC_MESSAGES/sphinx.po +2892 -2695
  173. sphinx/locale/uk_UA/LC_MESSAGES/sphinx.mo +0 -0
  174. sphinx/locale/uk_UA/LC_MESSAGES/sphinx.po +2400 -2203
  175. sphinx/locale/ur/LC_MESSAGES/sphinx.mo +0 -0
  176. sphinx/locale/ur/LC_MESSAGES/sphinx.po +2250 -2053
  177. sphinx/locale/vi/LC_MESSAGES/sphinx.mo +0 -0
  178. sphinx/locale/vi/LC_MESSAGES/sphinx.po +2422 -2225
  179. sphinx/locale/yue/LC_MESSAGES/sphinx.mo +0 -0
  180. sphinx/locale/yue/LC_MESSAGES/sphinx.po +2250 -2053
  181. sphinx/locale/zh_HK/LC_MESSAGES/sphinx.mo +0 -0
  182. sphinx/locale/zh_HK/LC_MESSAGES/sphinx.po +2250 -2053
  183. sphinx/locale/zh_TW/LC_MESSAGES/sphinx.mo +0 -0
  184. sphinx/locale/zh_TW/LC_MESSAGES/sphinx.po +3028 -2831
  185. sphinx/locale/zh_TW.Big5/LC_MESSAGES/sphinx.mo +0 -0
  186. sphinx/locale/zh_TW.Big5/LC_MESSAGES/sphinx.po +2250 -2053
  187. sphinx/project.py +25 -20
  188. sphinx/pycode/ast.py +2 -2
  189. sphinx/pycode/parser.py +2 -2
  190. sphinx/pygments_styles.py +3 -3
  191. sphinx/registry.py +3 -8
  192. sphinx/search/__init__.py +1 -1
  193. sphinx/testing/path.py +2 -1
  194. sphinx/testing/util.py +1 -1
  195. sphinx/texinputs/Makefile.jinja +2 -1
  196. sphinx/texinputs_win/Makefile.jinja +2 -1
  197. sphinx/theming.py +3 -12
  198. sphinx/transforms/__init__.py +5 -5
  199. sphinx/transforms/references.py +1 -1
  200. sphinx/util/__init__.py +11 -35
  201. sphinx/util/_pathlib.py +31 -19
  202. sphinx/util/_timestamps.py +12 -0
  203. sphinx/util/cfamily.py +5 -5
  204. sphinx/util/console.py +4 -3
  205. sphinx/util/display.py +3 -3
  206. sphinx/util/docfields.py +1 -1
  207. sphinx/util/docutils.py +44 -10
  208. sphinx/util/fileutil.py +25 -20
  209. sphinx/util/i18n.py +9 -4
  210. sphinx/util/images.py +3 -2
  211. sphinx/util/inspect.py +28 -43
  212. sphinx/util/inventory.py +2 -2
  213. sphinx/util/matching.py +2 -2
  214. sphinx/util/math.py +1 -1
  215. sphinx/util/nodes.py +8 -8
  216. sphinx/util/osutil.py +36 -32
  217. sphinx/util/parallel.py +2 -2
  218. sphinx/util/requests.py +1 -1
  219. sphinx/util/template.py +3 -3
  220. sphinx/util/typing.py +36 -72
  221. sphinx/writers/html.py +1 -1
  222. sphinx/writers/html5.py +1 -1
  223. sphinx/writers/latex.py +4 -4
  224. sphinx/writers/manpage.py +2 -2
  225. sphinx/writers/texinfo.py +5 -5
  226. sphinx/writers/text.py +4 -4
  227. sphinx/writers/xml.py +2 -2
  228. {sphinx-7.4.7.dist-info → sphinx-8.0.0.dist-info}/METADATA +11 -10
  229. {sphinx-7.4.7.dist-info → sphinx-8.0.0.dist-info}/RECORD +232 -233
  230. sphinx/templates/quickstart/Makefile.jinja +0 -98
  231. sphinx/templates/quickstart/make.bat.jinja +0 -110
  232. {sphinx-7.4.7.dist-info → sphinx-8.0.0.dist-info}/LICENSE.rst +0 -0
  233. {sphinx-7.4.7.dist-info → sphinx-8.0.0.dist-info}/WHEEL +0 -0
  234. {sphinx-7.4.7.dist-info → sphinx-8.0.0.dist-info}/entry_points.txt +0 -0
@@ -2,19 +2,113 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
- from typing import TYPE_CHECKING, Final, Union
5
+ from typing import TYPE_CHECKING, Any, Final, NoReturn
6
6
 
7
7
  from sphinx.util import logging
8
8
 
9
9
  if TYPE_CHECKING:
10
+ from collections.abc import Sequence
11
+ from typing import TypeAlias
12
+
10
13
  from sphinx.environment import BuildEnvironment
11
14
  from sphinx.util.typing import Inventory
12
15
 
13
- InventoryCacheEntry = tuple[Union[str, None], int, Inventory]
16
+ #: The inventory project URL to which links are resolved.
17
+ #:
18
+ #: This value is unique in :confval:`intersphinx_mapping`.
19
+ InventoryURI = str
20
+
21
+ #: The inventory (non-empty) name.
22
+ #:
23
+ #: It is unique and in bijection with an inventory remote URL.
24
+ InventoryName = str
25
+
26
+ #: A target (local or remote) containing the inventory data to fetch.
27
+ #:
28
+ #: Empty strings are not expected and ``None`` indicates the default
29
+ #: inventory file name :data:`~sphinx.builder.html.INVENTORY_FILENAME`.
30
+ InventoryLocation = str | None
31
+
32
+ #: Inventory cache entry. The integer field is the cache expiration time.
33
+ InventoryCacheEntry: TypeAlias = tuple[InventoryName, int, Inventory]
34
+
35
+ #: The type of :confval:`intersphinx_mapping` *after* normalisation.
36
+ IntersphinxMapping = dict[
37
+ InventoryName,
38
+ tuple[InventoryName, tuple[InventoryURI, tuple[InventoryLocation, ...]]],
39
+ ]
14
40
 
15
41
  LOGGER: Final[logging.SphinxLoggerAdapter] = logging.getLogger('sphinx.ext.intersphinx')
16
42
 
17
43
 
44
+ class _IntersphinxProject:
45
+ name: InventoryName
46
+ target_uri: InventoryURI
47
+ locations: tuple[InventoryLocation, ...]
48
+
49
+ __slots__ = {
50
+ 'name': 'The inventory name. '
51
+ 'It is unique and in bijection with an remote inventory URL.',
52
+ 'target_uri': 'The inventory project URL to which links are resolved. '
53
+ 'It is unique and in bijection with an inventory name.',
54
+ 'locations': 'A tuple of local or remote targets containing '
55
+ 'the inventory data to fetch. '
56
+ 'None indicates the default inventory file name.',
57
+ }
58
+
59
+ def __init__(
60
+ self,
61
+ *,
62
+ name: InventoryName,
63
+ target_uri: InventoryURI,
64
+ locations: Sequence[InventoryLocation],
65
+ ) -> None:
66
+ if not name or not isinstance(name, str):
67
+ msg = 'name must be a non-empty string'
68
+ raise ValueError(msg)
69
+ if not target_uri or not isinstance(target_uri, str):
70
+ msg = 'target_uri must be a non-empty string'
71
+ raise ValueError(msg)
72
+ if not locations or not isinstance(locations, tuple):
73
+ msg = 'locations must be a non-empty tuple'
74
+ raise ValueError(msg)
75
+ if any(
76
+ location is not None and (not location or not isinstance(location, str))
77
+ for location in locations
78
+ ):
79
+ msg = 'locations must be a tuple of strings or None'
80
+ raise ValueError(msg)
81
+ object.__setattr__(self, 'name', name)
82
+ object.__setattr__(self, 'target_uri', target_uri)
83
+ object.__setattr__(self, 'locations', tuple(locations))
84
+
85
+ def __repr__(self) -> str:
86
+ return (f'{self.__class__.__name__}('
87
+ f'name={self.name!r}, '
88
+ f'target_uri={self.target_uri!r}, '
89
+ f'locations={self.locations!r})')
90
+
91
+ def __eq__(self, other: object) -> bool:
92
+ if not isinstance(other, _IntersphinxProject):
93
+ return NotImplemented
94
+ return (
95
+ self.name == other.name
96
+ and self.target_uri == other.target_uri
97
+ and self.locations == other.locations
98
+ )
99
+
100
+ def __hash__(self) -> int:
101
+ return hash((self.name, self.target_uri, self.locations))
102
+
103
+ def __setattr__(self, key: str, value: Any) -> NoReturn:
104
+ msg = f'{self.__class__.__name__} is immutable'
105
+ raise AttributeError(msg)
106
+
107
+ def __delattr__(self, key: str) -> NoReturn:
108
+ msg = f'{self.__class__.__name__} is immutable'
109
+ raise AttributeError(msg)
110
+
111
+
18
112
  class InventoryAdapter:
19
113
  """Inventory adapter for environment"""
20
114
 
@@ -29,14 +123,13 @@ class InventoryAdapter:
29
123
  self.env.intersphinx_named_inventory = {} # type: ignore[attr-defined]
30
124
 
31
125
  @property
32
- def cache(self) -> dict[str, InventoryCacheEntry]:
126
+ def cache(self) -> dict[InventoryURI, InventoryCacheEntry]:
33
127
  """Intersphinx cache.
34
128
 
35
- - Key is the URI of the remote inventory
36
- - Element one is the key given in the Sphinx intersphinx_mapping
37
- configuration value
38
- - Element two is a time value for cache invalidation, a float
39
- - Element three is the loaded remote inventory, type Inventory
129
+ - Key is the URI of the remote inventory.
130
+ - Element one is the key given in the Sphinx :confval:`intersphinx_mapping`.
131
+ - Element two is a time value for cache invalidation, an integer.
132
+ - Element three is the loaded remote inventory of type :class:`!Inventory`.
40
133
  """
41
134
  return self.env.intersphinx_cache # type: ignore[attr-defined]
42
135
 
@@ -45,7 +138,7 @@ class InventoryAdapter:
45
138
  return self.env.intersphinx_inventory # type: ignore[attr-defined]
46
139
 
47
140
  @property
48
- def named_inventory(self) -> dict[str, Inventory]:
141
+ def named_inventory(self) -> dict[InventoryName, Inventory]:
49
142
  return self.env.intersphinx_named_inventory # type: ignore[attr-defined]
50
143
 
51
144
  def clear(self) -> None:
sphinx/ext/mathjax.py CHANGED
@@ -22,7 +22,7 @@ from sphinx.util.math import get_node_equation_number
22
22
  if TYPE_CHECKING:
23
23
  from sphinx.application import Sphinx
24
24
  from sphinx.util.typing import ExtensionMetadata
25
- from sphinx.writers.html import HTML5Translator
25
+ from sphinx.writers.html5 import HTML5Translator
26
26
 
27
27
  # more information for mathjax secure url is here:
28
28
  # https://docs.mathjax.org/en/latest/web/start.html#using-mathjax-from-a-content-delivery-network-cdn
@@ -8,14 +8,14 @@ import inspect
8
8
  import re
9
9
  from functools import partial
10
10
  from itertools import starmap
11
- from typing import TYPE_CHECKING, Any, Callable
11
+ from typing import TYPE_CHECKING, Any
12
12
 
13
13
  from sphinx.locale import _, __
14
14
  from sphinx.util import logging
15
15
  from sphinx.util.typing import get_type_hints, stringify_annotation
16
16
 
17
17
  if TYPE_CHECKING:
18
- from collections.abc import Iterator
18
+ from collections.abc import Callable, Iterator
19
19
 
20
20
  from sphinx.application import Sphinx
21
21
  from sphinx.config import Config as SphinxConfig
sphinx/ext/todo.py CHANGED
@@ -29,7 +29,7 @@ if TYPE_CHECKING:
29
29
  from sphinx.application import Sphinx
30
30
  from sphinx.environment import BuildEnvironment
31
31
  from sphinx.util.typing import ExtensionMetadata, OptionSpec
32
- from sphinx.writers.html import HTML5Translator
32
+ from sphinx.writers.html5 import HTML5Translator
33
33
  from sphinx.writers.latex import LaTeXTranslator
34
34
 
35
35
  logger = logging.getLogger(__name__)
@@ -43,7 +43,7 @@ class todolist(nodes.General, nodes.Element):
43
43
  pass
44
44
 
45
45
 
46
- class Todo(BaseAdmonition, SphinxDirective):
46
+ class Todo(BaseAdmonition, SphinxDirective): # type: ignore[misc]
47
47
  """
48
48
  A todo entry, displayed (if configured) in the form of an admonition.
49
49
  """
sphinx/ext/viewcode.py CHANGED
@@ -21,6 +21,7 @@ from sphinx.transforms.post_transforms import SphinxPostTransform
21
21
  from sphinx.util import logging
22
22
  from sphinx.util.display import status_iterator
23
23
  from sphinx.util.nodes import make_refnode
24
+ from sphinx.util.osutil import _last_modified_time
24
25
 
25
26
  if TYPE_CHECKING:
26
27
  from collections.abc import Iterable, Iterator
@@ -231,7 +232,7 @@ def should_generate_module_page(app: Sphinx, modname: str) -> bool:
231
232
  page_filename = path.join(app.outdir, '_modules/', basename)
232
233
 
233
234
  try:
234
- if path.getmtime(module_filename) <= path.getmtime(page_filename):
235
+ if _last_modified_time(module_filename) <= _last_modified_time(page_filename):
235
236
  # generation is not needed if the HTML page is newer than module file.
236
237
  return False
237
238
  except OSError:
sphinx/highlighting.py CHANGED
@@ -86,8 +86,8 @@ _LATEX_ADD_STYLES = r"""
86
86
  class PygmentsBridge:
87
87
  # Set these attributes if you want to have different Pygments formatters
88
88
  # than the default ones.
89
- html_formatter = HtmlFormatter
90
- latex_formatter = LatexFormatter
89
+ html_formatter = HtmlFormatter[str]
90
+ latex_formatter = LatexFormatter[str]
91
91
 
92
92
  def __init__(
93
93
  self, dest: str = 'html', stylename: str = 'sphinx', latex_engine: str | None = None
@@ -98,7 +98,7 @@ class PygmentsBridge:
98
98
  style = self.get_style(stylename)
99
99
  self.formatter_args: dict[str, Any] = {'style': style}
100
100
  if dest == 'html':
101
- self.formatter = self.html_formatter
101
+ self.formatter: type[Formatter[str]] = self.html_formatter
102
102
  else:
103
103
  self.formatter = self.latex_formatter
104
104
  self.formatter_args['commandprefix'] = 'PYG'
sphinx/io.py CHANGED
@@ -35,7 +35,7 @@ if TYPE_CHECKING:
35
35
  logger = logging.getLogger(__name__)
36
36
 
37
37
 
38
- class SphinxBaseReader(standalone.Reader):
38
+ class SphinxBaseReader(standalone.Reader): # type: ignore[misc]
39
39
  """
40
40
  A base class of readers for Sphinx.
41
41
 
@@ -143,7 +143,7 @@ class SphinxI18nReader(SphinxBaseReader):
143
143
  self.transforms.remove(transform)
144
144
 
145
145
 
146
- class SphinxDummyWriter(UnfilteredWriter):
146
+ class SphinxDummyWriter(UnfilteredWriter): # type: ignore[misc]
147
147
  """Dummy writer module used for generating doctree."""
148
148
 
149
149
  supported = ('html',) # needed to keep "meta" nodes
sphinx/jinja2glue.py CHANGED
@@ -2,9 +2,10 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
+ import os
5
6
  from os import path
6
7
  from pprint import pformat
7
- from typing import TYPE_CHECKING, Any, Callable
8
+ from typing import TYPE_CHECKING, Any
8
9
 
9
10
  from jinja2 import BaseLoader, FileSystemLoader, TemplateNotFound
10
11
  from jinja2.sandbox import SandboxedEnvironment
@@ -12,10 +13,10 @@ from jinja2.utils import open_if_exists, pass_context
12
13
 
13
14
  from sphinx.application import TemplateBridge
14
15
  from sphinx.util import logging
15
- from sphinx.util.osutil import mtimes_of_files
16
+ from sphinx.util.osutil import _last_modified_time
16
17
 
17
18
  if TYPE_CHECKING:
18
- from collections.abc import Iterator
19
+ from collections.abc import Callable, Iterator
19
20
 
20
21
  from jinja2.environment import Environment
21
22
 
@@ -127,11 +128,11 @@ class SphinxFileSystemLoader(FileSystemLoader):
127
128
  with f:
128
129
  contents = f.read().decode(self.encoding)
129
130
 
130
- mtime = path.getmtime(filename)
131
+ mtime = _last_modified_time(filename)
131
132
 
132
133
  def uptodate() -> bool:
133
134
  try:
134
- return path.getmtime(filename) == mtime
135
+ return _last_modified_time(filename) == mtime
135
136
  except OSError:
136
137
  return False
137
138
 
@@ -203,7 +204,13 @@ class BuiltinTemplateLoader(TemplateBridge, BaseLoader):
203
204
  return self.environment.from_string(source).render(context)
204
205
 
205
206
  def newest_template_mtime(self) -> float:
206
- return max(mtimes_of_files(self.pathchain, '.html'))
207
+ return max(
208
+ os.stat(os.path.join(root, sfile)).st_mtime_ns / 10**9
209
+ for dirname in self.pathchain
210
+ for root, _dirs, files in os.walk(dirname)
211
+ for sfile in files
212
+ if sfile.endswith('.html')
213
+ )
207
214
 
208
215
  # Loader interface
209
216
 
sphinx/locale/__init__.py CHANGED
@@ -9,8 +9,9 @@ from os import path
9
9
  from typing import TYPE_CHECKING
10
10
 
11
11
  if TYPE_CHECKING:
12
- from collections.abc import Iterable
13
- from typing import Any, Callable
12
+ import os
13
+ from collections.abc import Callable, Iterable
14
+ from typing import Any
14
15
 
15
16
 
16
17
  class _TranslationProxy:
@@ -98,7 +99,7 @@ translators: dict[tuple[str, str], NullTranslations] = {}
98
99
 
99
100
 
100
101
  def init(
101
- locale_dirs: Iterable[str | None],
102
+ locale_dirs: Iterable[str | os.PathLike[str] | None],
102
103
  language: str | None,
103
104
  catalog: str = 'sphinx',
104
105
  namespace: str = 'general',
Binary file