Sphinx 8.2.0rc2__py3-none-any.whl → 8.3.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 (156) hide show
  1. sphinx/__init__.py +19 -18
  2. sphinx/application.py +1 -0
  3. sphinx/deprecation.py +7 -0
  4. sphinx/ext/apidoc/_extension.py +2 -1
  5. sphinx/ext/autodoc/__init__.py +1 -1
  6. sphinx/ext/autodoc/directive.py +1 -1
  7. sphinx/ext/autodoc/mock.py +1 -1
  8. sphinx/ext/napoleon/__init__.py +23 -24
  9. sphinx/ext/viewcode.py +12 -8
  10. sphinx/highlighting.py +1 -1
  11. sphinx/locale/__init__.py +4 -3
  12. sphinx/locale/ar/LC_MESSAGES/sphinx.mo +0 -0
  13. sphinx/locale/ar/LC_MESSAGES/sphinx.po +2155 -2050
  14. sphinx/locale/bg/LC_MESSAGES/sphinx.mo +0 -0
  15. sphinx/locale/bg/LC_MESSAGES/sphinx.po +2045 -1940
  16. sphinx/locale/bn/LC_MESSAGES/sphinx.mo +0 -0
  17. sphinx/locale/bn/LC_MESSAGES/sphinx.po +2175 -2070
  18. sphinx/locale/ca/LC_MESSAGES/sphinx.js +3 -3
  19. sphinx/locale/ca/LC_MESSAGES/sphinx.mo +0 -0
  20. sphinx/locale/ca/LC_MESSAGES/sphinx.po +2690 -2585
  21. sphinx/locale/ca@valencia/LC_MESSAGES/sphinx.js +63 -0
  22. sphinx/locale/ca@valencia/LC_MESSAGES/sphinx.mo +0 -0
  23. sphinx/locale/ca@valencia/LC_MESSAGES/sphinx.po +4216 -0
  24. sphinx/locale/cak/LC_MESSAGES/sphinx.mo +0 -0
  25. sphinx/locale/cak/LC_MESSAGES/sphinx.po +2096 -1991
  26. sphinx/locale/cs/LC_MESSAGES/sphinx.mo +0 -0
  27. sphinx/locale/cs/LC_MESSAGES/sphinx.po +2248 -2143
  28. sphinx/locale/cy/LC_MESSAGES/sphinx.mo +0 -0
  29. sphinx/locale/cy/LC_MESSAGES/sphinx.po +2201 -2096
  30. sphinx/locale/da/LC_MESSAGES/sphinx.mo +0 -0
  31. sphinx/locale/da/LC_MESSAGES/sphinx.po +2282 -2177
  32. sphinx/locale/de/LC_MESSAGES/sphinx.mo +0 -0
  33. sphinx/locale/de/LC_MESSAGES/sphinx.po +2261 -2156
  34. sphinx/locale/de_DE/LC_MESSAGES/sphinx.mo +0 -0
  35. sphinx/locale/de_DE/LC_MESSAGES/sphinx.po +2045 -1940
  36. sphinx/locale/el/LC_MESSAGES/sphinx.mo +0 -0
  37. sphinx/locale/el/LC_MESSAGES/sphinx.po +2604 -2499
  38. sphinx/locale/en_DE/LC_MESSAGES/sphinx.mo +0 -0
  39. sphinx/locale/en_DE/LC_MESSAGES/sphinx.po +2045 -1940
  40. sphinx/locale/en_FR/LC_MESSAGES/sphinx.mo +0 -0
  41. sphinx/locale/en_FR/LC_MESSAGES/sphinx.po +2045 -1940
  42. sphinx/locale/en_GB/LC_MESSAGES/sphinx.mo +0 -0
  43. sphinx/locale/en_GB/LC_MESSAGES/sphinx.po +2631 -2526
  44. sphinx/locale/en_HK/LC_MESSAGES/sphinx.mo +0 -0
  45. sphinx/locale/en_HK/LC_MESSAGES/sphinx.po +2045 -1940
  46. sphinx/locale/eo/LC_MESSAGES/sphinx.mo +0 -0
  47. sphinx/locale/eo/LC_MESSAGES/sphinx.po +2078 -1973
  48. sphinx/locale/es/LC_MESSAGES/sphinx.mo +0 -0
  49. sphinx/locale/es/LC_MESSAGES/sphinx.po +2633 -2528
  50. sphinx/locale/es_CO/LC_MESSAGES/sphinx.mo +0 -0
  51. sphinx/locale/es_CO/LC_MESSAGES/sphinx.po +2045 -1940
  52. sphinx/locale/et/LC_MESSAGES/sphinx.mo +0 -0
  53. sphinx/locale/et/LC_MESSAGES/sphinx.po +2449 -2344
  54. sphinx/locale/eu/LC_MESSAGES/sphinx.mo +0 -0
  55. sphinx/locale/eu/LC_MESSAGES/sphinx.po +2241 -2136
  56. sphinx/locale/fa/LC_MESSAGES/sphinx.mo +0 -0
  57. sphinx/locale/fa/LC_MESSAGES/sphinx.po +504 -500
  58. sphinx/locale/fi/LC_MESSAGES/sphinx.mo +0 -0
  59. sphinx/locale/fi/LC_MESSAGES/sphinx.po +499 -495
  60. sphinx/locale/fr/LC_MESSAGES/sphinx.mo +0 -0
  61. sphinx/locale/fr/LC_MESSAGES/sphinx.po +513 -509
  62. sphinx/locale/fr_FR/LC_MESSAGES/sphinx.mo +0 -0
  63. sphinx/locale/fr_FR/LC_MESSAGES/sphinx.po +499 -495
  64. sphinx/locale/gl/LC_MESSAGES/sphinx.mo +0 -0
  65. sphinx/locale/gl/LC_MESSAGES/sphinx.po +2644 -2539
  66. sphinx/locale/he/LC_MESSAGES/sphinx.mo +0 -0
  67. sphinx/locale/he/LC_MESSAGES/sphinx.po +499 -495
  68. sphinx/locale/hi/LC_MESSAGES/sphinx.mo +0 -0
  69. sphinx/locale/hi/LC_MESSAGES/sphinx.po +504 -500
  70. sphinx/locale/hi_IN/LC_MESSAGES/sphinx.mo +0 -0
  71. sphinx/locale/hi_IN/LC_MESSAGES/sphinx.po +499 -495
  72. sphinx/locale/hr/LC_MESSAGES/sphinx.mo +0 -0
  73. sphinx/locale/hr/LC_MESSAGES/sphinx.po +501 -497
  74. sphinx/locale/hu/LC_MESSAGES/sphinx.mo +0 -0
  75. sphinx/locale/hu/LC_MESSAGES/sphinx.po +499 -495
  76. sphinx/locale/id/LC_MESSAGES/sphinx.mo +0 -0
  77. sphinx/locale/id/LC_MESSAGES/sphinx.po +2609 -2504
  78. sphinx/locale/is/LC_MESSAGES/sphinx.mo +0 -0
  79. sphinx/locale/is/LC_MESSAGES/sphinx.po +499 -495
  80. sphinx/locale/it/LC_MESSAGES/sphinx.mo +0 -0
  81. sphinx/locale/it/LC_MESSAGES/sphinx.po +2265 -2160
  82. sphinx/locale/ja/LC_MESSAGES/sphinx.mo +0 -0
  83. sphinx/locale/ja/LC_MESSAGES/sphinx.po +2621 -2516
  84. sphinx/locale/ka/LC_MESSAGES/sphinx.mo +0 -0
  85. sphinx/locale/ka/LC_MESSAGES/sphinx.po +2567 -2462
  86. sphinx/locale/ko/LC_MESSAGES/sphinx.mo +0 -0
  87. sphinx/locale/ko/LC_MESSAGES/sphinx.po +2631 -2526
  88. sphinx/locale/lt/LC_MESSAGES/sphinx.mo +0 -0
  89. sphinx/locale/lt/LC_MESSAGES/sphinx.po +2214 -2109
  90. sphinx/locale/lv/LC_MESSAGES/sphinx.mo +0 -0
  91. sphinx/locale/lv/LC_MESSAGES/sphinx.po +2218 -2113
  92. sphinx/locale/mk/LC_MESSAGES/sphinx.mo +0 -0
  93. sphinx/locale/mk/LC_MESSAGES/sphinx.po +2088 -1983
  94. sphinx/locale/nb_NO/LC_MESSAGES/sphinx.mo +0 -0
  95. sphinx/locale/nb_NO/LC_MESSAGES/sphinx.po +2247 -2142
  96. sphinx/locale/ne/LC_MESSAGES/sphinx.mo +0 -0
  97. sphinx/locale/ne/LC_MESSAGES/sphinx.po +2227 -2122
  98. sphinx/locale/nl/LC_MESSAGES/sphinx.mo +0 -0
  99. sphinx/locale/nl/LC_MESSAGES/sphinx.po +2316 -2211
  100. sphinx/locale/pl/LC_MESSAGES/sphinx.js +2 -2
  101. sphinx/locale/pl/LC_MESSAGES/sphinx.mo +0 -0
  102. sphinx/locale/pl/LC_MESSAGES/sphinx.po +2442 -2336
  103. sphinx/locale/pt/LC_MESSAGES/sphinx.mo +0 -0
  104. sphinx/locale/pt/LC_MESSAGES/sphinx.po +2045 -1940
  105. sphinx/locale/pt_BR/LC_MESSAGES/sphinx.mo +0 -0
  106. sphinx/locale/pt_BR/LC_MESSAGES/sphinx.po +2657 -2552
  107. sphinx/locale/pt_PT/LC_MESSAGES/sphinx.mo +0 -0
  108. sphinx/locale/pt_PT/LC_MESSAGES/sphinx.po +2243 -2138
  109. sphinx/locale/ro/LC_MESSAGES/sphinx.mo +0 -0
  110. sphinx/locale/ro/LC_MESSAGES/sphinx.po +2244 -2139
  111. sphinx/locale/ru/LC_MESSAGES/sphinx.js +1 -1
  112. sphinx/locale/ru/LC_MESSAGES/sphinx.mo +0 -0
  113. sphinx/locale/ru/LC_MESSAGES/sphinx.po +2660 -2555
  114. sphinx/locale/si/LC_MESSAGES/sphinx.mo +0 -0
  115. sphinx/locale/si/LC_MESSAGES/sphinx.po +2134 -2029
  116. sphinx/locale/sk/LC_MESSAGES/sphinx.mo +0 -0
  117. sphinx/locale/sk/LC_MESSAGES/sphinx.po +2614 -2509
  118. sphinx/locale/sl/LC_MESSAGES/sphinx.mo +0 -0
  119. sphinx/locale/sl/LC_MESSAGES/sphinx.po +2167 -2062
  120. sphinx/locale/sphinx.pot +2069 -1964
  121. sphinx/locale/sq/LC_MESSAGES/sphinx.mo +0 -0
  122. sphinx/locale/sq/LC_MESSAGES/sphinx.po +2661 -2556
  123. sphinx/locale/sr/LC_MESSAGES/sphinx.mo +0 -0
  124. sphinx/locale/sr/LC_MESSAGES/sphinx.po +2213 -2108
  125. sphinx/locale/sv/LC_MESSAGES/sphinx.mo +0 -0
  126. sphinx/locale/sv/LC_MESSAGES/sphinx.po +2229 -2124
  127. sphinx/locale/te/LC_MESSAGES/sphinx.mo +0 -0
  128. sphinx/locale/te/LC_MESSAGES/sphinx.po +2045 -1940
  129. sphinx/locale/tr/LC_MESSAGES/sphinx.mo +0 -0
  130. sphinx/locale/tr/LC_MESSAGES/sphinx.po +2608 -2503
  131. sphinx/locale/uk_UA/LC_MESSAGES/sphinx.mo +0 -0
  132. sphinx/locale/uk_UA/LC_MESSAGES/sphinx.po +2167 -2062
  133. sphinx/locale/ur/LC_MESSAGES/sphinx.mo +0 -0
  134. sphinx/locale/ur/LC_MESSAGES/sphinx.po +2045 -1940
  135. sphinx/locale/vi/LC_MESSAGES/sphinx.mo +0 -0
  136. sphinx/locale/vi/LC_MESSAGES/sphinx.po +2204 -2099
  137. sphinx/locale/yue/LC_MESSAGES/sphinx.mo +0 -0
  138. sphinx/locale/yue/LC_MESSAGES/sphinx.po +2045 -1940
  139. sphinx/locale/zh_HK/LC_MESSAGES/sphinx.mo +0 -0
  140. sphinx/locale/zh_HK/LC_MESSAGES/sphinx.po +2045 -1940
  141. sphinx/locale/zh_TW/LC_MESSAGES/sphinx.mo +0 -0
  142. sphinx/locale/zh_TW/LC_MESSAGES/sphinx.po +2659 -2554
  143. sphinx/locale/zh_TW.Big5/LC_MESSAGES/sphinx.mo +0 -0
  144. sphinx/locale/zh_TW.Big5/LC_MESSAGES/sphinx.po +2045 -1940
  145. sphinx/search/zh.py +23 -13
  146. sphinx/testing/path.py +8 -0
  147. sphinx/themes/basic/static/basic.css.jinja +0 -8
  148. sphinx/util/__init__.py +7 -0
  149. sphinx/util/_files.py +2 -2
  150. sphinx/util/fileutil.py +2 -1
  151. sphinx/util/osutil.py +6 -1
  152. {sphinx-8.2.0rc2.dist-info → sphinx-8.3.0.dist-info}/METADATA +7 -6
  153. {sphinx-8.2.0rc2.dist-info → sphinx-8.3.0.dist-info}/RECORD +156 -153
  154. {sphinx-8.2.0rc2.dist-info → sphinx-8.3.0.dist-info}/WHEEL +1 -1
  155. {sphinx-8.2.0rc2.dist-info → sphinx-8.3.0.dist-info}/entry_points.txt +0 -0
  156. {sphinx-8.2.0rc2.dist-info → sphinx-8.3.0.dist-info/licenses}/LICENSE.rst +0 -0
sphinx/__init__.py CHANGED
@@ -1,24 +1,25 @@
1
1
  """The Sphinx documentation toolchain."""
2
2
 
3
- from __future__ import annotations
4
-
5
- __version__ = '8.2.0rc2'
6
- __display_version__ = __version__ # used for command line version
7
-
8
3
  # Keep this file executable as-is in Python 3!
9
4
  # (Otherwise getting the version out of it when packaging is impossible.)
10
5
 
11
- import os
6
+ from __future__ import annotations
7
+
12
8
  import warnings
13
9
 
14
- from sphinx.util._pathlib import _StrPath
10
+ # work around flit error in parsing annotated assignments
11
+ try:
12
+ from sphinx.util._pathlib import _StrPath
13
+ except ImportError:
14
+ from pathlib import Path as _StrPath # type: ignore[assignment]
15
+
16
+ TYPE_CHECKING = False
17
+ if TYPE_CHECKING:
18
+ from typing import Final
15
19
 
16
- # by default, all DeprecationWarning under sphinx package will be emit.
17
- # Users can avoid this by using environment variable: PYTHONWARNINGS=
18
- if 'PYTHONWARNINGS' not in os.environ:
19
- from sphinx.deprecation import RemovedInNextVersionWarning
20
+ __version__: Final = '8.3.0'
21
+ __display_version__: Final = __version__ # used for command line version
20
22
 
21
- warnings.filterwarnings('default', category=RemovedInNextVersionWarning)
22
23
  warnings.filterwarnings(
23
24
  'ignore',
24
25
  'The frontend.Option class .*',
@@ -34,9 +35,9 @@ warnings.filterwarnings(
34
35
  #:
35
36
  #: .. versionadded:: 1.2
36
37
  #: Before version 1.2, check the string ``sphinx.__version__``.
37
- version_info = (8, 2, 0, 'candidate', 2)
38
+ version_info: Final = (8, 2, 2, 'final', 0)
38
39
 
39
- package_dir = _StrPath(__file__).resolve().parent
40
+ package_dir: Final = _StrPath(__file__).resolve().parent
40
41
 
41
42
  _in_development = False
42
43
  if _in_development:
@@ -45,14 +46,14 @@ if _in_development:
45
46
 
46
47
  try:
47
48
  if ret := subprocess.run(
48
- ['git', 'rev-parse', '--short', 'HEAD'], # NoQA: S607
49
- cwd=package_dir,
49
+ ('git', 'rev-parse', '--short', 'HEAD'),
50
50
  capture_output=True,
51
51
  check=False,
52
- encoding='ascii',
52
+ cwd=package_dir,
53
+ encoding='utf-8',
53
54
  errors='surrogateescape',
54
55
  ).stdout:
55
- __display_version__ += '+/' + ret.strip()
56
+ __display_version__ += f'+/{ret.strip()}' # type: ignore[misc]
56
57
  del ret
57
58
  finally:
58
59
  del subprocess
sphinx/application.py CHANGED
@@ -1507,6 +1507,7 @@ class Sphinx:
1507
1507
  elif loading_method == 'defer':
1508
1508
  kwargs['defer'] = 'defer'
1509
1509
 
1510
+ filename = filename or ''
1510
1511
  self.registry.add_js_file(filename, priority=priority, **kwargs)
1511
1512
  with contextlib.suppress(AttributeError):
1512
1513
  self.builder.add_js_file( # type: ignore[attr-defined]
sphinx/deprecation.py CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
+ import os
5
6
  import warnings
6
7
 
7
8
 
@@ -16,6 +17,12 @@ class RemovedInSphinx10Warning(PendingDeprecationWarning):
16
17
  RemovedInNextVersionWarning = RemovedInSphinx90Warning
17
18
 
18
19
 
20
+ # By default, all Sphinx deprecation warnings will be emitted.
21
+ # To avoid this, set the environment variable: PYTHONWARNINGS=
22
+ if 'PYTHONWARNINGS' not in os.environ:
23
+ warnings.filterwarnings('default', category=RemovedInNextVersionWarning)
24
+
25
+
19
26
  def _deprecation_warning(
20
27
  module: str,
21
28
  attribute: str,
@@ -217,7 +217,6 @@ def _parse_module_options(
217
217
  dest_dir=dest_path,
218
218
  module_path=module_path,
219
219
  exclude_pattern=exclude_patterns,
220
- automodule_options=automodule_options,
221
220
  max_depth=max_depth,
222
221
  quiet=True,
223
222
  follow_links=bool_options['follow_links'],
@@ -226,6 +225,8 @@ def _parse_module_options(
226
225
  no_headings=bool_options['no_headings'],
227
226
  module_first=bool_options['module_first'],
228
227
  implicit_namespaces=bool_options['implicit_namespaces'],
228
+ automodule_options=automodule_options,
229
+ header=module_path.name,
229
230
  )
230
231
 
231
232
 
@@ -291,7 +291,7 @@ def between(
291
291
  # This class is used only in ``sphinx.ext.autodoc.directive``,
292
292
  # But we define this class here to keep compatibility
293
293
  # See: https://github.com/sphinx-doc/sphinx/issues/4538
294
- class Options(dict[str, Any]):
294
+ class Options(dict[str, Any]): # NoQA: FURB189
295
295
  """A dict/attribute hybrid that returns None on nonexisting keys."""
296
296
 
297
297
  def copy(self) -> Options:
@@ -52,7 +52,7 @@ AUTODOC_EXTENDABLE_OPTIONS = frozenset({
52
52
  })
53
53
 
54
54
 
55
- class DummyOptionSpec(dict[str, Callable[[str], str]]):
55
+ class DummyOptionSpec(dict[str, Callable[[str], str]]): # NoQA: FURB189
56
56
  """An option_spec allows any options."""
57
57
 
58
58
  def __bool__(self) -> bool:
@@ -30,7 +30,7 @@ class _MockObject:
30
30
  __sphinx_mock__ = True
31
31
  __sphinx_decorator_args__: tuple[Any, ...] = ()
32
32
 
33
- def __new__(cls, *args: Any, **kwargs: Any) -> Any:
33
+ def __new__(cls, *args: Any, **kwargs: Any) -> Any: # NoQA: ARG004
34
34
  if len(args) == 3 and isinstance(args[1], tuple):
35
35
  superclass = args[1][-1].__class__
36
36
  if superclass is cls:
@@ -11,6 +11,7 @@ from sphinx.ext.napoleon.docstring import GoogleDocstring, NumpyDocstring
11
11
  from sphinx.util import inspect
12
12
 
13
13
  if TYPE_CHECKING:
14
+ from collections.abc import Sequence, Set
14
15
  from typing import Any
15
16
 
16
17
  from sphinx.config import _ConfigRebuild
@@ -270,27 +271,27 @@ class Config:
270
271
 
271
272
  """
272
273
 
273
- _config_values: dict[str, tuple[Any, _ConfigRebuild]] = {
274
- 'napoleon_google_docstring': (True, 'env'),
275
- 'napoleon_numpy_docstring': (True, 'env'),
276
- 'napoleon_include_init_with_doc': (False, 'env'),
277
- 'napoleon_include_private_with_doc': (False, 'env'),
278
- 'napoleon_include_special_with_doc': (False, 'env'),
279
- 'napoleon_use_admonition_for_examples': (False, 'env'),
280
- 'napoleon_use_admonition_for_notes': (False, 'env'),
281
- 'napoleon_use_admonition_for_references': (False, 'env'),
282
- 'napoleon_use_ivar': (False, 'env'),
283
- 'napoleon_use_param': (True, 'env'),
284
- 'napoleon_use_rtype': (True, 'env'),
285
- 'napoleon_use_keyword': (True, 'env'),
286
- 'napoleon_preprocess_types': (False, 'env'),
287
- 'napoleon_type_aliases': (None, 'env'),
288
- 'napoleon_custom_sections': (None, 'env'),
289
- 'napoleon_attr_annotations': (True, 'env'),
290
- }
274
+ _config_values: Sequence[tuple[str, bool | None, _ConfigRebuild, Set[type]]] = (
275
+ ('napoleon_google_docstring', True, 'env', frozenset({bool})),
276
+ ('napoleon_numpy_docstring', True, 'env', frozenset({bool})),
277
+ ('napoleon_include_init_with_doc', False, 'env', frozenset({bool})),
278
+ ('napoleon_include_private_with_doc', False, 'env', frozenset({bool})),
279
+ ('napoleon_include_special_with_doc', False, 'env', frozenset({bool})),
280
+ ('napoleon_use_admonition_for_examples', False, 'env', frozenset({bool})),
281
+ ('napoleon_use_admonition_for_notes', False, 'env', frozenset({bool})),
282
+ ('napoleon_use_admonition_for_references', False, 'env', frozenset({bool})),
283
+ ('napoleon_use_ivar', False, 'env', frozenset({bool})),
284
+ ('napoleon_use_param', True, 'env', frozenset({bool})),
285
+ ('napoleon_use_rtype', True, 'env', frozenset({bool})),
286
+ ('napoleon_use_keyword', True, 'env', frozenset({bool})),
287
+ ('napoleon_preprocess_types', False, 'env', frozenset({bool})),
288
+ ('napoleon_type_aliases', None, 'env', frozenset({dict, NoneType})),
289
+ ('napoleon_custom_sections', None, 'env', frozenset({list, tuple, NoneType})),
290
+ ('napoleon_attr_annotations', True, 'env', frozenset({bool})),
291
+ )
291
292
 
292
293
  def __init__(self, **settings: Any) -> None:
293
- for name, (default, _rebuild) in self._config_values.items():
294
+ for name, default, _rebuild, _types in self._config_values:
294
295
  setattr(self, name, default)
295
296
  for name, value in settings.items():
296
297
  setattr(self, name, value)
@@ -331,11 +332,9 @@ def setup(app: Sphinx) -> ExtensionMetadata:
331
332
  app.connect('autodoc-process-docstring', _process_docstring)
332
333
  app.connect('autodoc-skip-member', _skip_member)
333
334
 
334
- for name, (default, rebuild) in Config._config_values.items():
335
- if isinstance(default, bool):
336
- app.add_config_value(name, default, rebuild, types=frozenset({bool}))
337
- else:
338
- app.add_config_value(name, default, rebuild, types=frozenset({NoneType}))
335
+ for name, default, rebuild, types in Config._config_values:
336
+ app.add_config_value(name, default, rebuild, types=types)
337
+
339
338
  return {
340
339
  'version': sphinx.__display_version__,
341
340
  'parallel_read_safe': True,
sphinx/ext/viewcode.py CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
- import importlib.util
5
+ import importlib
6
6
  import operator
7
7
  import posixpath
8
8
  import traceback
@@ -62,16 +62,20 @@ def _get_full_modname(modname: str, attribute: str) -> str | None:
62
62
  num_parts = len(module_path)
63
63
  for i in range(num_parts, 0, -1):
64
64
  mod_root = '.'.join(module_path[:i])
65
- module_spec = importlib.util.find_spec(mod_root)
66
- if module_spec is not None:
65
+ try:
66
+ # import_module() caches the module in sys.modules
67
+ module = importlib.import_module(mod_root)
67
68
  break
69
+ except ModuleNotFoundError:
70
+ continue
71
+ except BaseException as exc:
72
+ # Importing modules may cause any side effects, including
73
+ # SystemExit, so we need to catch all errors.
74
+ msg = f"viewcode failed to import '{mod_root}'."
75
+ raise ImportError(msg) from exc
68
76
  else:
69
77
  return None
70
- # Load and execute the module
71
- module = importlib.util.module_from_spec(module_spec)
72
- if module_spec.loader is None:
73
- return None
74
- module_spec.loader.exec_module(module)
78
+
75
79
  if i != num_parts:
76
80
  for mod in module_path[i:]:
77
81
  module = getattr(module, mod)
sphinx/highlighting.py CHANGED
@@ -171,7 +171,7 @@ class PygmentsBridge:
171
171
  lang,
172
172
  location=location,
173
173
  type='misc',
174
- subtype='higlighting_failure',
174
+ subtype='highlighting_failure',
175
175
  )
176
176
  lexer = lexer_classes['none'](**opts)
177
177
 
sphinx/locale/__init__.py CHANGED
@@ -8,11 +8,15 @@ from gettext import NullTranslations, translation
8
8
  from pathlib import Path
9
9
  from typing import TYPE_CHECKING
10
10
 
11
+ from sphinx import package_dir
12
+
11
13
  if TYPE_CHECKING:
12
14
  import os
13
15
  from collections.abc import Callable, Iterable
14
16
  from typing import Any
15
17
 
18
+ _LOCALE_DIR = Path(package_dir, 'locale')
19
+
16
20
 
17
21
  class _TranslationProxy:
18
22
  """The proxy implementation attempts to be as complete as possible, so that
@@ -140,9 +144,6 @@ def init(
140
144
  return translator, has_translation
141
145
 
142
146
 
143
- _LOCALE_DIR = Path(__file__).resolve().parent
144
-
145
-
146
147
  def init_console(
147
148
  locale_dir: str | os.PathLike[str] | None = None,
148
149
  catalog: str = 'sphinx',
Binary file