Sphinx 7.2.5__py3-none-any.whl → 7.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 (388) hide show
  1. sphinx/__init__.py +8 -9
  2. sphinx/addnodes.py +31 -28
  3. sphinx/application.py +9 -15
  4. sphinx/builders/__init__.py +5 -6
  5. sphinx/builders/_epub_base.py +17 -9
  6. sphinx/builders/changes.py +10 -5
  7. sphinx/builders/dirhtml.py +4 -2
  8. sphinx/builders/dummy.py +3 -2
  9. sphinx/builders/epub3.py +5 -3
  10. sphinx/builders/gettext.py +24 -7
  11. sphinx/builders/html/__init__.py +88 -96
  12. sphinx/builders/html/_assets.py +16 -16
  13. sphinx/builders/html/transforms.py +4 -2
  14. sphinx/builders/latex/__init__.py +40 -33
  15. sphinx/builders/latex/nodes.py +6 -2
  16. sphinx/builders/latex/transforms.py +17 -8
  17. sphinx/builders/latex/util.py +1 -1
  18. sphinx/builders/linkcheck.py +86 -27
  19. sphinx/builders/manpage.py +8 -6
  20. sphinx/builders/singlehtml.py +5 -4
  21. sphinx/builders/texinfo.py +18 -14
  22. sphinx/builders/text.py +3 -2
  23. sphinx/builders/xml.py +5 -2
  24. sphinx/cmd/build.py +119 -76
  25. sphinx/cmd/make_mode.py +21 -20
  26. sphinx/cmd/quickstart.py +13 -16
  27. sphinx/config.py +432 -250
  28. sphinx/deprecation.py +23 -13
  29. sphinx/directives/__init__.py +8 -8
  30. sphinx/directives/code.py +7 -7
  31. sphinx/directives/other.py +23 -13
  32. sphinx/directives/patches.py +7 -6
  33. sphinx/domains/__init__.py +2 -2
  34. sphinx/domains/c/__init__.py +796 -0
  35. sphinx/domains/c/_ast.py +1421 -0
  36. sphinx/domains/c/_ids.py +65 -0
  37. sphinx/domains/c/_parser.py +1048 -0
  38. sphinx/domains/c/_symbol.py +700 -0
  39. sphinx/domains/changeset.py +11 -7
  40. sphinx/domains/citation.py +5 -2
  41. sphinx/domains/cpp/__init__.py +1089 -0
  42. sphinx/domains/cpp/_ast.py +3635 -0
  43. sphinx/domains/cpp/_ids.py +537 -0
  44. sphinx/domains/cpp/_parser.py +2117 -0
  45. sphinx/domains/cpp/_symbol.py +1092 -0
  46. sphinx/domains/index.py +6 -4
  47. sphinx/domains/javascript.py +16 -13
  48. sphinx/domains/math.py +9 -4
  49. sphinx/domains/python/__init__.py +890 -0
  50. sphinx/domains/python/_annotations.py +507 -0
  51. sphinx/domains/python/_object.py +426 -0
  52. sphinx/domains/rst.py +12 -7
  53. sphinx/domains/{std.py → std/__init__.py} +19 -16
  54. sphinx/environment/__init__.py +21 -19
  55. sphinx/environment/adapters/indexentries.py +2 -2
  56. sphinx/environment/adapters/toctree.py +10 -9
  57. sphinx/environment/collectors/__init__.py +6 -3
  58. sphinx/environment/collectors/asset.py +4 -3
  59. sphinx/environment/collectors/dependencies.py +3 -2
  60. sphinx/environment/collectors/metadata.py +6 -5
  61. sphinx/environment/collectors/title.py +3 -2
  62. sphinx/environment/collectors/toctree.py +5 -4
  63. sphinx/errors.py +13 -2
  64. sphinx/events.py +14 -9
  65. sphinx/ext/apidoc.py +9 -11
  66. sphinx/ext/autodoc/__init__.py +105 -71
  67. sphinx/ext/autodoc/directive.py +7 -6
  68. sphinx/ext/autodoc/importer.py +132 -52
  69. sphinx/ext/autodoc/mock.py +7 -5
  70. sphinx/ext/autodoc/preserve_defaults.py +4 -3
  71. sphinx/ext/autodoc/type_comment.py +2 -1
  72. sphinx/ext/autodoc/typehints.py +5 -4
  73. sphinx/ext/autosectionlabel.py +3 -2
  74. sphinx/ext/autosummary/__init__.py +21 -17
  75. sphinx/ext/autosummary/generate.py +9 -9
  76. sphinx/ext/coverage.py +26 -20
  77. sphinx/ext/doctest.py +38 -33
  78. sphinx/ext/duration.py +1 -0
  79. sphinx/ext/extlinks.py +4 -3
  80. sphinx/ext/githubpages.py +3 -2
  81. sphinx/ext/graphviz.py +10 -7
  82. sphinx/ext/ifconfig.py +5 -5
  83. sphinx/ext/imgconverter.py +6 -5
  84. sphinx/ext/imgmath.py +9 -8
  85. sphinx/ext/inheritance_diagram.py +31 -31
  86. sphinx/ext/intersphinx.py +140 -23
  87. sphinx/ext/linkcode.py +3 -2
  88. sphinx/ext/mathjax.py +2 -1
  89. sphinx/ext/napoleon/__init__.py +12 -7
  90. sphinx/ext/napoleon/docstring.py +34 -32
  91. sphinx/ext/todo.py +10 -7
  92. sphinx/ext/viewcode.py +12 -11
  93. sphinx/extension.py +18 -8
  94. sphinx/highlighting.py +39 -20
  95. sphinx/io.py +17 -8
  96. sphinx/jinja2glue.py +16 -15
  97. sphinx/locale/__init__.py +30 -23
  98. sphinx/locale/ar/LC_MESSAGES/sphinx.mo +0 -0
  99. sphinx/locale/ar/LC_MESSAGES/sphinx.po +818 -761
  100. sphinx/locale/bg/LC_MESSAGES/sphinx.mo +0 -0
  101. sphinx/locale/bg/LC_MESSAGES/sphinx.po +811 -754
  102. sphinx/locale/bn/LC_MESSAGES/sphinx.mo +0 -0
  103. sphinx/locale/bn/LC_MESSAGES/sphinx.po +835 -778
  104. sphinx/locale/ca/LC_MESSAGES/sphinx.mo +0 -0
  105. sphinx/locale/ca/LC_MESSAGES/sphinx.po +864 -807
  106. sphinx/locale/cak/LC_MESSAGES/sphinx.mo +0 -0
  107. sphinx/locale/cak/LC_MESSAGES/sphinx.po +816 -759
  108. sphinx/locale/cs/LC_MESSAGES/sphinx.mo +0 -0
  109. sphinx/locale/cs/LC_MESSAGES/sphinx.po +837 -780
  110. sphinx/locale/cy/LC_MESSAGES/sphinx.mo +0 -0
  111. sphinx/locale/cy/LC_MESSAGES/sphinx.po +819 -762
  112. sphinx/locale/da/LC_MESSAGES/sphinx.mo +0 -0
  113. sphinx/locale/da/LC_MESSAGES/sphinx.po +838 -781
  114. sphinx/locale/de/LC_MESSAGES/sphinx.mo +0 -0
  115. sphinx/locale/de/LC_MESSAGES/sphinx.po +838 -781
  116. sphinx/locale/de_DE/LC_MESSAGES/sphinx.mo +0 -0
  117. sphinx/locale/de_DE/LC_MESSAGES/sphinx.po +811 -754
  118. sphinx/locale/el/LC_MESSAGES/sphinx.mo +0 -0
  119. sphinx/locale/el/LC_MESSAGES/sphinx.po +853 -796
  120. sphinx/locale/en_DE/LC_MESSAGES/sphinx.mo +0 -0
  121. sphinx/locale/en_DE/LC_MESSAGES/sphinx.po +811 -754
  122. sphinx/locale/en_FR/LC_MESSAGES/sphinx.mo +0 -0
  123. sphinx/locale/en_FR/LC_MESSAGES/sphinx.po +811 -754
  124. sphinx/locale/en_GB/LC_MESSAGES/sphinx.mo +0 -0
  125. sphinx/locale/en_GB/LC_MESSAGES/sphinx.po +856 -799
  126. sphinx/locale/en_HK/LC_MESSAGES/sphinx.mo +0 -0
  127. sphinx/locale/en_HK/LC_MESSAGES/sphinx.po +811 -754
  128. sphinx/locale/eo/LC_MESSAGES/sphinx.mo +0 -0
  129. sphinx/locale/eo/LC_MESSAGES/sphinx.po +820 -763
  130. sphinx/locale/es/LC_MESSAGES/sphinx.mo +0 -0
  131. sphinx/locale/es/LC_MESSAGES/sphinx.po +856 -799
  132. sphinx/locale/es_CO/LC_MESSAGES/sphinx.mo +0 -0
  133. sphinx/locale/es_CO/LC_MESSAGES/sphinx.po +811 -754
  134. sphinx/locale/et/LC_MESSAGES/sphinx.mo +0 -0
  135. sphinx/locale/et/LC_MESSAGES/sphinx.po +845 -788
  136. sphinx/locale/eu/LC_MESSAGES/sphinx.mo +0 -0
  137. sphinx/locale/eu/LC_MESSAGES/sphinx.po +837 -780
  138. sphinx/locale/fa/LC_MESSAGES/sphinx.mo +0 -0
  139. sphinx/locale/fa/LC_MESSAGES/sphinx.po +854 -797
  140. sphinx/locale/fi/LC_MESSAGES/sphinx.mo +0 -0
  141. sphinx/locale/fi/LC_MESSAGES/sphinx.po +816 -759
  142. sphinx/locale/fr/LC_MESSAGES/sphinx.js +1 -1
  143. sphinx/locale/fr/LC_MESSAGES/sphinx.mo +0 -0
  144. sphinx/locale/fr/LC_MESSAGES/sphinx.po +904 -847
  145. sphinx/locale/fr_FR/LC_MESSAGES/sphinx.mo +0 -0
  146. sphinx/locale/fr_FR/LC_MESSAGES/sphinx.po +811 -754
  147. sphinx/locale/gl/LC_MESSAGES/sphinx.js +54 -54
  148. sphinx/locale/gl/LC_MESSAGES/sphinx.mo +0 -0
  149. sphinx/locale/gl/LC_MESSAGES/sphinx.po +1506 -1449
  150. sphinx/locale/he/LC_MESSAGES/sphinx.js +1 -1
  151. sphinx/locale/he/LC_MESSAGES/sphinx.mo +0 -0
  152. sphinx/locale/he/LC_MESSAGES/sphinx.po +823 -766
  153. sphinx/locale/hi/LC_MESSAGES/sphinx.mo +0 -0
  154. sphinx/locale/hi/LC_MESSAGES/sphinx.po +853 -796
  155. sphinx/locale/hi_IN/LC_MESSAGES/sphinx.mo +0 -0
  156. sphinx/locale/hi_IN/LC_MESSAGES/sphinx.po +811 -754
  157. sphinx/locale/hr/LC_MESSAGES/sphinx.mo +0 -0
  158. sphinx/locale/hr/LC_MESSAGES/sphinx.po +844 -787
  159. sphinx/locale/hu/LC_MESSAGES/sphinx.mo +0 -0
  160. sphinx/locale/hu/LC_MESSAGES/sphinx.po +837 -780
  161. sphinx/locale/id/LC_MESSAGES/sphinx.mo +0 -0
  162. sphinx/locale/id/LC_MESSAGES/sphinx.po +854 -797
  163. sphinx/locale/is/LC_MESSAGES/sphinx.mo +0 -0
  164. sphinx/locale/is/LC_MESSAGES/sphinx.po +811 -754
  165. sphinx/locale/it/LC_MESSAGES/sphinx.mo +0 -0
  166. sphinx/locale/it/LC_MESSAGES/sphinx.po +837 -780
  167. sphinx/locale/ja/LC_MESSAGES/sphinx.mo +0 -0
  168. sphinx/locale/ja/LC_MESSAGES/sphinx.po +853 -796
  169. sphinx/locale/ka/LC_MESSAGES/sphinx.mo +0 -0
  170. sphinx/locale/ka/LC_MESSAGES/sphinx.po +848 -791
  171. sphinx/locale/ko/LC_MESSAGES/sphinx.mo +0 -0
  172. sphinx/locale/ko/LC_MESSAGES/sphinx.po +855 -798
  173. sphinx/locale/lt/LC_MESSAGES/sphinx.mo +0 -0
  174. sphinx/locale/lt/LC_MESSAGES/sphinx.po +837 -780
  175. sphinx/locale/lv/LC_MESSAGES/sphinx.mo +0 -0
  176. sphinx/locale/lv/LC_MESSAGES/sphinx.po +837 -780
  177. sphinx/locale/mk/LC_MESSAGES/sphinx.mo +0 -0
  178. sphinx/locale/mk/LC_MESSAGES/sphinx.po +825 -768
  179. sphinx/locale/nb_NO/LC_MESSAGES/sphinx.js +27 -27
  180. sphinx/locale/nb_NO/LC_MESSAGES/sphinx.mo +0 -0
  181. sphinx/locale/nb_NO/LC_MESSAGES/sphinx.po +876 -818
  182. sphinx/locale/ne/LC_MESSAGES/sphinx.mo +0 -0
  183. sphinx/locale/ne/LC_MESSAGES/sphinx.po +837 -780
  184. sphinx/locale/nl/LC_MESSAGES/sphinx.mo +0 -0
  185. sphinx/locale/nl/LC_MESSAGES/sphinx.po +844 -787
  186. sphinx/locale/pl/LC_MESSAGES/sphinx.mo +0 -0
  187. sphinx/locale/pl/LC_MESSAGES/sphinx.po +845 -788
  188. sphinx/locale/pt/LC_MESSAGES/sphinx.mo +0 -0
  189. sphinx/locale/pt/LC_MESSAGES/sphinx.po +811 -754
  190. sphinx/locale/pt_BR/LC_MESSAGES/sphinx.mo +0 -0
  191. sphinx/locale/pt_BR/LC_MESSAGES/sphinx.po +908 -851
  192. sphinx/locale/pt_PT/LC_MESSAGES/sphinx.mo +0 -0
  193. sphinx/locale/pt_PT/LC_MESSAGES/sphinx.po +837 -780
  194. sphinx/locale/ro/LC_MESSAGES/sphinx.mo +0 -0
  195. sphinx/locale/ro/LC_MESSAGES/sphinx.po +837 -780
  196. sphinx/locale/ru/LC_MESSAGES/sphinx.mo +0 -0
  197. sphinx/locale/ru/LC_MESSAGES/sphinx.po +838 -781
  198. sphinx/locale/si/LC_MESSAGES/sphinx.mo +0 -0
  199. sphinx/locale/si/LC_MESSAGES/sphinx.po +823 -766
  200. sphinx/locale/sk/LC_MESSAGES/sphinx.mo +0 -0
  201. sphinx/locale/sk/LC_MESSAGES/sphinx.po +854 -797
  202. sphinx/locale/sl/LC_MESSAGES/sphinx.mo +0 -0
  203. sphinx/locale/sl/LC_MESSAGES/sphinx.po +832 -775
  204. sphinx/locale/sphinx.pot +813 -755
  205. sphinx/locale/sq/LC_MESSAGES/sphinx.js +1 -1
  206. sphinx/locale/sq/LC_MESSAGES/sphinx.mo +0 -0
  207. sphinx/locale/sq/LC_MESSAGES/sphinx.po +865 -808
  208. sphinx/locale/sr/LC_MESSAGES/sphinx.mo +0 -0
  209. sphinx/locale/sr/LC_MESSAGES/sphinx.po +835 -778
  210. sphinx/locale/sr@latin/LC_MESSAGES/sphinx.mo +0 -0
  211. sphinx/locale/sr_RS/LC_MESSAGES/sphinx.mo +0 -0
  212. sphinx/locale/sv/LC_MESSAGES/sphinx.mo +0 -0
  213. sphinx/locale/sv/LC_MESSAGES/sphinx.po +837 -780
  214. sphinx/locale/ta/LC_MESSAGES/sphinx.js +54 -54
  215. sphinx/locale/ta/LC_MESSAGES/sphinx.mo +0 -0
  216. sphinx/locale/ta/LC_MESSAGES/sphinx.po +1530 -1473
  217. sphinx/locale/te/LC_MESSAGES/sphinx.mo +0 -0
  218. sphinx/locale/te/LC_MESSAGES/sphinx.po +811 -754
  219. sphinx/locale/tr/LC_MESSAGES/sphinx.mo +0 -0
  220. sphinx/locale/tr/LC_MESSAGES/sphinx.po +853 -796
  221. sphinx/locale/uk_UA/LC_MESSAGES/sphinx.mo +0 -0
  222. sphinx/locale/uk_UA/LC_MESSAGES/sphinx.po +833 -776
  223. sphinx/locale/ur/LC_MESSAGES/sphinx.mo +0 -0
  224. sphinx/locale/ur/LC_MESSAGES/sphinx.po +811 -754
  225. sphinx/locale/vi/LC_MESSAGES/sphinx.mo +0 -0
  226. sphinx/locale/vi/LC_MESSAGES/sphinx.po +837 -780
  227. sphinx/locale/yue/LC_MESSAGES/sphinx.mo +0 -0
  228. sphinx/locale/yue/LC_MESSAGES/sphinx.po +811 -754
  229. sphinx/locale/zh_CN/LC_MESSAGES/sphinx.mo +0 -0
  230. sphinx/locale/zh_CN/LC_MESSAGES/sphinx.po +855 -798
  231. sphinx/locale/zh_HK/LC_MESSAGES/sphinx.mo +0 -0
  232. sphinx/locale/zh_HK/LC_MESSAGES/sphinx.po +811 -754
  233. sphinx/locale/zh_TW/LC_MESSAGES/sphinx.js +1 -1
  234. sphinx/locale/zh_TW/LC_MESSAGES/sphinx.mo +0 -0
  235. sphinx/locale/zh_TW/LC_MESSAGES/sphinx.po +879 -822
  236. sphinx/locale/zh_TW.Big5/LC_MESSAGES/sphinx.mo +0 -0
  237. sphinx/locale/zh_TW.Big5/LC_MESSAGES/sphinx.po +811 -754
  238. sphinx/parsers.py +7 -5
  239. sphinx/project.py +18 -11
  240. sphinx/pycode/__init__.py +6 -5
  241. sphinx/pycode/ast.py +23 -8
  242. sphinx/pycode/parser.py +6 -5
  243. sphinx/registry.py +12 -6
  244. sphinx/roles.py +103 -57
  245. sphinx/search/__init__.py +17 -18
  246. sphinx/search/da.py +2 -2
  247. sphinx/search/de.py +2 -2
  248. sphinx/search/en.py +1 -1
  249. sphinx/search/es.py +2 -2
  250. sphinx/search/fi.py +2 -2
  251. sphinx/search/fr.py +2 -2
  252. sphinx/search/hu.py +2 -2
  253. sphinx/search/it.py +2 -2
  254. sphinx/search/ja.py +13 -22
  255. sphinx/search/nl.py +2 -2
  256. sphinx/search/no.py +2 -2
  257. sphinx/search/pt.py +2 -2
  258. sphinx/search/ro.py +1 -1
  259. sphinx/search/ru.py +2 -2
  260. sphinx/search/sv.py +2 -2
  261. sphinx/search/tr.py +1 -1
  262. sphinx/search/zh.py +2 -3
  263. sphinx/templates/graphviz/graphviz.css +1 -1
  264. sphinx/testing/fixtures.py +41 -24
  265. sphinx/testing/path.py +1 -1
  266. sphinx/testing/util.py +142 -53
  267. sphinx/texinputs/sphinx.xdy +1 -1
  268. sphinx/texinputs/sphinxlatextables.sty +1 -1
  269. sphinx/texinputs/sphinxpackagesubstitutefont.sty +21 -0
  270. sphinx/themes/agogo/layout.html +4 -4
  271. sphinx/themes/agogo/static/agogo.css_t +1 -1
  272. sphinx/themes/agogo/theme.toml +22 -0
  273. sphinx/themes/basic/defindex.html +1 -1
  274. sphinx/themes/basic/domainindex.html +1 -1
  275. sphinx/themes/basic/genindex-single.html +1 -1
  276. sphinx/themes/basic/genindex-split.html +1 -1
  277. sphinx/themes/basic/genindex.html +1 -1
  278. sphinx/themes/basic/globaltoc.html +1 -1
  279. sphinx/themes/basic/layout.html +1 -1
  280. sphinx/themes/basic/localtoc.html +1 -1
  281. sphinx/themes/basic/page.html +1 -1
  282. sphinx/themes/basic/relations.html +1 -1
  283. sphinx/themes/basic/search.html +5 -20
  284. sphinx/themes/basic/searchbox.html +3 -3
  285. sphinx/themes/basic/searchfield.html +3 -3
  286. sphinx/themes/basic/sourcelink.html +1 -1
  287. sphinx/themes/basic/static/basic.css_t +1 -1
  288. sphinx/themes/basic/static/doctools.js +1 -1
  289. sphinx/themes/basic/static/language_data.js_t +2 -2
  290. sphinx/themes/basic/static/searchtools.js +105 -60
  291. sphinx/themes/basic/theme.toml +23 -0
  292. sphinx/themes/bizstyle/layout.html +1 -6
  293. sphinx/themes/bizstyle/static/bizstyle.css_t +1 -1
  294. sphinx/themes/bizstyle/static/bizstyle.js_t +1 -1
  295. sphinx/themes/bizstyle/static/css3-mediaqueries_src.js +3 -3
  296. sphinx/themes/bizstyle/theme.toml +12 -0
  297. sphinx/themes/classic/layout.html +1 -1
  298. sphinx/themes/classic/static/classic.css_t +1 -1
  299. sphinx/themes/classic/static/sidebar.js_t +1 -1
  300. sphinx/themes/classic/theme.toml +34 -0
  301. sphinx/themes/default/theme.toml +2 -0
  302. sphinx/themes/epub/epub-cover.html +1 -1
  303. sphinx/themes/epub/layout.html +1 -1
  304. sphinx/themes/epub/static/epub.css_t +1 -1
  305. sphinx/themes/epub/theme.toml +10 -0
  306. sphinx/themes/haiku/layout.html +3 -3
  307. sphinx/themes/haiku/static/haiku.css_t +2 -2
  308. sphinx/themes/haiku/theme.toml +16 -0
  309. sphinx/themes/nature/static/nature.css_t +1 -1
  310. sphinx/themes/nature/theme.toml +6 -0
  311. sphinx/themes/nonav/layout.html +1 -1
  312. sphinx/themes/nonav/static/nonav.css_t +1 -1
  313. sphinx/themes/nonav/theme.toml +10 -0
  314. sphinx/themes/pyramid/static/epub.css_t +1 -1
  315. sphinx/themes/pyramid/static/pyramid.css_t +1 -1
  316. sphinx/themes/pyramid/theme.toml +6 -0
  317. sphinx/themes/scrolls/artwork/logo.svg +1 -1
  318. sphinx/themes/scrolls/layout.html +2 -2
  319. sphinx/themes/scrolls/static/scrolls.css_t +1 -1
  320. sphinx/themes/scrolls/theme.toml +15 -0
  321. sphinx/themes/sphinxdoc/static/sphinxdoc.css_t +1 -1
  322. sphinx/themes/sphinxdoc/theme.toml +6 -0
  323. sphinx/themes/traditional/static/traditional.css_t +1 -1
  324. sphinx/themes/traditional/theme.toml +9 -0
  325. sphinx/theming.py +427 -131
  326. sphinx/transforms/__init__.py +21 -24
  327. sphinx/transforms/compact_bullet_list.py +5 -5
  328. sphinx/transforms/i18n.py +30 -28
  329. sphinx/transforms/post_transforms/__init__.py +9 -7
  330. sphinx/transforms/post_transforms/code.py +4 -1
  331. sphinx/transforms/post_transforms/images.py +17 -13
  332. sphinx/transforms/references.py +3 -1
  333. sphinx/util/__init__.py +15 -11
  334. sphinx/util/_io.py +34 -0
  335. sphinx/util/_pathlib.py +23 -18
  336. sphinx/util/build_phase.py +1 -0
  337. sphinx/util/cfamily.py +19 -11
  338. sphinx/util/console.py +101 -21
  339. sphinx/util/display.py +3 -2
  340. sphinx/util/docfields.py +12 -8
  341. sphinx/util/docutils.py +21 -35
  342. sphinx/util/exceptions.py +3 -2
  343. sphinx/util/fileutil.py +5 -5
  344. sphinx/util/http_date.py +9 -2
  345. sphinx/util/i18n.py +40 -9
  346. sphinx/util/inspect.py +317 -245
  347. sphinx/util/inventory.py +22 -5
  348. sphinx/util/logging.py +81 -7
  349. sphinx/util/matching.py +2 -1
  350. sphinx/util/math.py +1 -2
  351. sphinx/util/nodes.py +39 -29
  352. sphinx/util/osutil.py +25 -6
  353. sphinx/util/parallel.py +6 -1
  354. sphinx/util/requests.py +8 -5
  355. sphinx/util/rst.py +8 -6
  356. sphinx/util/tags.py +3 -3
  357. sphinx/util/template.py +8 -3
  358. sphinx/util/typing.py +76 -42
  359. sphinx/versioning.py +6 -2
  360. sphinx/writers/html.py +1 -1
  361. sphinx/writers/html5.py +17 -13
  362. sphinx/writers/latex.py +12 -12
  363. sphinx/writers/manpage.py +13 -7
  364. sphinx/writers/texinfo.py +13 -10
  365. sphinx/writers/text.py +13 -23
  366. sphinx/writers/xml.py +1 -1
  367. sphinx-7.2.5.dist-info/LICENSE → sphinx-7.3.0.dist-info/LICENSE.rst +1 -1
  368. {sphinx-7.2.5.dist-info → sphinx-7.3.0.dist-info}/METADATA +13 -12
  369. sphinx-7.3.0.dist-info/RECORD +581 -0
  370. sphinx/domains/c.py +0 -3906
  371. sphinx/domains/cpp.py +0 -8233
  372. sphinx/domains/python.py +0 -1769
  373. sphinx/themes/agogo/theme.conf +0 -20
  374. sphinx/themes/basic/theme.conf +0 -16
  375. sphinx/themes/bizstyle/theme.conf +0 -10
  376. sphinx/themes/classic/theme.conf +0 -32
  377. sphinx/themes/default/theme.conf +0 -2
  378. sphinx/themes/epub/theme.conf +0 -8
  379. sphinx/themes/haiku/theme.conf +0 -14
  380. sphinx/themes/nature/theme.conf +0 -4
  381. sphinx/themes/nonav/theme.conf +0 -8
  382. sphinx/themes/pyramid/theme.conf +0 -4
  383. sphinx/themes/scrolls/theme.conf +0 -13
  384. sphinx/themes/sphinxdoc/theme.conf +0 -4
  385. sphinx/themes/traditional/theme.conf +0 -7
  386. sphinx-7.2.5.dist-info/RECORD +0 -569
  387. {sphinx-7.2.5.dist-info → sphinx-7.3.0.dist-info}/WHEEL +0 -0
  388. {sphinx-7.2.5.dist-info → sphinx-7.3.0.dist-info}/entry_points.txt +0 -0
@@ -9,7 +9,7 @@ import time
9
9
  from collections import defaultdict
10
10
  from copy import copy
11
11
  from os import path
12
- from typing import TYPE_CHECKING, Any, Callable
12
+ from typing import TYPE_CHECKING, Any, Callable, NoReturn
13
13
 
14
14
  from sphinx import addnodes
15
15
  from sphinx.environment.adapters import toctree as toctree_adapters
@@ -23,7 +23,7 @@ from sphinx.util.nodes import is_translatable
23
23
  from sphinx.util.osutil import canon_path, os_path
24
24
 
25
25
  if TYPE_CHECKING:
26
- from collections.abc import Generator, Iterator
26
+ from collections.abc import Iterator
27
27
  from pathlib import Path
28
28
 
29
29
  from docutils import nodes
@@ -58,7 +58,7 @@ default_settings: dict[str, Any] = {
58
58
 
59
59
  # This is increased every time an environment attribute is added
60
60
  # or changed to properly invalidate pickle files.
61
- ENV_VERSION = 60
61
+ ENV_VERSION = 61
62
62
 
63
63
  # config status
64
64
  CONFIG_UNSET = -1
@@ -81,9 +81,7 @@ versioning_conditions: dict[str, bool | Callable] = {
81
81
 
82
82
  if TYPE_CHECKING:
83
83
  from collections.abc import MutableMapping
84
- from typing import Literal
85
-
86
- from typing_extensions import overload
84
+ from typing import Literal, overload
87
85
 
88
86
  from sphinx.domains.c import CDomain
89
87
  from sphinx.domains.changeset import ChangeSetDomain
@@ -126,10 +124,12 @@ if TYPE_CHECKING:
126
124
  @overload
127
125
  def __getitem__(self, key: str) -> Domain: ... # NoQA: E704
128
126
  def __getitem__(self, key): raise NotImplementedError # NoQA: E704
129
- def __setitem__(self, key, value): raise NotImplementedError # NoQA: E704
130
- def __delitem__(self, key): raise NotImplementedError # NoQA: E704
131
- def __iter__(self): raise NotImplementedError # NoQA: E704
132
- def __len__(self): raise NotImplementedError # NoQA: E704
127
+ def __setitem__( # NoQA: E301,E704
128
+ self, key: str, value: Domain,
129
+ ) -> NoReturn: raise NotImplementedError
130
+ def __delitem__(self, key: str) -> NoReturn: raise NotImplementedError # NoQA: E704
131
+ def __iter__(self) -> NoReturn: raise NotImplementedError # NoQA: E704
132
+ def __len__(self) -> NoReturn: raise NotImplementedError # NoQA: E704
133
133
 
134
134
  else:
135
135
  _DomainsType = dict
@@ -146,7 +146,7 @@ class BuildEnvironment:
146
146
 
147
147
  # --------- ENVIRONMENT INITIALIZATION -------------------------------------
148
148
 
149
- def __init__(self, app: Sphinx):
149
+ def __init__(self, app: Sphinx) -> None:
150
150
  self.app: Sphinx = app
151
151
  self.doctreedir: Path = app.doctreedir
152
152
  self.srcdir: Path = app.srcdir
@@ -155,7 +155,7 @@ class BuildEnvironment:
155
155
  self.config_status_extra: str = ''
156
156
  self.events: EventManager = app.events
157
157
  self.project: Project = app.project
158
- self.version: dict[str, str] = app.registry.get_envversion(app)
158
+ self.version: dict[str, int] = app.registry.get_envversion(app)
159
159
 
160
160
  # the method of doctree versioning; see set_versioning_method
161
161
  self.versioning_condition: bool | Callable | None = None
@@ -265,6 +265,9 @@ class BuildEnvironment:
265
265
  """Obtains serializable data for pickling."""
266
266
  __dict__ = self.__dict__.copy()
267
267
  __dict__.update(app=None, domains={}, events=None) # clear unpickable attributes
268
+ # ensure that upon restoring the state, the most recent pickled files
269
+ # on the disk are used instead of those from a possibly outdated state
270
+ __dict__.update(_pickled_doctree_cache={})
268
271
  return __dict__
269
272
 
270
273
  def __setstate__(self, state: dict) -> None:
@@ -299,7 +302,7 @@ class BuildEnvironment:
299
302
  # initialize config
300
303
  self._update_config(app.config)
301
304
 
302
- # initialie settings
305
+ # initialize settings
303
306
  self._update_settings(app.config)
304
307
 
305
308
  def _update_config(self, config: Config) -> None:
@@ -320,7 +323,7 @@ class BuildEnvironment:
320
323
  else:
321
324
  # check if a config value was changed that affects how
322
325
  # doctrees are read
323
- for item in config.filter('env'):
326
+ for item in config.filter(frozenset({'env'})):
324
327
  if self.config[item.name] != item.value:
325
328
  self.config_status = CONFIG_CHANGED
326
329
  self.config_status_extra = f' ({item.name!r})'
@@ -338,7 +341,7 @@ class BuildEnvironment:
338
341
  self.settings.setdefault('smart_quotes', True)
339
342
 
340
343
  def set_versioning_method(self, method: str | Callable, compare: bool) -> None:
341
- """This sets the doctree versioning method for this environment.
344
+ """Set the doctree versioning method for this environment.
342
345
 
343
346
  Versioning methods are a builder property; only builders with the same
344
347
  versioning method can share the same doctree directory. Therefore, we
@@ -424,7 +427,7 @@ class BuildEnvironment:
424
427
 
425
428
  @property
426
429
  def found_docs(self) -> set[str]:
427
- """contains all existing docnames."""
430
+ """Contains all existing docnames."""
428
431
  return self.project.docnames
429
432
 
430
433
  def find_files(self, config: Config, builder: Builder) -> None:
@@ -521,7 +524,7 @@ class BuildEnvironment:
521
524
 
522
525
  return added, changed, removed
523
526
 
524
- def check_dependents(self, app: Sphinx, already: set[str]) -> Generator[str, None, None]:
527
+ def check_dependents(self, app: Sphinx, already: set[str]) -> Iterator[str]:
525
528
  to_rewrite: list[str] = []
526
529
  for docnames in self.events.emit('env-get-updated', self):
527
530
  to_rewrite.extend(docnames)
@@ -743,7 +746,6 @@ def _last_modified_time(filename: str | os.PathLike[str]) -> int:
743
746
  We prefer to err on the side of re-rendering a file,
744
747
  so we round up to the nearest microsecond.
745
748
  """
746
-
747
749
  # upside-down floor division to get the ceiling
748
750
  return -(os.stat(filename).st_mtime_ns // -1_000)
749
751
 
@@ -751,7 +753,7 @@ def _last_modified_time(filename: str | os.PathLike[str]) -> int:
751
753
  def _format_modified_time(timestamp: int) -> str:
752
754
  """Return an RFC 3339 formatted string representing the given timestamp."""
753
755
  seconds, fraction = divmod(timestamp, 10**6)
754
- return time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime(seconds)) + f'.{fraction//1_000}'
756
+ return time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime(seconds)) + f'.{fraction // 1_000}'
755
757
 
756
758
 
757
759
  def _traverse_toctree(
@@ -129,7 +129,7 @@ def _add_entry(word: str, subword: str, main: str | None, *,
129
129
 
130
130
 
131
131
  def _key_func_0(entry: tuple[str, str]) -> tuple[bool, str]:
132
- """sort the index entries for same keyword."""
132
+ """Sort the index entries for same keyword."""
133
133
  main, uri = entry
134
134
  return not main, uri # show main entries at first
135
135
 
@@ -156,7 +156,7 @@ def _key_func_1(entry: tuple[str, list]) -> tuple[tuple[int, str], str]:
156
156
 
157
157
 
158
158
  def _key_func_2(entry: tuple[str, list]) -> str:
159
- """sort the sub-index entries"""
159
+ """Sort the sub-index entries"""
160
160
  key = unicodedata.normalize('NFD', entry[0].lower())
161
161
  if key.startswith('\N{RIGHT-TO-LEFT MARK}'):
162
162
  key = key[1:]
@@ -47,7 +47,6 @@ def document_toc(env: BuildEnvironment, docname: str, tags: Tags) -> Node:
47
47
  For a ToC tree that shows the document's place in the
48
48
  ToC structure, use `get_toctree_for`.
49
49
  """
50
-
51
50
  tocdepth = env.metadata[docname].get('tocdepth', 0)
52
51
  try:
53
52
  toc = _toctree_copy(env.tocs[docname], 2, tocdepth, False, tags)
@@ -74,10 +73,8 @@ def global_toctree_for_doc(
74
73
 
75
74
  This gives the global ToC, with all ancestors and their siblings.
76
75
  """
77
-
78
- toctrees: list[Element] = []
79
- for toctree_node in env.master_doctree.findall(addnodes.toctree):
80
- if toctree := _resolve_toctree(
76
+ resolved = (
77
+ _resolve_toctree(
81
78
  env,
82
79
  docname,
83
80
  builder,
@@ -87,8 +84,13 @@ def global_toctree_for_doc(
87
84
  titles_only=titles_only,
88
85
  collapse=collapse,
89
86
  includehidden=includehidden,
90
- ):
91
- toctrees.append(toctree)
87
+ )
88
+ for toctree_node in env.master_doctree.findall(addnodes.toctree)
89
+ )
90
+ toctrees = [
91
+ toctree for toctree in resolved if toctree is not None
92
+ ]
93
+
92
94
  if not toctrees:
93
95
  return None
94
96
  result = toctrees[0]
@@ -113,7 +115,6 @@ def _resolve_toctree(
113
115
  If *collapse* is True, all branches not containing docname will
114
116
  be collapsed.
115
117
  """
116
-
117
118
  if toctree.get('hidden', False) and not includehidden:
118
119
  return None
119
120
 
@@ -250,7 +251,7 @@ def _entries_from_toctree(
250
251
  included,
251
252
  excluded,
252
253
  sub_toc_node,
253
- [refdoc] + parents,
254
+ [refdoc, *parents],
254
255
  subtree=True,
255
256
  ),
256
257
  start=sub_toc_node.parent.index(sub_toc_node) + 1,
@@ -41,19 +41,22 @@ class EnvironmentCollector:
41
41
  def clear_doc(self, app: Sphinx, env: BuildEnvironment, docname: str) -> None:
42
42
  """Remove specified data of a document.
43
43
 
44
- This method is called on the removal of the document."""
44
+ This method is called on the removal of the document.
45
+ """
45
46
  raise NotImplementedError
46
47
 
47
48
  def merge_other(self, app: Sphinx, env: BuildEnvironment,
48
49
  docnames: set[str], other: BuildEnvironment) -> None:
49
50
  """Merge in specified data regarding docnames from a different `BuildEnvironment`
50
- object which coming from a subprocess in parallel builds."""
51
+ object which coming from a subprocess in parallel builds.
52
+ """
51
53
  raise NotImplementedError
52
54
 
53
55
  def process_doc(self, app: Sphinx, doctree: nodes.document) -> None:
54
56
  """Process a document and gather specific data from it.
55
57
 
56
- This method is called after the document is read."""
58
+ This method is called after the document is read.
59
+ """
57
60
  raise NotImplementedError
58
61
 
59
62
  def get_updated_docs(self, app: Sphinx, env: BuildEnvironment) -> list[str]:
@@ -5,7 +5,7 @@ from __future__ import annotations
5
5
  import os
6
6
  from glob import glob
7
7
  from os import path
8
- from typing import TYPE_CHECKING, Any
8
+ from typing import TYPE_CHECKING
9
9
 
10
10
  from docutils import nodes
11
11
  from docutils.utils import relative_path
@@ -22,6 +22,7 @@ if TYPE_CHECKING:
22
22
 
23
23
  from sphinx.application import Sphinx
24
24
  from sphinx.environment import BuildEnvironment
25
+ from sphinx.util.typing import ExtensionMetadata
25
26
 
26
27
  logger = logging.getLogger(__name__)
27
28
 
@@ -121,7 +122,7 @@ class DownloadFileCollector(EnvironmentCollector):
121
122
  env.dlfiles.merge_other(docnames, other.dlfiles)
122
123
 
123
124
  def process_doc(self, app: Sphinx, doctree: nodes.document) -> None:
124
- """Process downloadable file paths. """
125
+ """Process downloadable file paths."""
125
126
  for node in doctree.findall(addnodes.download_reference):
126
127
  targetname = node['reftarget']
127
128
  if '://' in targetname:
@@ -136,7 +137,7 @@ class DownloadFileCollector(EnvironmentCollector):
136
137
  node['filename'] = app.env.dlfiles.add_file(app.env.docname, rel_filename)
137
138
 
138
139
 
139
- def setup(app: Sphinx) -> dict[str, Any]:
140
+ def setup(app: Sphinx) -> ExtensionMetadata:
140
141
  app.add_env_collector(ImageCollector)
141
142
  app.add_env_collector(DownloadFileCollector)
142
143
 
@@ -4,7 +4,7 @@ from __future__ import annotations
4
4
 
5
5
  import os
6
6
  from os import path
7
- from typing import TYPE_CHECKING, Any
7
+ from typing import TYPE_CHECKING
8
8
 
9
9
  from docutils.utils import relative_path
10
10
 
@@ -16,6 +16,7 @@ if TYPE_CHECKING:
16
16
 
17
17
  from sphinx.application import Sphinx
18
18
  from sphinx.environment import BuildEnvironment
19
+ from sphinx.util.typing import ExtensionMetadata
19
20
 
20
21
 
21
22
  class DependenciesCollector(EnvironmentCollector):
@@ -47,7 +48,7 @@ class DependenciesCollector(EnvironmentCollector):
47
48
  app.env.dependencies[app.env.docname].add(relpath)
48
49
 
49
50
 
50
- def setup(app: Sphinx) -> dict[str, Any]:
51
+ def setup(app: Sphinx) -> ExtensionMetadata:
51
52
  app.add_env_collector(DependenciesCollector)
52
53
 
53
54
  return {
@@ -2,7 +2,7 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
- from typing import TYPE_CHECKING, Any, cast
5
+ from typing import TYPE_CHECKING, cast
6
6
 
7
7
  from docutils import nodes
8
8
 
@@ -11,6 +11,7 @@ from sphinx.environment.collectors import EnvironmentCollector
11
11
  if TYPE_CHECKING:
12
12
  from sphinx.application import Sphinx
13
13
  from sphinx.environment import BuildEnvironment
14
+ from sphinx.util.typing import ExtensionMetadata
14
15
 
15
16
 
16
17
  class MetadataCollector(EnvironmentCollector):
@@ -29,7 +30,7 @@ class MetadataCollector(EnvironmentCollector):
29
30
 
30
31
  Keep processing minimal -- just return what docutils says.
31
32
  """
32
- index = doctree.first_child_not_matching_class(nodes.PreBibliographic)
33
+ index = doctree.first_child_not_matching_class(nodes.PreBibliographic) # type: ignore[arg-type]
33
34
  if index is None:
34
35
  return
35
36
  elif isinstance(doctree[index], nodes.docinfo):
@@ -46,11 +47,11 @@ class MetadataCollector(EnvironmentCollector):
46
47
  md[field_name.astext()] = field_body.astext()
47
48
  elif isinstance(node, nodes.TextElement):
48
49
  # other children must be TextElement
49
- # see: https://docutils.sourceforge.io/docs/ref/doctree.html#bibliographic-elements # noqa: E501
50
+ # see: https://docutils.sourceforge.io/docs/ref/doctree.html#bibliographic-elements # NoQA: E501
50
51
  md[node.__class__.__name__] = node.astext()
51
52
 
52
53
  for name, value in md.items():
53
- if name in ('tocdepth',):
54
+ if name == 'tocdepth':
54
55
  try:
55
56
  value = int(value)
56
57
  except ValueError:
@@ -60,7 +61,7 @@ class MetadataCollector(EnvironmentCollector):
60
61
  doctree.pop(index)
61
62
 
62
63
 
63
- def setup(app: Sphinx) -> dict[str, Any]:
64
+ def setup(app: Sphinx) -> ExtensionMetadata:
64
65
  app.add_env_collector(MetadataCollector)
65
66
 
66
67
  return {
@@ -2,7 +2,7 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
- from typing import TYPE_CHECKING, Any
5
+ from typing import TYPE_CHECKING
6
6
 
7
7
  from docutils import nodes
8
8
 
@@ -12,6 +12,7 @@ from sphinx.transforms import SphinxContentsFilter
12
12
  if TYPE_CHECKING:
13
13
  from sphinx.application import Sphinx
14
14
  from sphinx.environment import BuildEnvironment
15
+ from sphinx.util.typing import ExtensionMetadata
15
16
 
16
17
 
17
18
  class TitleCollector(EnvironmentCollector):
@@ -51,7 +52,7 @@ class TitleCollector(EnvironmentCollector):
51
52
  app.env.longtitles[app.env.docname] = longtitlenode
52
53
 
53
54
 
54
- def setup(app: Sphinx) -> dict[str, Any]:
55
+ def setup(app: Sphinx) -> ExtensionMetadata:
55
56
  app.add_env_collector(TitleCollector)
56
57
 
57
58
  return {
@@ -2,7 +2,7 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
- from typing import TYPE_CHECKING, Any, TypeVar, cast
5
+ from typing import TYPE_CHECKING, TypeVar, cast
6
6
 
7
7
  from docutils import nodes
8
8
 
@@ -20,6 +20,7 @@ if TYPE_CHECKING:
20
20
 
21
21
  from sphinx.application import Sphinx
22
22
  from sphinx.environment import BuildEnvironment
23
+ from sphinx.util.typing import ExtensionMetadata
23
24
 
24
25
  N = TypeVar('N')
25
26
 
@@ -201,7 +202,7 @@ class TocTreeCollector(EnvironmentCollector):
201
202
  numstack[-1] += 1
202
203
  reference = cast(nodes.reference, subnode[0])
203
204
  if depth > 0:
204
- number = list(numstack)
205
+ number = numstack.copy()
205
206
  secnums[reference['anchorname']] = tuple(numstack)
206
207
  else:
207
208
  number = None
@@ -283,7 +284,7 @@ class TocTreeCollector(EnvironmentCollector):
283
284
 
284
285
  secnum = secnum[:env.config.numfig_secnum_depth]
285
286
  counter[secnum] = counter.get(secnum, 0) + 1
286
- return secnum + (counter[secnum],)
287
+ return (*secnum, counter[secnum])
287
288
 
288
289
  def register_fignumber(docname: str, secnum: tuple[int, ...],
289
290
  figtype: str, fignode: Element) -> None:
@@ -345,7 +346,7 @@ def _make_anchor_name(ids: list[str], num_entries: list[int]) -> str:
345
346
  return anchorname
346
347
 
347
348
 
348
- def setup(app: Sphinx) -> dict[str, Any]:
349
+ def setup(app: Sphinx) -> ExtensionMetadata:
349
350
  app.add_env_collector(TocTreeCollector)
350
351
 
351
352
  return {
sphinx/errors.py CHANGED
@@ -25,16 +25,19 @@ class SphinxError(Exception):
25
25
  exception to a string ("category: message"). Should be set accordingly
26
26
  in subclasses.
27
27
  """
28
+
28
29
  category = 'Sphinx error'
29
30
 
30
31
 
31
32
  class SphinxWarning(SphinxError):
32
33
  """Warning, treated as error."""
34
+
33
35
  category = 'Warning, treated as error'
34
36
 
35
37
 
36
38
  class ApplicationError(SphinxError):
37
39
  """Application initialization error."""
40
+
38
41
  category = 'Application error'
39
42
 
40
43
 
@@ -42,7 +45,7 @@ class ExtensionError(SphinxError):
42
45
  """Extension error."""
43
46
 
44
47
  def __init__(
45
- self, message: str, orig_exc: Exception | None = None, modname: str | None = None,
48
+ self, message: str, orig_exc: Exception | None = None, modname: str | None = None
46
49
  ) -> None:
47
50
  super().__init__(message)
48
51
  self.message = message
@@ -70,26 +73,31 @@ class ExtensionError(SphinxError):
70
73
 
71
74
  class BuildEnvironmentError(SphinxError):
72
75
  """BuildEnvironment error."""
76
+
73
77
  category = 'BuildEnvironment error'
74
78
 
75
79
 
76
80
  class ConfigError(SphinxError):
77
81
  """Configuration error."""
82
+
78
83
  category = 'Configuration error'
79
84
 
80
85
 
81
86
  class DocumentError(SphinxError):
82
87
  """Document error."""
88
+
83
89
  category = 'Document error'
84
90
 
85
91
 
86
92
  class ThemeError(SphinxError):
87
93
  """Theme error."""
94
+
88
95
  category = 'Theme error'
89
96
 
90
97
 
91
98
  class VersionRequirementError(SphinxError):
92
99
  """Incompatible Sphinx version error."""
100
+
93
101
  category = 'Sphinx version error'
94
102
 
95
103
 
@@ -118,10 +126,13 @@ class PycodeError(Exception):
118
126
 
119
127
  class NoUri(Exception):
120
128
  """Raised by builder.get_relative_uri() or from missing-reference handlers
121
- if there is no URI available."""
129
+ if there is no URI available.
130
+ """
131
+
122
132
  pass
123
133
 
124
134
 
125
135
  class FiletypeNotFoundError(Exception):
126
136
  """Raised by get_filetype() if a filename matches no source suffix."""
137
+
127
138
  pass
sphinx/events.py CHANGED
@@ -77,21 +77,21 @@ class EventManager:
77
77
  def disconnect(self, listener_id: int) -> None:
78
78
  """Disconnect a handler."""
79
79
  for listeners in self.listeners.values():
80
- for listener in listeners[:]:
80
+ for listener in listeners.copy():
81
81
  if listener.id == listener_id:
82
82
  listeners.remove(listener)
83
83
 
84
- def emit(self, name: str, *args: Any,
85
- allowed_exceptions: tuple[type[Exception], ...] = ()) -> list:
84
+ def emit(
85
+ self, name: str, *args: Any, allowed_exceptions: tuple[type[Exception], ...] = ()
86
+ ) -> list:
86
87
  """Emit a Sphinx event."""
87
-
88
88
  # not every object likes to be repr()'d (think
89
89
  # random stuff coming via autodoc)
90
90
  with contextlib.suppress(Exception):
91
91
  logger.debug('[app] emitting event: %r%s', name, repr(args)[:100])
92
92
 
93
93
  results = []
94
- listeners = sorted(self.listeners[name], key=attrgetter("priority"))
94
+ listeners = sorted(self.listeners[name], key=attrgetter('priority'))
95
95
  for listener in listeners:
96
96
  try:
97
97
  results.append(listener.handler(self.app, *args))
@@ -105,12 +105,17 @@ class EventManager:
105
105
  # Just pass through the error, so that it can be debugged.
106
106
  raise
107
107
  modname = safe_getattr(listener.handler, '__module__', None)
108
- raise ExtensionError(__("Handler %r for event %r threw an exception") %
109
- (listener.handler, name), exc, modname=modname) from exc
108
+ raise ExtensionError(
109
+ __('Handler %r for event %r threw an exception')
110
+ % (listener.handler, name),
111
+ exc,
112
+ modname=modname,
113
+ ) from exc
110
114
  return results
111
115
 
112
- def emit_firstresult(self, name: str, *args: Any,
113
- allowed_exceptions: tuple[type[Exception], ...] = ()) -> Any:
116
+ def emit_firstresult(
117
+ self, name: str, *args: Any, allowed_exceptions: tuple[type[Exception], ...] = ()
118
+ ) -> Any:
114
119
  """Emit a Sphinx event and returns first result.
115
120
 
116
121
  This returns the result of the first handler that doesn't return ``None``.
sphinx/ext/apidoc.py CHANGED
@@ -32,7 +32,7 @@ from sphinx.util.osutil import FileAvoidWrite, ensuredir
32
32
  from sphinx.util.template import ReSTRenderer
33
33
 
34
34
  if TYPE_CHECKING:
35
- from collections.abc import Generator, Sequence
35
+ from collections.abc import Iterator, Sequence
36
36
 
37
37
  logger = logging.getLogger(__name__)
38
38
 
@@ -47,7 +47,7 @@ else:
47
47
  'show-inheritance',
48
48
  ]
49
49
 
50
- PY_SUFFIXES = ('.py', '.pyx') + tuple(EXTENSION_SUFFIXES)
50
+ PY_SUFFIXES = ('.py', '.pyx', *tuple(EXTENSION_SUFFIXES))
51
51
 
52
52
  template_dir = path.join(package_dir, 'templates', 'apidoc')
53
53
 
@@ -68,7 +68,7 @@ def module_join(*modnames: str | None) -> str:
68
68
 
69
69
  def is_packagedir(dirname: str | None = None, files: list[str] | None = None) -> bool:
70
70
  """Check given *files* contains __init__ file."""
71
- if files is None and dirname is None:
71
+ if files is dirname is None:
72
72
  return False
73
73
 
74
74
  if files is None:
@@ -168,7 +168,7 @@ def create_modules_toc_file(modules: list[str], opts: Any, name: str = 'modules'
168
168
  """Create the module's index."""
169
169
  modules.sort()
170
170
  prev_module = ''
171
- for module in modules[:]:
171
+ for module in modules.copy():
172
172
  # look if the module is a subpackage and, if yes, ignore it
173
173
  if module.startswith(prev_module + '.'):
174
174
  modules.remove(module)
@@ -209,14 +209,12 @@ def is_skipped_module(filename: str, opts: Any, _excludes: Sequence[re.Pattern[s
209
209
  if not path.exists(filename):
210
210
  # skip if the file doesn't exist
211
211
  return True
212
- if path.basename(filename).startswith('_') and not opts.includeprivate:
213
- # skip if the module has a "private" name
214
- return True
215
- return False
212
+ # skip if the module has a "private" name
213
+ return path.basename(filename).startswith('_') and not opts.includeprivate
216
214
 
217
215
 
218
216
  def walk(rootpath: str, excludes: Sequence[re.Pattern[str]], opts: Any,
219
- ) -> Generator[tuple[str, list[str], list[str]], None, None]:
217
+ ) -> Iterator[tuple[str, list[str], list[str]]]:
220
218
  """Walk through the directory and list files and subdirectories up."""
221
219
  followlinks = getattr(opts, 'followlinks', False)
222
220
  includeprivate = getattr(opts, 'includeprivate', False)
@@ -268,14 +266,14 @@ def recurse_tree(rootpath: str, excludes: Sequence[re.Pattern[str]], opts: Any,
268
266
  is_pkg = is_packagedir(None, files)
269
267
  is_namespace = not is_pkg and implicit_namespaces
270
268
  if is_pkg:
271
- for f in files[:]:
269
+ for f in files.copy():
272
270
  if is_initpy(f):
273
271
  files.remove(f)
274
272
  files.insert(0, f)
275
273
  elif root != rootpath:
276
274
  # only accept non-package at toplevel unless using implicit namespaces
277
275
  if not implicit_namespaces:
278
- del subs[:]
276
+ subs.clear()
279
277
  continue
280
278
 
281
279
  if is_pkg or is_namespace: