Sphinx 8.0.2__py3-none-any.whl → 8.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of Sphinx might be problematic. Click here for more details.
- sphinx/__init__.py +6 -3
- sphinx/_cli/__init__.py +40 -20
- sphinx/_cli/util/colour.py +5 -4
- sphinx/_cli/util/errors.py +28 -11
- sphinx/application.py +361 -38
- sphinx/builders/__init__.py +229 -83
- sphinx/builders/_epub_base.py +118 -71
- sphinx/builders/changes.py +39 -21
- sphinx/builders/dirhtml.py +4 -4
- sphinx/builders/dummy.py +2 -5
- sphinx/builders/epub3.py +43 -22
- sphinx/builders/gettext.py +43 -25
- sphinx/builders/html/__init__.py +284 -218
- sphinx/builders/html/_assets.py +62 -26
- sphinx/builders/html/_build_info.py +76 -0
- sphinx/builders/html/transforms.py +11 -9
- sphinx/builders/latex/__init__.py +139 -81
- sphinx/builders/latex/constants.py +7 -7
- sphinx/builders/latex/nodes.py +3 -2
- sphinx/builders/latex/theming.py +7 -5
- sphinx/builders/latex/transforms.py +27 -19
- sphinx/builders/linkcheck.py +146 -72
- sphinx/builders/manpage.py +30 -13
- sphinx/builders/singlehtml.py +22 -14
- sphinx/builders/texinfo.py +67 -37
- sphinx/builders/text.py +5 -5
- sphinx/builders/xml.py +6 -9
- sphinx/cmd/build.py +282 -103
- sphinx/cmd/make_mode.py +106 -63
- sphinx/cmd/quickstart.py +341 -145
- sphinx/config.py +45 -12
- sphinx/deprecation.py +8 -2
- sphinx/directives/__init__.py +28 -19
- sphinx/directives/code.py +86 -56
- sphinx/directives/other.py +50 -36
- sphinx/directives/patches.py +29 -19
- sphinx/domains/__init__.py +20 -120
- sphinx/domains/_domains_container.py +281 -0
- sphinx/domains/_index.py +110 -0
- sphinx/domains/c/__init__.py +3 -3
- sphinx/domains/c/_parser.py +10 -6
- sphinx/domains/changeset.py +5 -3
- sphinx/domains/citation.py +5 -3
- sphinx/domains/cpp/__init__.py +9 -11
- sphinx/domains/cpp/_parser.py +8 -7
- sphinx/domains/index.py +3 -3
- sphinx/domains/javascript.py +12 -7
- sphinx/domains/math.py +2 -2
- sphinx/domains/python/__init__.py +10 -5
- sphinx/domains/python/_object.py +1 -1
- sphinx/domains/rst.py +5 -5
- sphinx/domains/std/__init__.py +16 -11
- sphinx/environment/__init__.py +206 -146
- sphinx/environment/adapters/asset.py +3 -2
- sphinx/environment/adapters/indexentries.py +74 -33
- sphinx/environment/adapters/toctree.py +100 -43
- sphinx/environment/collectors/__init__.py +19 -8
- sphinx/environment/collectors/asset.py +47 -15
- sphinx/environment/collectors/dependencies.py +8 -4
- sphinx/environment/collectors/metadata.py +7 -2
- sphinx/environment/collectors/title.py +7 -2
- sphinx/environment/collectors/toctree.py +54 -22
- sphinx/errors.py +4 -1
- sphinx/events.py +314 -7
- sphinx/ext/apidoc.py +42 -18
- sphinx/ext/autodoc/__init__.py +52 -24
- sphinx/ext/autodoc/importer.py +6 -9
- sphinx/ext/autosectionlabel.py +1 -2
- sphinx/ext/autosummary/__init__.py +3 -1
- sphinx/ext/autosummary/generate.py +28 -14
- sphinx/ext/coverage.py +7 -7
- sphinx/ext/doctest.py +4 -8
- sphinx/ext/duration.py +6 -5
- sphinx/ext/inheritance_diagram.py +1 -1
- sphinx/ext/intersphinx/_cli.py +6 -4
- sphinx/ext/intersphinx/_load.py +77 -32
- sphinx/ext/intersphinx/_resolve.py +173 -79
- sphinx/ext/intersphinx/_shared.py +7 -5
- sphinx/ext/linkcode.py +7 -1
- sphinx/ext/mathjax.py +1 -2
- sphinx/ext/napoleon/__init__.py +37 -24
- sphinx/ext/napoleon/docstring.py +202 -134
- sphinx/ext/todo.py +5 -3
- sphinx/highlighting.py +9 -2
- sphinx/io.py +1 -1
- sphinx/jinja2glue.py +27 -6
- sphinx/locale/__init__.py +6 -2
- sphinx/locale/ar/LC_MESSAGES/sphinx.js +8 -1
- sphinx/locale/ar/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/ar/LC_MESSAGES/sphinx.po +2246 -2288
- sphinx/locale/bg/LC_MESSAGES/sphinx.js +4 -1
- sphinx/locale/bg/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/bg/LC_MESSAGES/sphinx.po +2113 -2159
- sphinx/locale/bn/LC_MESSAGES/sphinx.js +4 -1
- sphinx/locale/bn/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/bn/LC_MESSAGES/sphinx.po +2349 -2395
- sphinx/locale/ca/LC_MESSAGES/sphinx.js +4 -1
- sphinx/locale/ca/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/ca/LC_MESSAGES/sphinx.po +2846 -2892
- sphinx/locale/cak/LC_MESSAGES/sphinx.js +4 -1
- sphinx/locale/cak/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/cak/LC_MESSAGES/sphinx.po +2213 -2259
- sphinx/locale/cs/LC_MESSAGES/sphinx.js +6 -1
- sphinx/locale/cs/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/cs/LC_MESSAGES/sphinx.po +2225 -2269
- sphinx/locale/cy/LC_MESSAGES/sphinx.js +6 -1
- sphinx/locale/cy/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/cy/LC_MESSAGES/sphinx.po +2403 -2447
- sphinx/locale/da/LC_MESSAGES/sphinx.js +4 -1
- sphinx/locale/da/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/da/LC_MESSAGES/sphinx.po +2214 -2260
- sphinx/locale/de/LC_MESSAGES/sphinx.js +4 -1
- sphinx/locale/de/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/de/LC_MESSAGES/sphinx.po +2230 -2276
- sphinx/locale/de_DE/LC_MESSAGES/sphinx.js +4 -1
- sphinx/locale/de_DE/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/de_DE/LC_MESSAGES/sphinx.po +2113 -2159
- sphinx/locale/el/LC_MESSAGES/sphinx.js +4 -1
- sphinx/locale/el/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/el/LC_MESSAGES/sphinx.po +2619 -2665
- sphinx/locale/en_DE/LC_MESSAGES/sphinx.js +4 -1
- sphinx/locale/en_DE/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/en_DE/LC_MESSAGES/sphinx.po +2113 -2159
- sphinx/locale/en_FR/LC_MESSAGES/sphinx.js +4 -1
- sphinx/locale/en_FR/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/en_FR/LC_MESSAGES/sphinx.po +2113 -2159
- sphinx/locale/en_GB/LC_MESSAGES/sphinx.js +4 -1
- sphinx/locale/en_GB/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/en_GB/LC_MESSAGES/sphinx.po +2519 -2565
- sphinx/locale/en_HK/LC_MESSAGES/sphinx.js +4 -1
- sphinx/locale/en_HK/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/en_HK/LC_MESSAGES/sphinx.po +2113 -2159
- sphinx/locale/eo/LC_MESSAGES/sphinx.js +4 -1
- sphinx/locale/eo/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/eo/LC_MESSAGES/sphinx.po +2232 -2278
- sphinx/locale/es/LC_MESSAGES/sphinx.js +5 -1
- sphinx/locale/es/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/es/LC_MESSAGES/sphinx.po +2516 -2561
- sphinx/locale/es_CO/LC_MESSAGES/sphinx.js +5 -1
- sphinx/locale/es_CO/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/es_CO/LC_MESSAGES/sphinx.po +2114 -2159
- sphinx/locale/et/LC_MESSAGES/sphinx.js +4 -1
- sphinx/locale/et/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/et/LC_MESSAGES/sphinx.po +2317 -2363
- sphinx/locale/eu/LC_MESSAGES/sphinx.js +4 -1
- sphinx/locale/eu/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/eu/LC_MESSAGES/sphinx.po +2218 -2264
- sphinx/locale/fa/LC_MESSAGES/sphinx.js +4 -1
- sphinx/locale/fa/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/fa/LC_MESSAGES/sphinx.po +2505 -2551
- sphinx/locale/fi/LC_MESSAGES/sphinx.js +4 -1
- sphinx/locale/fi/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/fi/LC_MESSAGES/sphinx.po +2303 -2349
- sphinx/locale/fr/LC_MESSAGES/sphinx.js +6 -2
- sphinx/locale/fr/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/fr/LC_MESSAGES/sphinx.po +2863 -2908
- sphinx/locale/fr_FR/LC_MESSAGES/sphinx.js +5 -1
- sphinx/locale/fr_FR/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/fr_FR/LC_MESSAGES/sphinx.po +2114 -2159
- sphinx/locale/gl/LC_MESSAGES/sphinx.js +4 -1
- sphinx/locale/gl/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/gl/LC_MESSAGES/sphinx.po +2571 -2617
- sphinx/locale/he/LC_MESSAGES/sphinx.js +5 -1
- sphinx/locale/he/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/he/LC_MESSAGES/sphinx.po +2307 -2352
- sphinx/locale/hi/LC_MESSAGES/sphinx.js +4 -1
- sphinx/locale/hi/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/hi/LC_MESSAGES/sphinx.po +2580 -2626
- sphinx/locale/hi_IN/LC_MESSAGES/sphinx.js +4 -1
- sphinx/locale/hi_IN/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/hi_IN/LC_MESSAGES/sphinx.po +2113 -2159
- sphinx/locale/hr/LC_MESSAGES/sphinx.js +5 -1
- sphinx/locale/hr/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/hr/LC_MESSAGES/sphinx.po +2238 -2283
- sphinx/locale/hu/LC_MESSAGES/sphinx.js +4 -1
- sphinx/locale/hu/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/hu/LC_MESSAGES/sphinx.po +2228 -2274
- sphinx/locale/id/LC_MESSAGES/sphinx.js +3 -1
- sphinx/locale/id/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/id/LC_MESSAGES/sphinx.po +2787 -2834
- sphinx/locale/is/LC_MESSAGES/sphinx.js +4 -1
- sphinx/locale/is/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/is/LC_MESSAGES/sphinx.po +2224 -2270
- sphinx/locale/it/LC_MESSAGES/sphinx.js +5 -1
- sphinx/locale/it/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/it/LC_MESSAGES/sphinx.po +2231 -2276
- sphinx/locale/ja/LC_MESSAGES/sphinx.js +3 -1
- sphinx/locale/ja/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/ja/LC_MESSAGES/sphinx.po +2507 -2554
- sphinx/locale/ka/LC_MESSAGES/sphinx.js +4 -1
- sphinx/locale/ka/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/ka/LC_MESSAGES/sphinx.po +2428 -2474
- sphinx/locale/ko/LC_MESSAGES/sphinx.js +3 -1
- sphinx/locale/ko/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/ko/LC_MESSAGES/sphinx.po +2516 -2563
- sphinx/locale/lt/LC_MESSAGES/sphinx.js +6 -1
- sphinx/locale/lt/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/lt/LC_MESSAGES/sphinx.po +2425 -2469
- sphinx/locale/lv/LC_MESSAGES/sphinx.js +5 -1
- sphinx/locale/lv/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/lv/LC_MESSAGES/sphinx.po +2362 -2407
- sphinx/locale/mk/LC_MESSAGES/sphinx.js +4 -1
- sphinx/locale/mk/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/mk/LC_MESSAGES/sphinx.po +2121 -2167
- sphinx/locale/nb_NO/LC_MESSAGES/sphinx.js +4 -1
- sphinx/locale/nb_NO/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/nb_NO/LC_MESSAGES/sphinx.po +2220 -2266
- sphinx/locale/ne/LC_MESSAGES/sphinx.js +4 -1
- sphinx/locale/ne/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/ne/LC_MESSAGES/sphinx.po +2221 -2267
- sphinx/locale/nl/LC_MESSAGES/sphinx.js +4 -1
- sphinx/locale/nl/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/nl/LC_MESSAGES/sphinx.po +2240 -2286
- sphinx/locale/pl/LC_MESSAGES/sphinx.js +6 -1
- sphinx/locale/pl/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/pl/LC_MESSAGES/sphinx.po +2319 -2363
- sphinx/locale/pt/LC_MESSAGES/sphinx.js +5 -1
- sphinx/locale/pt/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/pt/LC_MESSAGES/sphinx.po +2114 -2159
- sphinx/locale/pt_BR/LC_MESSAGES/sphinx.js +5 -1
- sphinx/locale/pt_BR/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/pt_BR/LC_MESSAGES/sphinx.po +2854 -2899
- sphinx/locale/pt_PT/LC_MESSAGES/sphinx.js +5 -1
- sphinx/locale/pt_PT/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/pt_PT/LC_MESSAGES/sphinx.po +2224 -2269
- sphinx/locale/ro/LC_MESSAGES/sphinx.js +5 -1
- sphinx/locale/ro/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/ro/LC_MESSAGES/sphinx.po +2226 -2271
- sphinx/locale/ru/LC_MESSAGES/sphinx.js +8 -3
- sphinx/locale/ru/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/ru/LC_MESSAGES/sphinx.po +2841 -2885
- sphinx/locale/si/LC_MESSAGES/sphinx.js +4 -1
- sphinx/locale/si/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/si/LC_MESSAGES/sphinx.po +2294 -2340
- sphinx/locale/sk/LC_MESSAGES/sphinx.js +6 -1
- sphinx/locale/sk/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/sk/LC_MESSAGES/sphinx.po +2497 -2541
- sphinx/locale/sl/LC_MESSAGES/sphinx.js +6 -1
- sphinx/locale/sl/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/sl/LC_MESSAGES/sphinx.po +2331 -2375
- sphinx/locale/sphinx.pot +2121 -2167
- sphinx/locale/sq/LC_MESSAGES/sphinx.js +4 -1
- sphinx/locale/sq/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/sq/LC_MESSAGES/sphinx.po +2855 -2901
- sphinx/locale/sr/LC_MESSAGES/sphinx.js +5 -1
- sphinx/locale/sr/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/sr/LC_MESSAGES/sphinx.po +2203 -2248
- sphinx/locale/sr@latin/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/sr_RS/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/sv/LC_MESSAGES/sphinx.js +4 -1
- sphinx/locale/sv/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/sv/LC_MESSAGES/sphinx.po +2423 -2469
- sphinx/locale/te/LC_MESSAGES/sphinx.js +4 -1
- sphinx/locale/te/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/te/LC_MESSAGES/sphinx.po +2113 -2159
- sphinx/locale/tr/LC_MESSAGES/sphinx.js +4 -1
- sphinx/locale/tr/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/tr/LC_MESSAGES/sphinx.po +2443 -2489
- sphinx/locale/uk_UA/LC_MESSAGES/sphinx.js +6 -1
- sphinx/locale/uk_UA/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/uk_UA/LC_MESSAGES/sphinx.po +2329 -2373
- sphinx/locale/ur/LC_MESSAGES/sphinx.js +4 -1
- sphinx/locale/ur/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/ur/LC_MESSAGES/sphinx.po +2113 -2159
- sphinx/locale/vi/LC_MESSAGES/sphinx.js +3 -1
- sphinx/locale/vi/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/vi/LC_MESSAGES/sphinx.po +2199 -2246
- sphinx/locale/yue/LC_MESSAGES/sphinx.js +3 -1
- sphinx/locale/yue/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/yue/LC_MESSAGES/sphinx.po +2112 -2159
- sphinx/locale/zh_HK/LC_MESSAGES/sphinx.js +3 -1
- sphinx/locale/zh_HK/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/zh_HK/LC_MESSAGES/sphinx.po +2112 -2159
- sphinx/locale/zh_TW/LC_MESSAGES/sphinx.js +3 -1
- sphinx/locale/zh_TW/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/zh_TW/LC_MESSAGES/sphinx.po +2845 -2892
- sphinx/locale/zh_TW.Big5/LC_MESSAGES/sphinx.js +3 -1
- sphinx/locale/zh_TW.Big5/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/zh_TW.Big5/LC_MESSAGES/sphinx.po +2112 -2159
- sphinx/parsers.py +3 -1
- sphinx/project.py +6 -2
- sphinx/pycode/__init__.py +11 -4
- sphinx/pycode/ast.py +58 -58
- sphinx/pycode/parser.py +49 -28
- sphinx/pygments_styles.py +49 -49
- sphinx/registry.py +8 -3
- sphinx/roles.py +133 -13
- sphinx/search/__init__.py +146 -87
- sphinx/search/da.py +2 -4
- sphinx/search/de.py +2 -4
- sphinx/search/en.py +4 -4
- sphinx/search/es.py +2 -4
- sphinx/search/fi.py +2 -4
- sphinx/search/fr.py +2 -4
- sphinx/search/hu.py +2 -4
- sphinx/search/it.py +2 -4
- sphinx/search/ja.py +55 -32
- sphinx/search/nl.py +2 -4
- sphinx/search/no.py +2 -4
- sphinx/search/pt.py +2 -4
- sphinx/search/ro.py +0 -2
- sphinx/search/ru.py +2 -4
- sphinx/search/sv.py +2 -4
- sphinx/search/tr.py +0 -2
- sphinx/search/zh.py +18 -13
- sphinx/templates/graphviz/graphviz.css +0 -7
- sphinx/testing/fixtures.py +6 -5
- sphinx/testing/path.py +7 -5
- sphinx/testing/util.py +63 -29
- sphinx/texinputs/sphinx.sty +107 -39
- sphinx/texinputs/sphinxlatexadmonitions.sty +51 -35
- sphinx/texinputs/sphinxlatexcontainers.sty +1 -1
- sphinx/texinputs/sphinxlatexgraphics.sty +3 -2
- sphinx/texinputs/sphinxlatexindbibtoc.sty +1 -1
- sphinx/texinputs/sphinxlatexlists.sty +1 -1
- sphinx/texinputs/sphinxlatexliterals.sty +4 -1
- sphinx/texinputs/sphinxlatexnumfig.sty +22 -9
- sphinx/texinputs/sphinxlatexobjects.sty +1 -1
- sphinx/texinputs/sphinxlatexshadowbox.sty +72 -10
- sphinx/texinputs/sphinxlatexstyleheadings.sty +7 -2
- sphinx/texinputs/sphinxlatexstylepage.sty +2 -8
- sphinx/texinputs/sphinxlatexstyletext.sty +2 -4
- sphinx/texinputs/sphinxlatextables.sty +1 -1
- sphinx/texinputs/sphinxoptionsgeometry.sty +1 -1
- sphinx/texinputs/sphinxoptionshyperref.sty +1 -1
- sphinx/themes/agogo/layout.html +1 -10
- sphinx/themes/agogo/static/agogo.css.jinja +0 -7
- sphinx/themes/basic/defindex.html +1 -8
- sphinx/themes/basic/domainindex.html +1 -9
- sphinx/themes/basic/genindex-single.html +1 -9
- sphinx/themes/basic/genindex-split.html +1 -9
- sphinx/themes/basic/genindex.html +1 -9
- sphinx/themes/basic/globaltoc.html +1 -9
- sphinx/themes/basic/layout.html +1 -9
- sphinx/themes/basic/localtoc.html +1 -9
- sphinx/themes/basic/page.html +1 -9
- sphinx/themes/basic/relations.html +1 -9
- sphinx/themes/basic/search.html +1 -9
- sphinx/themes/basic/searchbox.html +1 -9
- sphinx/themes/basic/searchfield.html +4 -10
- sphinx/themes/basic/sourcelink.html +1 -9
- sphinx/themes/basic/static/basic.css.jinja +2 -13
- sphinx/themes/basic/static/doctools.js +0 -7
- sphinx/themes/basic/static/language_data.js.jinja +0 -7
- sphinx/themes/basic/static/searchtools.js +25 -13
- sphinx/themes/bizstyle/layout.html +1 -9
- sphinx/themes/bizstyle/static/bizstyle.css.jinja +0 -7
- sphinx/themes/bizstyle/static/bizstyle.js.jinja +5 -11
- sphinx/themes/classic/layout.html +1 -9
- sphinx/themes/classic/static/classic.css.jinja +0 -7
- sphinx/themes/classic/static/sidebar.js.jinja +0 -6
- sphinx/themes/epub/epub-cover.html +1 -9
- sphinx/themes/epub/layout.html +1 -9
- sphinx/themes/epub/static/epub.css.jinja +0 -7
- sphinx/themes/haiku/layout.html +1 -9
- sphinx/themes/haiku/static/haiku.css.jinja +0 -6
- sphinx/themes/nature/static/nature.css.jinja +0 -7
- sphinx/themes/nonav/layout.html +1 -9
- sphinx/themes/nonav/static/nonav.css.jinja +0 -7
- sphinx/themes/pyramid/static/epub.css.jinja +0 -7
- sphinx/themes/pyramid/static/pyramid.css.jinja +0 -7
- sphinx/themes/scrolls/layout.html +1 -10
- sphinx/themes/scrolls/static/scrolls.css.jinja +0 -7
- sphinx/themes/sphinxdoc/static/sphinxdoc.css.jinja +2 -7
- sphinx/themes/traditional/static/traditional.css.jinja +0 -7
- sphinx/theming.py +18 -6
- sphinx/transforms/__init__.py +56 -35
- sphinx/transforms/compact_bullet_list.py +3 -2
- sphinx/transforms/i18n.py +132 -50
- sphinx/transforms/post_transforms/__init__.py +94 -43
- sphinx/transforms/post_transforms/code.py +7 -6
- sphinx/transforms/post_transforms/images.py +71 -54
- sphinx/transforms/references.py +1 -2
- sphinx/util/__init__.py +23 -194
- sphinx/util/_files.py +80 -0
- sphinx/util/_importer.py +27 -0
- sphinx/util/_io.py +1 -2
- sphinx/util/_lines.py +26 -0
- sphinx/util/_pathlib.py +5 -2
- sphinx/util/_serialise.py +53 -0
- sphinx/util/_timestamps.py +2 -1
- sphinx/util/_uri.py +16 -0
- sphinx/util/cfamily.py +48 -25
- sphinx/util/console.py +1 -0
- sphinx/util/display.py +1 -1
- sphinx/util/docfields.py +125 -45
- sphinx/util/docstrings.py +1 -1
- sphinx/util/docutils.py +118 -44
- sphinx/util/exceptions.py +11 -5
- sphinx/util/fileutil.py +53 -32
- sphinx/util/http_date.py +9 -7
- sphinx/util/i18n.py +49 -16
- sphinx/util/images.py +7 -6
- sphinx/util/inspect.py +29 -12
- sphinx/util/inventory.py +47 -29
- sphinx/util/logging.py +58 -85
- sphinx/util/matching.py +3 -3
- sphinx/util/math.py +1 -1
- sphinx/util/nodes.py +176 -108
- sphinx/util/osutil.py +13 -10
- sphinx/util/parallel.py +5 -4
- sphinx/util/parsing.py +5 -3
- sphinx/util/png.py +3 -3
- sphinx/util/requests.py +8 -4
- sphinx/util/rst.py +5 -3
- sphinx/util/tags.py +5 -2
- sphinx/util/template.py +26 -11
- sphinx/util/texescape.py +2 -2
- sphinx/util/typing.py +89 -38
- sphinx/versioning.py +3 -1
- sphinx/writers/html.py +22 -7
- sphinx/writers/html5.py +113 -64
- sphinx/writers/latex.py +408 -221
- sphinx/writers/manpage.py +25 -15
- sphinx/writers/texinfo.py +94 -82
- sphinx/writers/text.py +87 -53
- sphinx/writers/xml.py +5 -4
- sphinx-8.1.0.dist-info/LICENSE.rst +31 -0
- {sphinx-8.0.2.dist-info → sphinx-8.1.0.dist-info}/METADATA +13 -11
- sphinx-8.1.0.dist-info/RECORD +598 -0
- sphinx-8.0.2.dist-info/LICENSE.rst +0 -67
- sphinx-8.0.2.dist-info/RECORD +0 -590
- {sphinx-8.0.2.dist-info → sphinx-8.1.0.dist-info}/WHEEL +0 -0
- {sphinx-8.0.2.dist-info → sphinx-8.1.0.dist-info}/entry_points.txt +0 -0
sphinx/ext/napoleon/docstring.py
CHANGED
|
@@ -31,7 +31,8 @@ _xref_or_code_regex = re.compile(
|
|
|
31
31
|
r'((?::(?:[a-zA-Z0-9]+[\-_+:.])*[a-zA-Z0-9]+:`.+?`)|'
|
|
32
32
|
r'(?:``.+?``)|'
|
|
33
33
|
r'(?::meta .+:.*)|'
|
|
34
|
-
r'(?:`.+?\s*(?<!\x00)<.*?>`))'
|
|
34
|
+
r'(?:`.+?\s*(?<!\x00)<.*?>`))'
|
|
35
|
+
)
|
|
35
36
|
_xref_regex = re.compile(
|
|
36
37
|
r'(?:(?::(?:[a-zA-Z0-9]+[\-_+:.])*[a-zA-Z0-9]+:)?`.+?`)',
|
|
37
38
|
)
|
|
@@ -39,20 +40,21 @@ _bullet_list_regex = re.compile(r'^(\*|\+|\-)(\s+\S|\s*$)')
|
|
|
39
40
|
_enumerated_list_regex = re.compile(
|
|
40
41
|
r'^(?P<paren>\()?'
|
|
41
42
|
r'(\d+|#|[ivxlcdm]+|[IVXLCDM]+|[a-zA-Z])'
|
|
42
|
-
r'(?(paren)\)|\.)(\s+\S|\s*$)'
|
|
43
|
+
r'(?(paren)\)|\.)(\s+\S|\s*$)'
|
|
44
|
+
)
|
|
43
45
|
_token_regex = re.compile(
|
|
44
|
-
r
|
|
45
|
-
r
|
|
46
|
+
r'(,\sor\s|\sor\s|\sof\s|:\s|\sto\s|,\sand\s|\sand\s|,\s'
|
|
47
|
+
r'|[{]|[}]'
|
|
46
48
|
r'|"(?:\\"|[^"])*"'
|
|
47
49
|
r"|'(?:\\'|[^'])*')",
|
|
48
50
|
)
|
|
49
51
|
_default_regex = re.compile(
|
|
50
|
-
r
|
|
52
|
+
r'^default[^_0-9A-Za-z].*$',
|
|
51
53
|
)
|
|
52
|
-
_SINGLETONS = (
|
|
54
|
+
_SINGLETONS = ('None', 'True', 'False', 'Ellipsis')
|
|
53
55
|
|
|
54
56
|
|
|
55
|
-
class Deque(collections.deque):
|
|
57
|
+
class Deque(collections.deque[Any]):
|
|
56
58
|
"""
|
|
57
59
|
A subclass of deque that mimics ``pockets.iterators.modify_iter``.
|
|
58
60
|
|
|
@@ -147,8 +149,11 @@ class GoogleDocstring:
|
|
|
147
149
|
|
|
148
150
|
"""
|
|
149
151
|
|
|
150
|
-
_name_rgx = re.compile(
|
|
151
|
-
|
|
152
|
+
_name_rgx = re.compile(
|
|
153
|
+
r'^\s*((?::(?P<role>\S+):)?`(?P<name>~?[a-zA-Z0-9_.-]+)`|'
|
|
154
|
+
r' (?P<name2>~?[a-zA-Z0-9_.-]+))\s*',
|
|
155
|
+
re.VERBOSE,
|
|
156
|
+
)
|
|
152
157
|
|
|
153
158
|
def __init__(
|
|
154
159
|
self,
|
|
@@ -195,7 +200,7 @@ class GoogleDocstring:
|
|
|
195
200
|
if not hasattr(self, '_directive_sections'):
|
|
196
201
|
self._directive_sections: list[str] = []
|
|
197
202
|
if not hasattr(self, '_sections'):
|
|
198
|
-
self._sections: dict[str, Callable] = {
|
|
203
|
+
self._sections: dict[str, Callable[..., list[str]]] = {
|
|
199
204
|
'args': self._parse_parameters_section,
|
|
200
205
|
'arguments': self._parse_parameters_section,
|
|
201
206
|
'attention': partial(self._parse_admonition, 'attention'),
|
|
@@ -261,9 +266,8 @@ class GoogleDocstring:
|
|
|
261
266
|
def _consume_indented_block(self, indent: int = 1) -> list[str]:
|
|
262
267
|
lines = []
|
|
263
268
|
line = self._lines.get(0)
|
|
264
|
-
while (
|
|
265
|
-
not self.
|
|
266
|
-
(not line or self._is_indented(line, indent))
|
|
269
|
+
while not self._is_section_break() and (
|
|
270
|
+
not line or self._is_indented(line, indent)
|
|
267
271
|
):
|
|
268
272
|
lines.append(self._lines.next())
|
|
269
273
|
line = self._lines.get(0)
|
|
@@ -271,9 +275,7 @@ class GoogleDocstring:
|
|
|
271
275
|
|
|
272
276
|
def _consume_contiguous(self) -> list[str]:
|
|
273
277
|
lines = []
|
|
274
|
-
while
|
|
275
|
-
self._lines.get(0) and
|
|
276
|
-
not self._is_section_header()):
|
|
278
|
+
while self._lines and self._lines.get(0) and not self._is_section_header():
|
|
277
279
|
lines.append(self._lines.next())
|
|
278
280
|
return lines
|
|
279
281
|
|
|
@@ -285,8 +287,11 @@ class GoogleDocstring:
|
|
|
285
287
|
line = self._lines.get(0)
|
|
286
288
|
return lines
|
|
287
289
|
|
|
288
|
-
def _consume_field(
|
|
289
|
-
|
|
290
|
+
def _consume_field(
|
|
291
|
+
self,
|
|
292
|
+
parse_type: bool = True,
|
|
293
|
+
prefer_type: bool = False,
|
|
294
|
+
) -> tuple[str, str, list[str]]:
|
|
290
295
|
line = self._lines.next()
|
|
291
296
|
|
|
292
297
|
before, colon, after = self._partition_field_on_colon(line)
|
|
@@ -311,14 +316,15 @@ class GoogleDocstring:
|
|
|
311
316
|
_descs = self.__class__(_descs, self._config).lines()
|
|
312
317
|
return _name, _type, _descs
|
|
313
318
|
|
|
314
|
-
def _consume_fields(
|
|
315
|
-
|
|
319
|
+
def _consume_fields(
|
|
320
|
+
self, parse_type: bool = True, prefer_type: bool = False, multiple: bool = False
|
|
321
|
+
) -> list[tuple[str, str, list[str]]]:
|
|
316
322
|
self._consume_empty()
|
|
317
323
|
fields: list[tuple[str, str, list[str]]] = []
|
|
318
324
|
while not self._is_section_break():
|
|
319
325
|
_name, _type, _desc = self._consume_field(parse_type, prefer_type)
|
|
320
326
|
if multiple and _name:
|
|
321
|
-
fields.extend((name.strip(), _type, _desc) for name in _name.split(
|
|
327
|
+
fields.extend((name.strip(), _type, _desc) for name in _name.split(','))
|
|
322
328
|
elif _name or _type or _desc:
|
|
323
329
|
fields.append((_name, _type, _desc))
|
|
324
330
|
return fields
|
|
@@ -333,8 +339,9 @@ class GoogleDocstring:
|
|
|
333
339
|
_descs = self.__class__(_descs, self._config).lines()
|
|
334
340
|
return _type, _descs
|
|
335
341
|
|
|
336
|
-
def _consume_returns_section(
|
|
337
|
-
|
|
342
|
+
def _consume_returns_section(
|
|
343
|
+
self, preprocess_types: bool = False
|
|
344
|
+
) -> list[tuple[str, str, list[str]]]:
|
|
338
345
|
lines = self._dedent(self._consume_to_next_section())
|
|
339
346
|
if lines:
|
|
340
347
|
before, colon, after = self._partition_field_on_colon(lines[0])
|
|
@@ -348,9 +355,10 @@ class GoogleDocstring:
|
|
|
348
355
|
|
|
349
356
|
_type = before
|
|
350
357
|
|
|
351
|
-
if
|
|
352
|
-
|
|
353
|
-
|
|
358
|
+
if _type and preprocess_types and self._config.napoleon_preprocess_types:
|
|
359
|
+
_type = _convert_type_spec(
|
|
360
|
+
_type, self._config.napoleon_type_aliases or {}
|
|
361
|
+
)
|
|
354
362
|
|
|
355
363
|
_desc = self.__class__(_desc, self._config).lines()
|
|
356
364
|
return [(_name, _type, _desc)]
|
|
@@ -389,7 +397,9 @@ class GoogleDocstring:
|
|
|
389
397
|
return [line[min_indent:] for line in lines]
|
|
390
398
|
|
|
391
399
|
def _escape_args_and_kwargs(self, name: str) -> str:
|
|
392
|
-
if name.endswith('_') and getattr(
|
|
400
|
+
if name.endswith('_') and getattr(
|
|
401
|
+
self._config, 'strip_signature_backslash', False
|
|
402
|
+
):
|
|
393
403
|
name = name[:-1] + r'\_'
|
|
394
404
|
|
|
395
405
|
if name[:2] == '**':
|
|
@@ -423,7 +433,10 @@ class GoogleDocstring:
|
|
|
423
433
|
return ['.. %s::' % admonition, '']
|
|
424
434
|
|
|
425
435
|
def _format_block(
|
|
426
|
-
self,
|
|
436
|
+
self,
|
|
437
|
+
prefix: str,
|
|
438
|
+
lines: list[str],
|
|
439
|
+
padding: str | None = None,
|
|
427
440
|
) -> list[str]:
|
|
428
441
|
if lines:
|
|
429
442
|
if padding is None:
|
|
@@ -440,9 +453,12 @@ class GoogleDocstring:
|
|
|
440
453
|
else:
|
|
441
454
|
return [prefix]
|
|
442
455
|
|
|
443
|
-
def _format_docutils_params(
|
|
444
|
-
|
|
445
|
-
|
|
456
|
+
def _format_docutils_params(
|
|
457
|
+
self,
|
|
458
|
+
fields: list[tuple[str, str, list[str]]],
|
|
459
|
+
field_role: str = 'param',
|
|
460
|
+
type_role: str = 'type',
|
|
461
|
+
) -> list[str]:
|
|
446
462
|
lines = []
|
|
447
463
|
for _name, _type, _desc in fields:
|
|
448
464
|
_desc = self._strip_empty(_desc)
|
|
@@ -486,8 +502,11 @@ class GoogleDocstring:
|
|
|
486
502
|
else:
|
|
487
503
|
return [field]
|
|
488
504
|
|
|
489
|
-
def _format_fields(
|
|
490
|
-
|
|
505
|
+
def _format_fields(
|
|
506
|
+
self,
|
|
507
|
+
field_type: str,
|
|
508
|
+
fields: list[tuple[str, str, list[str]]],
|
|
509
|
+
) -> list[str]:
|
|
491
510
|
field_type = ':%s:' % field_type.strip()
|
|
492
511
|
padding = ' ' * len(field_type)
|
|
493
512
|
multi = len(fields) > 1
|
|
@@ -579,11 +598,15 @@ class GoogleDocstring:
|
|
|
579
598
|
|
|
580
599
|
def _is_section_break(self) -> bool:
|
|
581
600
|
line = self._lines.get(0)
|
|
582
|
-
return (
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
601
|
+
return (
|
|
602
|
+
not self._lines
|
|
603
|
+
or self._is_section_header()
|
|
604
|
+
or (
|
|
605
|
+
self._is_in_section
|
|
606
|
+
and line
|
|
607
|
+
and not self._is_indented(line, self._section_indent)
|
|
608
|
+
)
|
|
609
|
+
)
|
|
587
610
|
|
|
588
611
|
def _load_custom_sections(self) -> None:
|
|
589
612
|
if self._config.napoleon_custom_sections is not None:
|
|
@@ -594,18 +617,20 @@ class GoogleDocstring:
|
|
|
594
617
|
self._sections[entry.lower()] = self._parse_custom_generic_section
|
|
595
618
|
else:
|
|
596
619
|
# otherwise, assume entry is container;
|
|
597
|
-
if entry[1] ==
|
|
598
|
-
self._sections[entry[0].lower()] =
|
|
620
|
+
if entry[1] == 'params_style':
|
|
621
|
+
self._sections[entry[0].lower()] = (
|
|
599
622
|
self._parse_custom_params_style_section
|
|
600
|
-
|
|
601
|
-
|
|
623
|
+
)
|
|
624
|
+
elif entry[1] == 'returns_style':
|
|
625
|
+
self._sections[entry[0].lower()] = (
|
|
602
626
|
self._parse_custom_returns_style_section
|
|
627
|
+
)
|
|
603
628
|
else:
|
|
604
629
|
# [0] is new section, [1] is the section to alias.
|
|
605
630
|
# in the case of key mismatch, just handle as generic section.
|
|
606
|
-
self._sections[entry[0].lower()] =
|
|
607
|
-
|
|
608
|
-
|
|
631
|
+
self._sections[entry[0].lower()] = self._sections.get(
|
|
632
|
+
entry[1].lower(), self._parse_custom_generic_section
|
|
633
|
+
)
|
|
609
634
|
|
|
610
635
|
def _parse(self) -> None:
|
|
611
636
|
self._parsed_lines = self._consume_empty()
|
|
@@ -721,9 +746,8 @@ class GoogleDocstring:
|
|
|
721
746
|
fields = self._consume_fields()
|
|
722
747
|
if self._config.napoleon_use_keyword:
|
|
723
748
|
return self._format_docutils_params(
|
|
724
|
-
fields,
|
|
725
|
-
|
|
726
|
-
type_role="kwtype")
|
|
749
|
+
fields, field_role='keyword', type_role='kwtype'
|
|
750
|
+
)
|
|
727
751
|
else:
|
|
728
752
|
return self._format_fields(_('Keyword Arguments'), fields)
|
|
729
753
|
|
|
@@ -770,7 +794,7 @@ class GoogleDocstring:
|
|
|
770
794
|
_type = m.group('name')
|
|
771
795
|
elif _xref_regex.match(_type):
|
|
772
796
|
pos = _type.find('`')
|
|
773
|
-
_type = _type[pos + 1
|
|
797
|
+
_type = _type[pos + 1 : -1]
|
|
774
798
|
_type = ' ' + _type if _type else ''
|
|
775
799
|
_desc = self._strip_empty(_desc)
|
|
776
800
|
_descs = ' ' + '\n '.join(_desc) if any(_desc) else ''
|
|
@@ -840,15 +864,13 @@ class GoogleDocstring:
|
|
|
840
864
|
m = _single_colon_regex.search(source)
|
|
841
865
|
if (i % 2) == 0 and m:
|
|
842
866
|
found_colon = True
|
|
843
|
-
colon = source[m.start(): m.end()]
|
|
844
|
-
before_colon.append(source[:m.start()])
|
|
845
|
-
after_colon.append(source[m.end():])
|
|
867
|
+
colon = source[m.start() : m.end()]
|
|
868
|
+
before_colon.append(source[: m.start()])
|
|
869
|
+
after_colon.append(source[m.end() :])
|
|
846
870
|
else:
|
|
847
871
|
before_colon.append(source)
|
|
848
872
|
|
|
849
|
-
return
|
|
850
|
-
colon,
|
|
851
|
-
"".join(after_colon).strip())
|
|
873
|
+
return ''.join(before_colon).strip(), colon, ''.join(after_colon).strip()
|
|
852
874
|
|
|
853
875
|
def _strip_empty(self, lines: list[str]) -> list[str]:
|
|
854
876
|
if lines:
|
|
@@ -866,29 +888,35 @@ class GoogleDocstring:
|
|
|
866
888
|
end = i
|
|
867
889
|
break
|
|
868
890
|
if start > 0 or end + 1 < len(lines):
|
|
869
|
-
lines = lines[start:end + 1]
|
|
891
|
+
lines = lines[start : end + 1]
|
|
870
892
|
return lines
|
|
871
893
|
|
|
872
894
|
def _lookup_annotation(self, _name: str) -> str:
|
|
873
895
|
if self._config.napoleon_attr_annotations:
|
|
874
|
-
if self._what in (
|
|
896
|
+
if self._what in ('module', 'class', 'exception') and self._obj:
|
|
875
897
|
# cache the class annotations
|
|
876
|
-
if not hasattr(self,
|
|
877
|
-
localns = getattr(self._config,
|
|
878
|
-
localns.update(
|
|
879
|
-
|
|
880
|
-
|
|
898
|
+
if not hasattr(self, '_annotations'):
|
|
899
|
+
localns = getattr(self._config, 'autodoc_type_aliases', {})
|
|
900
|
+
localns.update(
|
|
901
|
+
getattr(
|
|
902
|
+
self._config,
|
|
903
|
+
'napoleon_type_aliases',
|
|
904
|
+
{},
|
|
905
|
+
)
|
|
906
|
+
or {}
|
|
907
|
+
)
|
|
881
908
|
self._annotations = get_type_hints(self._obj, None, localns)
|
|
882
909
|
if _name in self._annotations:
|
|
883
|
-
return stringify_annotation(
|
|
884
|
-
|
|
910
|
+
return stringify_annotation(
|
|
911
|
+
self._annotations[_name], 'fully-qualified-except-typing'
|
|
912
|
+
)
|
|
885
913
|
# No annotation found
|
|
886
|
-
return
|
|
914
|
+
return ''
|
|
887
915
|
|
|
888
916
|
|
|
889
917
|
def _recombine_set_tokens(tokens: list[str]) -> list[str]:
|
|
890
918
|
token_queue = collections.deque(tokens)
|
|
891
|
-
keywords = (
|
|
919
|
+
keywords = ('optional', 'default')
|
|
892
920
|
|
|
893
921
|
def takewhile_set(tokens: collections.deque[str]) -> Iterator[str]:
|
|
894
922
|
open_braces = 0
|
|
@@ -899,7 +927,7 @@ def _recombine_set_tokens(tokens: list[str]) -> list[str]:
|
|
|
899
927
|
except IndexError:
|
|
900
928
|
break
|
|
901
929
|
|
|
902
|
-
if token ==
|
|
930
|
+
if token == ', ':
|
|
903
931
|
previous_token = token
|
|
904
932
|
continue
|
|
905
933
|
|
|
@@ -916,9 +944,9 @@ def _recombine_set_tokens(tokens: list[str]) -> list[str]:
|
|
|
916
944
|
yield previous_token
|
|
917
945
|
previous_token = None
|
|
918
946
|
|
|
919
|
-
if token ==
|
|
947
|
+
if token == '{':
|
|
920
948
|
open_braces += 1
|
|
921
|
-
elif token ==
|
|
949
|
+
elif token == '}':
|
|
922
950
|
open_braces -= 1
|
|
923
951
|
|
|
924
952
|
yield token
|
|
@@ -933,9 +961,9 @@ def _recombine_set_tokens(tokens: list[str]) -> list[str]:
|
|
|
933
961
|
except IndexError:
|
|
934
962
|
break
|
|
935
963
|
|
|
936
|
-
if token ==
|
|
937
|
-
tokens.appendleft(
|
|
938
|
-
yield
|
|
964
|
+
if token == '{':
|
|
965
|
+
tokens.appendleft('{')
|
|
966
|
+
yield ''.join(takewhile_set(tokens))
|
|
939
967
|
else:
|
|
940
968
|
yield token
|
|
941
969
|
|
|
@@ -950,7 +978,7 @@ def _tokenize_type_spec(spec: str) -> list[str]:
|
|
|
950
978
|
# for now
|
|
951
979
|
other = item[8:]
|
|
952
980
|
|
|
953
|
-
return [default,
|
|
981
|
+
return [default, ' ', other]
|
|
954
982
|
else:
|
|
955
983
|
return [item]
|
|
956
984
|
|
|
@@ -973,70 +1001,74 @@ def _token_type(token: str, location: str | None = None) -> str:
|
|
|
973
1001
|
else:
|
|
974
1002
|
return True
|
|
975
1003
|
|
|
976
|
-
if token.startswith(
|
|
977
|
-
type_ =
|
|
1004
|
+
if token.startswith(' ') or token.endswith(' '):
|
|
1005
|
+
type_ = 'delimiter'
|
|
978
1006
|
elif (
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
1007
|
+
is_numeric(token)
|
|
1008
|
+
or (token.startswith('{') and token.endswith('}'))
|
|
1009
|
+
or (token.startswith('"') and token.endswith('"'))
|
|
1010
|
+
or (token.startswith("'") and token.endswith("'"))
|
|
983
1011
|
):
|
|
984
|
-
type_ =
|
|
985
|
-
elif token.startswith(
|
|
1012
|
+
type_ = 'literal'
|
|
1013
|
+
elif token.startswith('{'):
|
|
986
1014
|
logger.warning(
|
|
987
|
-
__(
|
|
1015
|
+
__('invalid value set (missing closing brace): %s'),
|
|
988
1016
|
token,
|
|
989
1017
|
location=location,
|
|
990
1018
|
)
|
|
991
|
-
type_ =
|
|
992
|
-
elif token.endswith(
|
|
1019
|
+
type_ = 'literal'
|
|
1020
|
+
elif token.endswith('}'):
|
|
993
1021
|
logger.warning(
|
|
994
|
-
__(
|
|
1022
|
+
__('invalid value set (missing opening brace): %s'),
|
|
995
1023
|
token,
|
|
996
1024
|
location=location,
|
|
997
1025
|
)
|
|
998
|
-
type_ =
|
|
1026
|
+
type_ = 'literal'
|
|
999
1027
|
elif token.startswith(("'", '"')):
|
|
1000
1028
|
logger.warning(
|
|
1001
|
-
__(
|
|
1029
|
+
__('malformed string literal (missing closing quote): %s'),
|
|
1002
1030
|
token,
|
|
1003
1031
|
location=location,
|
|
1004
1032
|
)
|
|
1005
|
-
type_ =
|
|
1033
|
+
type_ = 'literal'
|
|
1006
1034
|
elif token.endswith(("'", '"')):
|
|
1007
1035
|
logger.warning(
|
|
1008
|
-
__(
|
|
1036
|
+
__('malformed string literal (missing opening quote): %s'),
|
|
1009
1037
|
token,
|
|
1010
1038
|
location=location,
|
|
1011
1039
|
)
|
|
1012
|
-
type_ =
|
|
1013
|
-
elif token in (
|
|
1040
|
+
type_ = 'literal'
|
|
1041
|
+
elif token in ('optional', 'default'):
|
|
1014
1042
|
# default is not a official keyword (yet) but supported by the
|
|
1015
1043
|
# reference implementation (numpydoc) and widely used
|
|
1016
|
-
type_ =
|
|
1044
|
+
type_ = 'control'
|
|
1017
1045
|
elif _xref_regex.match(token):
|
|
1018
|
-
type_ =
|
|
1046
|
+
type_ = 'reference'
|
|
1019
1047
|
else:
|
|
1020
|
-
type_ =
|
|
1048
|
+
type_ = 'obj'
|
|
1021
1049
|
|
|
1022
1050
|
return type_
|
|
1023
1051
|
|
|
1024
1052
|
|
|
1025
1053
|
def _convert_numpy_type_spec(
|
|
1026
|
-
_type: str,
|
|
1054
|
+
_type: str,
|
|
1055
|
+
location: str | None = None,
|
|
1056
|
+
translations: dict[str, str] | None = None,
|
|
1027
1057
|
) -> str:
|
|
1028
1058
|
if translations is None:
|
|
1029
1059
|
translations = {}
|
|
1030
1060
|
|
|
1031
|
-
def convert_obj(
|
|
1061
|
+
def convert_obj(
|
|
1062
|
+
obj: str, translations: dict[str, str], default_translation: str
|
|
1063
|
+
) -> str:
|
|
1032
1064
|
translation = translations.get(obj, obj)
|
|
1033
1065
|
|
|
1034
1066
|
# use :class: (the default) only if obj is not a standard singleton
|
|
1035
|
-
if translation in _SINGLETONS and default_translation ==
|
|
1036
|
-
default_translation =
|
|
1037
|
-
elif translation ==
|
|
1067
|
+
if translation in _SINGLETONS and default_translation == ':class:`%s`':
|
|
1068
|
+
default_translation = ':obj:`%s`'
|
|
1069
|
+
elif translation == '...' and default_translation == ':class:`%s`':
|
|
1038
1070
|
# allow referencing the builtin ...
|
|
1039
|
-
default_translation =
|
|
1071
|
+
default_translation = ':obj:`%s <Ellipsis>`'
|
|
1040
1072
|
|
|
1041
1073
|
if _xref_regex.match(translation) is None:
|
|
1042
1074
|
translation = default_translation % translation
|
|
@@ -1045,21 +1077,20 @@ def _convert_numpy_type_spec(
|
|
|
1045
1077
|
|
|
1046
1078
|
tokens = _tokenize_type_spec(_type)
|
|
1047
1079
|
combined_tokens = _recombine_set_tokens(tokens)
|
|
1048
|
-
types = [
|
|
1049
|
-
(token, _token_type(token, location))
|
|
1050
|
-
for token in combined_tokens
|
|
1051
|
-
]
|
|
1080
|
+
types = [(token, _token_type(token, location)) for token in combined_tokens]
|
|
1052
1081
|
|
|
1053
1082
|
converters = {
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1083
|
+
'literal': lambda x: '``%s``' % x,
|
|
1084
|
+
'obj': lambda x: convert_obj(x, translations, ':class:`%s`'),
|
|
1085
|
+
'control': lambda x: '*%s*' % x,
|
|
1086
|
+
'delimiter': lambda x: x,
|
|
1087
|
+
'reference': lambda x: x,
|
|
1059
1088
|
}
|
|
1060
1089
|
|
|
1061
|
-
converted =
|
|
1062
|
-
|
|
1090
|
+
converted = ''.join(
|
|
1091
|
+
converters.get(type_)(token) # type: ignore[misc]
|
|
1092
|
+
for token, type_ in types
|
|
1093
|
+
)
|
|
1063
1094
|
|
|
1064
1095
|
return converted
|
|
1065
1096
|
|
|
@@ -1181,20 +1212,21 @@ class NumpyDocstring(GoogleDocstring):
|
|
|
1181
1212
|
if filepath is None and name is None:
|
|
1182
1213
|
return None
|
|
1183
1214
|
elif filepath is None:
|
|
1184
|
-
filepath =
|
|
1215
|
+
filepath = ''
|
|
1185
1216
|
|
|
1186
|
-
return f
|
|
1217
|
+
return f'{filepath}:docstring of {name}'
|
|
1187
1218
|
|
|
1188
1219
|
def _escape_args_and_kwargs(self, name: str) -> str:
|
|
1189
1220
|
func = super()._escape_args_and_kwargs
|
|
1190
1221
|
|
|
1191
|
-
if
|
|
1192
|
-
return
|
|
1222
|
+
if ', ' in name:
|
|
1223
|
+
return ', '.join(map(func, name.split(', ')))
|
|
1193
1224
|
else:
|
|
1194
1225
|
return func(name)
|
|
1195
1226
|
|
|
1196
|
-
def _consume_field(
|
|
1197
|
-
|
|
1227
|
+
def _consume_field(
|
|
1228
|
+
self, parse_type: bool = True, prefer_type: bool = False
|
|
1229
|
+
) -> tuple[str, str, list[str]]:
|
|
1198
1230
|
line = self._lines.next()
|
|
1199
1231
|
if parse_type:
|
|
1200
1232
|
_name, _, _type = self._partition_field_on_colon(line)
|
|
@@ -1221,8 +1253,9 @@ class NumpyDocstring(GoogleDocstring):
|
|
|
1221
1253
|
_desc = self.__class__(_desc, self._config).lines()
|
|
1222
1254
|
return _name, _type, _desc
|
|
1223
1255
|
|
|
1224
|
-
def _consume_returns_section(
|
|
1225
|
-
|
|
1256
|
+
def _consume_returns_section(
|
|
1257
|
+
self, preprocess_types: bool = False
|
|
1258
|
+
) -> list[tuple[str, str, list[str]]]:
|
|
1226
1259
|
return self._consume_fields(prefer_type=True)
|
|
1227
1260
|
|
|
1228
1261
|
def _consume_section_header(self) -> str:
|
|
@@ -1234,12 +1267,16 @@ class NumpyDocstring(GoogleDocstring):
|
|
|
1234
1267
|
|
|
1235
1268
|
def _is_section_break(self) -> bool:
|
|
1236
1269
|
line1, line2 = self._lines.get(0), self._lines.get(1)
|
|
1237
|
-
return (
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1270
|
+
return (
|
|
1271
|
+
not self._lines
|
|
1272
|
+
or self._is_section_header()
|
|
1273
|
+
or (line1 == line2 == '')
|
|
1274
|
+
or (
|
|
1275
|
+
self._is_in_section
|
|
1276
|
+
and line1
|
|
1277
|
+
and not self._is_indented(line1, self._section_indent)
|
|
1278
|
+
)
|
|
1279
|
+
)
|
|
1243
1280
|
|
|
1244
1281
|
def _is_section_header(self) -> bool:
|
|
1245
1282
|
section, underline = self._lines.get(0), self._lines.get(1)
|
|
@@ -1262,8 +1299,6 @@ class NumpyDocstring(GoogleDocstring):
|
|
|
1262
1299
|
|
|
1263
1300
|
def _parse_numpydoc_see_also_section(self, content: list[str]) -> list[str]:
|
|
1264
1301
|
"""
|
|
1265
|
-
Derived from the NumpyDoc implementation of _parse_see_also.
|
|
1266
|
-
|
|
1267
1302
|
See Also
|
|
1268
1303
|
--------
|
|
1269
1304
|
func_name : Descriptive text
|
|
@@ -1271,6 +1306,37 @@ class NumpyDocstring(GoogleDocstring):
|
|
|
1271
1306
|
another_func_name : Descriptive text
|
|
1272
1307
|
func_name1, func_name2, :meth:`func_name`, func_name3
|
|
1273
1308
|
|
|
1309
|
+
Licence
|
|
1310
|
+
-------
|
|
1311
|
+
|
|
1312
|
+
Derived from the NumpyDoc implementation of ``_parse_see_also``,
|
|
1313
|
+
which was under the following licence:
|
|
1314
|
+
|
|
1315
|
+
Copyright (C) 2008 Stefan van der Walt <stefan@mentat.za.net>,
|
|
1316
|
+
Pauli Virtanen <pav@iki.fi>
|
|
1317
|
+
|
|
1318
|
+
Redistribution and use in source and binary forms, with or without
|
|
1319
|
+
modification, are permitted provided that the following conditions are
|
|
1320
|
+
met:
|
|
1321
|
+
|
|
1322
|
+
1. Redistributions of source code must retain the above copyright
|
|
1323
|
+
notice, this list of conditions and the following disclaimer.
|
|
1324
|
+
2. Redistributions in binary form must reproduce the above copyright
|
|
1325
|
+
notice, this list of conditions and the following disclaimer in
|
|
1326
|
+
the documentation and/or other materials provided with the
|
|
1327
|
+
distribution.
|
|
1328
|
+
|
|
1329
|
+
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
|
|
1330
|
+
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
1331
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
1332
|
+
DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
|
|
1333
|
+
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
1334
|
+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
1335
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
1336
|
+
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
1337
|
+
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
|
1338
|
+
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
1339
|
+
POSSIBILITY OF SUCH DAMAGE.
|
|
1274
1340
|
"""
|
|
1275
1341
|
items: list[tuple[str, list[str], str | None]] = []
|
|
1276
1342
|
|
|
@@ -1283,7 +1349,7 @@ class NumpyDocstring(GoogleDocstring):
|
|
|
1283
1349
|
return g[3], None
|
|
1284
1350
|
else:
|
|
1285
1351
|
return g[2], g[1]
|
|
1286
|
-
raise ValueError(
|
|
1352
|
+
raise ValueError('%s is not a item name' % text)
|
|
1287
1353
|
|
|
1288
1354
|
def push_item(name: str | None, rest: list[str]) -> None:
|
|
1289
1355
|
if not name:
|
|
@@ -1293,7 +1359,9 @@ class NumpyDocstring(GoogleDocstring):
|
|
|
1293
1359
|
rest.clear()
|
|
1294
1360
|
|
|
1295
1361
|
def translate(
|
|
1296
|
-
func: str,
|
|
1362
|
+
func: str,
|
|
1363
|
+
description: list[str],
|
|
1364
|
+
role: str | None,
|
|
1297
1365
|
) -> tuple[str, list[str], str | None]:
|
|
1298
1366
|
translations = self._config.napoleon_type_aliases
|
|
1299
1367
|
if role is not None or not translations:
|
|
@@ -1305,8 +1373,8 @@ class NumpyDocstring(GoogleDocstring):
|
|
|
1305
1373
|
return translated, description, role
|
|
1306
1374
|
|
|
1307
1375
|
groups = match.groupdict()
|
|
1308
|
-
role = groups[
|
|
1309
|
-
new_func = groups[
|
|
1376
|
+
role = groups['role']
|
|
1377
|
+
new_func = groups['name'] or groups['name2']
|
|
1310
1378
|
|
|
1311
1379
|
return new_func, description, role
|
|
1312
1380
|
|
|
@@ -1318,9 +1386,9 @@ class NumpyDocstring(GoogleDocstring):
|
|
|
1318
1386
|
continue
|
|
1319
1387
|
|
|
1320
1388
|
m = self._name_rgx.match(line)
|
|
1321
|
-
if m and line[m.end():].strip().startswith(':'):
|
|
1389
|
+
if m and line[m.end() :].strip().startswith(':'):
|
|
1322
1390
|
push_item(current_func, rest)
|
|
1323
|
-
current_func, line = line[:m.end()], line[m.end():]
|
|
1391
|
+
current_func, line = line[: m.end()], line[m.end() :]
|
|
1324
1392
|
rest = [line.split(':', 1)[1].strip()]
|
|
1325
1393
|
if not rest[0]:
|
|
1326
1394
|
rest = []
|
|
@@ -1354,7 +1422,7 @@ class NumpyDocstring(GoogleDocstring):
|
|
|
1354
1422
|
lines += ['']
|
|
1355
1423
|
lines += [link]
|
|
1356
1424
|
else:
|
|
1357
|
-
lines[-1] +=
|
|
1425
|
+
lines[-1] += ', %s' % link
|
|
1358
1426
|
if desc:
|
|
1359
1427
|
lines += self._indent([' '.join(desc)])
|
|
1360
1428
|
last_had_desc = True
|