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.
- sphinx/__init__.py +8 -9
- sphinx/addnodes.py +31 -28
- sphinx/application.py +9 -15
- sphinx/builders/__init__.py +5 -6
- sphinx/builders/_epub_base.py +17 -9
- sphinx/builders/changes.py +10 -5
- sphinx/builders/dirhtml.py +4 -2
- sphinx/builders/dummy.py +3 -2
- sphinx/builders/epub3.py +5 -3
- sphinx/builders/gettext.py +24 -7
- sphinx/builders/html/__init__.py +88 -96
- sphinx/builders/html/_assets.py +16 -16
- sphinx/builders/html/transforms.py +4 -2
- sphinx/builders/latex/__init__.py +40 -33
- sphinx/builders/latex/nodes.py +6 -2
- sphinx/builders/latex/transforms.py +17 -8
- sphinx/builders/latex/util.py +1 -1
- sphinx/builders/linkcheck.py +86 -27
- sphinx/builders/manpage.py +8 -6
- sphinx/builders/singlehtml.py +5 -4
- sphinx/builders/texinfo.py +18 -14
- sphinx/builders/text.py +3 -2
- sphinx/builders/xml.py +5 -2
- sphinx/cmd/build.py +119 -76
- sphinx/cmd/make_mode.py +21 -20
- sphinx/cmd/quickstart.py +13 -16
- sphinx/config.py +432 -250
- sphinx/deprecation.py +23 -13
- sphinx/directives/__init__.py +8 -8
- sphinx/directives/code.py +7 -7
- sphinx/directives/other.py +23 -13
- sphinx/directives/patches.py +7 -6
- sphinx/domains/__init__.py +2 -2
- sphinx/domains/c/__init__.py +796 -0
- sphinx/domains/c/_ast.py +1421 -0
- sphinx/domains/c/_ids.py +65 -0
- sphinx/domains/c/_parser.py +1048 -0
- sphinx/domains/c/_symbol.py +700 -0
- sphinx/domains/changeset.py +11 -7
- sphinx/domains/citation.py +5 -2
- sphinx/domains/cpp/__init__.py +1089 -0
- sphinx/domains/cpp/_ast.py +3635 -0
- sphinx/domains/cpp/_ids.py +537 -0
- sphinx/domains/cpp/_parser.py +2117 -0
- sphinx/domains/cpp/_symbol.py +1092 -0
- sphinx/domains/index.py +6 -4
- sphinx/domains/javascript.py +16 -13
- sphinx/domains/math.py +9 -4
- sphinx/domains/python/__init__.py +890 -0
- sphinx/domains/python/_annotations.py +507 -0
- sphinx/domains/python/_object.py +426 -0
- sphinx/domains/rst.py +12 -7
- sphinx/domains/{std.py → std/__init__.py} +19 -16
- sphinx/environment/__init__.py +21 -19
- sphinx/environment/adapters/indexentries.py +2 -2
- sphinx/environment/adapters/toctree.py +10 -9
- sphinx/environment/collectors/__init__.py +6 -3
- sphinx/environment/collectors/asset.py +4 -3
- sphinx/environment/collectors/dependencies.py +3 -2
- sphinx/environment/collectors/metadata.py +6 -5
- sphinx/environment/collectors/title.py +3 -2
- sphinx/environment/collectors/toctree.py +5 -4
- sphinx/errors.py +13 -2
- sphinx/events.py +14 -9
- sphinx/ext/apidoc.py +9 -11
- sphinx/ext/autodoc/__init__.py +105 -71
- sphinx/ext/autodoc/directive.py +7 -6
- sphinx/ext/autodoc/importer.py +132 -52
- sphinx/ext/autodoc/mock.py +7 -5
- sphinx/ext/autodoc/preserve_defaults.py +4 -3
- sphinx/ext/autodoc/type_comment.py +2 -1
- sphinx/ext/autodoc/typehints.py +5 -4
- sphinx/ext/autosectionlabel.py +3 -2
- sphinx/ext/autosummary/__init__.py +21 -17
- sphinx/ext/autosummary/generate.py +9 -9
- sphinx/ext/coverage.py +26 -20
- sphinx/ext/doctest.py +38 -33
- sphinx/ext/duration.py +1 -0
- sphinx/ext/extlinks.py +4 -3
- sphinx/ext/githubpages.py +3 -2
- sphinx/ext/graphviz.py +10 -7
- sphinx/ext/ifconfig.py +5 -5
- sphinx/ext/imgconverter.py +6 -5
- sphinx/ext/imgmath.py +9 -8
- sphinx/ext/inheritance_diagram.py +31 -31
- sphinx/ext/intersphinx.py +140 -23
- sphinx/ext/linkcode.py +3 -2
- sphinx/ext/mathjax.py +2 -1
- sphinx/ext/napoleon/__init__.py +12 -7
- sphinx/ext/napoleon/docstring.py +34 -32
- sphinx/ext/todo.py +10 -7
- sphinx/ext/viewcode.py +12 -11
- sphinx/extension.py +18 -8
- sphinx/highlighting.py +39 -20
- sphinx/io.py +17 -8
- sphinx/jinja2glue.py +16 -15
- sphinx/locale/__init__.py +30 -23
- sphinx/locale/ar/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/ar/LC_MESSAGES/sphinx.po +818 -761
- sphinx/locale/bg/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/bg/LC_MESSAGES/sphinx.po +811 -754
- sphinx/locale/bn/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/bn/LC_MESSAGES/sphinx.po +835 -778
- sphinx/locale/ca/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/ca/LC_MESSAGES/sphinx.po +864 -807
- sphinx/locale/cak/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/cak/LC_MESSAGES/sphinx.po +816 -759
- sphinx/locale/cs/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/cs/LC_MESSAGES/sphinx.po +837 -780
- sphinx/locale/cy/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/cy/LC_MESSAGES/sphinx.po +819 -762
- sphinx/locale/da/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/da/LC_MESSAGES/sphinx.po +838 -781
- sphinx/locale/de/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/de/LC_MESSAGES/sphinx.po +838 -781
- sphinx/locale/de_DE/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/de_DE/LC_MESSAGES/sphinx.po +811 -754
- sphinx/locale/el/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/el/LC_MESSAGES/sphinx.po +853 -796
- sphinx/locale/en_DE/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/en_DE/LC_MESSAGES/sphinx.po +811 -754
- sphinx/locale/en_FR/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/en_FR/LC_MESSAGES/sphinx.po +811 -754
- sphinx/locale/en_GB/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/en_GB/LC_MESSAGES/sphinx.po +856 -799
- sphinx/locale/en_HK/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/en_HK/LC_MESSAGES/sphinx.po +811 -754
- sphinx/locale/eo/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/eo/LC_MESSAGES/sphinx.po +820 -763
- sphinx/locale/es/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/es/LC_MESSAGES/sphinx.po +856 -799
- sphinx/locale/es_CO/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/es_CO/LC_MESSAGES/sphinx.po +811 -754
- sphinx/locale/et/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/et/LC_MESSAGES/sphinx.po +845 -788
- sphinx/locale/eu/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/eu/LC_MESSAGES/sphinx.po +837 -780
- sphinx/locale/fa/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/fa/LC_MESSAGES/sphinx.po +854 -797
- sphinx/locale/fi/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/fi/LC_MESSAGES/sphinx.po +816 -759
- sphinx/locale/fr/LC_MESSAGES/sphinx.js +1 -1
- sphinx/locale/fr/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/fr/LC_MESSAGES/sphinx.po +904 -847
- sphinx/locale/fr_FR/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/fr_FR/LC_MESSAGES/sphinx.po +811 -754
- sphinx/locale/gl/LC_MESSAGES/sphinx.js +54 -54
- sphinx/locale/gl/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/gl/LC_MESSAGES/sphinx.po +1506 -1449
- sphinx/locale/he/LC_MESSAGES/sphinx.js +1 -1
- sphinx/locale/he/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/he/LC_MESSAGES/sphinx.po +823 -766
- sphinx/locale/hi/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/hi/LC_MESSAGES/sphinx.po +853 -796
- sphinx/locale/hi_IN/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/hi_IN/LC_MESSAGES/sphinx.po +811 -754
- sphinx/locale/hr/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/hr/LC_MESSAGES/sphinx.po +844 -787
- sphinx/locale/hu/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/hu/LC_MESSAGES/sphinx.po +837 -780
- sphinx/locale/id/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/id/LC_MESSAGES/sphinx.po +854 -797
- sphinx/locale/is/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/is/LC_MESSAGES/sphinx.po +811 -754
- sphinx/locale/it/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/it/LC_MESSAGES/sphinx.po +837 -780
- sphinx/locale/ja/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/ja/LC_MESSAGES/sphinx.po +853 -796
- sphinx/locale/ka/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/ka/LC_MESSAGES/sphinx.po +848 -791
- sphinx/locale/ko/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/ko/LC_MESSAGES/sphinx.po +855 -798
- sphinx/locale/lt/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/lt/LC_MESSAGES/sphinx.po +837 -780
- sphinx/locale/lv/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/lv/LC_MESSAGES/sphinx.po +837 -780
- sphinx/locale/mk/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/mk/LC_MESSAGES/sphinx.po +825 -768
- sphinx/locale/nb_NO/LC_MESSAGES/sphinx.js +27 -27
- sphinx/locale/nb_NO/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/nb_NO/LC_MESSAGES/sphinx.po +876 -818
- sphinx/locale/ne/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/ne/LC_MESSAGES/sphinx.po +837 -780
- sphinx/locale/nl/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/nl/LC_MESSAGES/sphinx.po +844 -787
- sphinx/locale/pl/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/pl/LC_MESSAGES/sphinx.po +845 -788
- sphinx/locale/pt/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/pt/LC_MESSAGES/sphinx.po +811 -754
- sphinx/locale/pt_BR/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/pt_BR/LC_MESSAGES/sphinx.po +908 -851
- sphinx/locale/pt_PT/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/pt_PT/LC_MESSAGES/sphinx.po +837 -780
- sphinx/locale/ro/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/ro/LC_MESSAGES/sphinx.po +837 -780
- sphinx/locale/ru/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/ru/LC_MESSAGES/sphinx.po +838 -781
- sphinx/locale/si/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/si/LC_MESSAGES/sphinx.po +823 -766
- sphinx/locale/sk/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/sk/LC_MESSAGES/sphinx.po +854 -797
- sphinx/locale/sl/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/sl/LC_MESSAGES/sphinx.po +832 -775
- sphinx/locale/sphinx.pot +813 -755
- sphinx/locale/sq/LC_MESSAGES/sphinx.js +1 -1
- sphinx/locale/sq/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/sq/LC_MESSAGES/sphinx.po +865 -808
- sphinx/locale/sr/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/sr/LC_MESSAGES/sphinx.po +835 -778
- 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.mo +0 -0
- sphinx/locale/sv/LC_MESSAGES/sphinx.po +837 -780
- sphinx/locale/ta/LC_MESSAGES/sphinx.js +54 -54
- sphinx/locale/ta/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/ta/LC_MESSAGES/sphinx.po +1530 -1473
- sphinx/locale/te/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/te/LC_MESSAGES/sphinx.po +811 -754
- sphinx/locale/tr/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/tr/LC_MESSAGES/sphinx.po +853 -796
- sphinx/locale/uk_UA/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/uk_UA/LC_MESSAGES/sphinx.po +833 -776
- sphinx/locale/ur/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/ur/LC_MESSAGES/sphinx.po +811 -754
- sphinx/locale/vi/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/vi/LC_MESSAGES/sphinx.po +837 -780
- sphinx/locale/yue/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/yue/LC_MESSAGES/sphinx.po +811 -754
- sphinx/locale/zh_CN/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/zh_CN/LC_MESSAGES/sphinx.po +855 -798
- sphinx/locale/zh_HK/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/zh_HK/LC_MESSAGES/sphinx.po +811 -754
- sphinx/locale/zh_TW/LC_MESSAGES/sphinx.js +1 -1
- sphinx/locale/zh_TW/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/zh_TW/LC_MESSAGES/sphinx.po +879 -822
- sphinx/locale/zh_TW.Big5/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/zh_TW.Big5/LC_MESSAGES/sphinx.po +811 -754
- sphinx/parsers.py +7 -5
- sphinx/project.py +18 -11
- sphinx/pycode/__init__.py +6 -5
- sphinx/pycode/ast.py +23 -8
- sphinx/pycode/parser.py +6 -5
- sphinx/registry.py +12 -6
- sphinx/roles.py +103 -57
- sphinx/search/__init__.py +17 -18
- sphinx/search/da.py +2 -2
- sphinx/search/de.py +2 -2
- sphinx/search/en.py +1 -1
- sphinx/search/es.py +2 -2
- sphinx/search/fi.py +2 -2
- sphinx/search/fr.py +2 -2
- sphinx/search/hu.py +2 -2
- sphinx/search/it.py +2 -2
- sphinx/search/ja.py +13 -22
- sphinx/search/nl.py +2 -2
- sphinx/search/no.py +2 -2
- sphinx/search/pt.py +2 -2
- sphinx/search/ro.py +1 -1
- sphinx/search/ru.py +2 -2
- sphinx/search/sv.py +2 -2
- sphinx/search/tr.py +1 -1
- sphinx/search/zh.py +2 -3
- sphinx/templates/graphviz/graphviz.css +1 -1
- sphinx/testing/fixtures.py +41 -24
- sphinx/testing/path.py +1 -1
- sphinx/testing/util.py +142 -53
- sphinx/texinputs/sphinx.xdy +1 -1
- sphinx/texinputs/sphinxlatextables.sty +1 -1
- sphinx/texinputs/sphinxpackagesubstitutefont.sty +21 -0
- sphinx/themes/agogo/layout.html +4 -4
- sphinx/themes/agogo/static/agogo.css_t +1 -1
- sphinx/themes/agogo/theme.toml +22 -0
- sphinx/themes/basic/defindex.html +1 -1
- sphinx/themes/basic/domainindex.html +1 -1
- sphinx/themes/basic/genindex-single.html +1 -1
- sphinx/themes/basic/genindex-split.html +1 -1
- sphinx/themes/basic/genindex.html +1 -1
- sphinx/themes/basic/globaltoc.html +1 -1
- sphinx/themes/basic/layout.html +1 -1
- sphinx/themes/basic/localtoc.html +1 -1
- sphinx/themes/basic/page.html +1 -1
- sphinx/themes/basic/relations.html +1 -1
- sphinx/themes/basic/search.html +5 -20
- sphinx/themes/basic/searchbox.html +3 -3
- sphinx/themes/basic/searchfield.html +3 -3
- sphinx/themes/basic/sourcelink.html +1 -1
- sphinx/themes/basic/static/basic.css_t +1 -1
- sphinx/themes/basic/static/doctools.js +1 -1
- sphinx/themes/basic/static/language_data.js_t +2 -2
- sphinx/themes/basic/static/searchtools.js +105 -60
- sphinx/themes/basic/theme.toml +23 -0
- sphinx/themes/bizstyle/layout.html +1 -6
- sphinx/themes/bizstyle/static/bizstyle.css_t +1 -1
- sphinx/themes/bizstyle/static/bizstyle.js_t +1 -1
- sphinx/themes/bizstyle/static/css3-mediaqueries_src.js +3 -3
- sphinx/themes/bizstyle/theme.toml +12 -0
- sphinx/themes/classic/layout.html +1 -1
- sphinx/themes/classic/static/classic.css_t +1 -1
- sphinx/themes/classic/static/sidebar.js_t +1 -1
- sphinx/themes/classic/theme.toml +34 -0
- sphinx/themes/default/theme.toml +2 -0
- sphinx/themes/epub/epub-cover.html +1 -1
- sphinx/themes/epub/layout.html +1 -1
- sphinx/themes/epub/static/epub.css_t +1 -1
- sphinx/themes/epub/theme.toml +10 -0
- sphinx/themes/haiku/layout.html +3 -3
- sphinx/themes/haiku/static/haiku.css_t +2 -2
- sphinx/themes/haiku/theme.toml +16 -0
- sphinx/themes/nature/static/nature.css_t +1 -1
- sphinx/themes/nature/theme.toml +6 -0
- sphinx/themes/nonav/layout.html +1 -1
- sphinx/themes/nonav/static/nonav.css_t +1 -1
- sphinx/themes/nonav/theme.toml +10 -0
- sphinx/themes/pyramid/static/epub.css_t +1 -1
- sphinx/themes/pyramid/static/pyramid.css_t +1 -1
- sphinx/themes/pyramid/theme.toml +6 -0
- sphinx/themes/scrolls/artwork/logo.svg +1 -1
- sphinx/themes/scrolls/layout.html +2 -2
- sphinx/themes/scrolls/static/scrolls.css_t +1 -1
- sphinx/themes/scrolls/theme.toml +15 -0
- sphinx/themes/sphinxdoc/static/sphinxdoc.css_t +1 -1
- sphinx/themes/sphinxdoc/theme.toml +6 -0
- sphinx/themes/traditional/static/traditional.css_t +1 -1
- sphinx/themes/traditional/theme.toml +9 -0
- sphinx/theming.py +427 -131
- sphinx/transforms/__init__.py +21 -24
- sphinx/transforms/compact_bullet_list.py +5 -5
- sphinx/transforms/i18n.py +30 -28
- sphinx/transforms/post_transforms/__init__.py +9 -7
- sphinx/transforms/post_transforms/code.py +4 -1
- sphinx/transforms/post_transforms/images.py +17 -13
- sphinx/transforms/references.py +3 -1
- sphinx/util/__init__.py +15 -11
- sphinx/util/_io.py +34 -0
- sphinx/util/_pathlib.py +23 -18
- sphinx/util/build_phase.py +1 -0
- sphinx/util/cfamily.py +19 -11
- sphinx/util/console.py +101 -21
- sphinx/util/display.py +3 -2
- sphinx/util/docfields.py +12 -8
- sphinx/util/docutils.py +21 -35
- sphinx/util/exceptions.py +3 -2
- sphinx/util/fileutil.py +5 -5
- sphinx/util/http_date.py +9 -2
- sphinx/util/i18n.py +40 -9
- sphinx/util/inspect.py +317 -245
- sphinx/util/inventory.py +22 -5
- sphinx/util/logging.py +81 -7
- sphinx/util/matching.py +2 -1
- sphinx/util/math.py +1 -2
- sphinx/util/nodes.py +39 -29
- sphinx/util/osutil.py +25 -6
- sphinx/util/parallel.py +6 -1
- sphinx/util/requests.py +8 -5
- sphinx/util/rst.py +8 -6
- sphinx/util/tags.py +3 -3
- sphinx/util/template.py +8 -3
- sphinx/util/typing.py +76 -42
- sphinx/versioning.py +6 -2
- sphinx/writers/html.py +1 -1
- sphinx/writers/html5.py +17 -13
- sphinx/writers/latex.py +12 -12
- sphinx/writers/manpage.py +13 -7
- sphinx/writers/texinfo.py +13 -10
- sphinx/writers/text.py +13 -23
- sphinx/writers/xml.py +1 -1
- sphinx-7.2.5.dist-info/LICENSE → sphinx-7.3.0.dist-info/LICENSE.rst +1 -1
- {sphinx-7.2.5.dist-info → sphinx-7.3.0.dist-info}/METADATA +13 -12
- sphinx-7.3.0.dist-info/RECORD +581 -0
- sphinx/domains/c.py +0 -3906
- sphinx/domains/cpp.py +0 -8233
- sphinx/domains/python.py +0 -1769
- sphinx/themes/agogo/theme.conf +0 -20
- sphinx/themes/basic/theme.conf +0 -16
- sphinx/themes/bizstyle/theme.conf +0 -10
- sphinx/themes/classic/theme.conf +0 -32
- sphinx/themes/default/theme.conf +0 -2
- sphinx/themes/epub/theme.conf +0 -8
- sphinx/themes/haiku/theme.conf +0 -14
- sphinx/themes/nature/theme.conf +0 -4
- sphinx/themes/nonav/theme.conf +0 -8
- sphinx/themes/pyramid/theme.conf +0 -4
- sphinx/themes/scrolls/theme.conf +0 -13
- sphinx/themes/sphinxdoc/theme.conf +0 -4
- sphinx/themes/traditional/theme.conf +0 -7
- sphinx-7.2.5.dist-info/RECORD +0 -569
- {sphinx-7.2.5.dist-info → sphinx-7.3.0.dist-info}/WHEEL +0 -0
- {sphinx-7.2.5.dist-info → sphinx-7.3.0.dist-info}/entry_points.txt +0 -0
sphinx/domains/c/_ast.py
ADDED
|
@@ -0,0 +1,1421 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import TYPE_CHECKING, Any, Union, cast
|
|
4
|
+
|
|
5
|
+
from docutils import nodes
|
|
6
|
+
|
|
7
|
+
from sphinx import addnodes
|
|
8
|
+
from sphinx.domains.c._ids import _id_prefix, _max_id
|
|
9
|
+
from sphinx.util.cfamily import (
|
|
10
|
+
ASTAttributeList,
|
|
11
|
+
ASTBaseBase,
|
|
12
|
+
ASTBaseParenExprList,
|
|
13
|
+
StringifyTransform,
|
|
14
|
+
UnsupportedMultiCharacterCharLiteral,
|
|
15
|
+
verify_description_mode,
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
if TYPE_CHECKING:
|
|
19
|
+
|
|
20
|
+
from docutils.nodes import Element, Node, TextElement
|
|
21
|
+
|
|
22
|
+
from sphinx.domains.c._symbol import Symbol
|
|
23
|
+
from sphinx.environment import BuildEnvironment
|
|
24
|
+
|
|
25
|
+
DeclarationType = Union[
|
|
26
|
+
"ASTStruct", "ASTUnion", "ASTEnum", "ASTEnumerator",
|
|
27
|
+
"ASTType", "ASTTypeWithInit", "ASTMacro",
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class ASTBase(ASTBaseBase):
|
|
32
|
+
def describe_signature(self, signode: TextElement, mode: str,
|
|
33
|
+
env: BuildEnvironment, symbol: Symbol) -> None:
|
|
34
|
+
raise NotImplementedError(repr(self))
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
# Names
|
|
38
|
+
################################################################################
|
|
39
|
+
|
|
40
|
+
class ASTIdentifier(ASTBaseBase):
|
|
41
|
+
def __init__(self, identifier: str) -> None:
|
|
42
|
+
assert identifier is not None
|
|
43
|
+
assert len(identifier) != 0
|
|
44
|
+
self.identifier = identifier
|
|
45
|
+
|
|
46
|
+
# ASTBaseBase already implements this method,
|
|
47
|
+
# but specialising it here improves performance
|
|
48
|
+
def __eq__(self, other: object) -> bool:
|
|
49
|
+
if type(other) is not ASTIdentifier:
|
|
50
|
+
return NotImplemented
|
|
51
|
+
return self.identifier == other.identifier
|
|
52
|
+
|
|
53
|
+
def is_anon(self) -> bool:
|
|
54
|
+
return self.identifier[0] == '@'
|
|
55
|
+
|
|
56
|
+
# and this is where we finally make a difference between __str__ and the display string
|
|
57
|
+
|
|
58
|
+
def __str__(self) -> str:
|
|
59
|
+
return self.identifier
|
|
60
|
+
|
|
61
|
+
def get_display_string(self) -> str:
|
|
62
|
+
return "[anonymous]" if self.is_anon() else self.identifier
|
|
63
|
+
|
|
64
|
+
def describe_signature(self, signode: TextElement, mode: str, env: BuildEnvironment,
|
|
65
|
+
prefix: str, symbol: Symbol) -> None:
|
|
66
|
+
# note: slightly different signature of describe_signature due to the prefix
|
|
67
|
+
verify_description_mode(mode)
|
|
68
|
+
if self.is_anon():
|
|
69
|
+
node = addnodes.desc_sig_name(text="[anonymous]")
|
|
70
|
+
else:
|
|
71
|
+
node = addnodes.desc_sig_name(self.identifier, self.identifier)
|
|
72
|
+
if mode == 'markType':
|
|
73
|
+
targetText = prefix + self.identifier
|
|
74
|
+
pnode = addnodes.pending_xref('', refdomain='c',
|
|
75
|
+
reftype='identifier',
|
|
76
|
+
reftarget=targetText, modname=None,
|
|
77
|
+
classname=None)
|
|
78
|
+
pnode['c:parent_key'] = symbol.get_lookup_key()
|
|
79
|
+
pnode += node
|
|
80
|
+
signode += pnode
|
|
81
|
+
elif mode == 'lastIsName':
|
|
82
|
+
nameNode = addnodes.desc_name()
|
|
83
|
+
nameNode += node
|
|
84
|
+
signode += nameNode
|
|
85
|
+
elif mode == 'noneIsName':
|
|
86
|
+
signode += node
|
|
87
|
+
else:
|
|
88
|
+
raise Exception('Unknown description mode: %s' % mode)
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
class ASTNestedName(ASTBase):
|
|
92
|
+
def __init__(self, names: list[ASTIdentifier], rooted: bool) -> None:
|
|
93
|
+
assert len(names) > 0
|
|
94
|
+
self.names = names
|
|
95
|
+
self.rooted = rooted
|
|
96
|
+
|
|
97
|
+
@property
|
|
98
|
+
def name(self) -> ASTNestedName:
|
|
99
|
+
return self
|
|
100
|
+
|
|
101
|
+
def get_id(self, version: int) -> str:
|
|
102
|
+
return '.'.join(str(n) for n in self.names)
|
|
103
|
+
|
|
104
|
+
def _stringify(self, transform: StringifyTransform) -> str:
|
|
105
|
+
res = '.'.join(transform(n) for n in self.names)
|
|
106
|
+
if self.rooted:
|
|
107
|
+
return '.' + res
|
|
108
|
+
else:
|
|
109
|
+
return res
|
|
110
|
+
|
|
111
|
+
def describe_signature(self, signode: TextElement, mode: str,
|
|
112
|
+
env: BuildEnvironment, symbol: Symbol) -> None:
|
|
113
|
+
verify_description_mode(mode)
|
|
114
|
+
# just print the name part, with template args, not template params
|
|
115
|
+
if mode == 'noneIsName':
|
|
116
|
+
if self.rooted:
|
|
117
|
+
unreachable = "Can this happen?"
|
|
118
|
+
raise AssertionError(unreachable) # TODO
|
|
119
|
+
signode += nodes.Text('.')
|
|
120
|
+
for i in range(len(self.names)):
|
|
121
|
+
if i != 0:
|
|
122
|
+
unreachable = "Can this happen?"
|
|
123
|
+
raise AssertionError(unreachable) # TODO
|
|
124
|
+
signode += nodes.Text('.')
|
|
125
|
+
n = self.names[i]
|
|
126
|
+
n.describe_signature(signode, mode, env, '', symbol)
|
|
127
|
+
elif mode == 'param':
|
|
128
|
+
assert not self.rooted, str(self)
|
|
129
|
+
assert len(self.names) == 1
|
|
130
|
+
self.names[0].describe_signature(signode, 'noneIsName', env, '', symbol)
|
|
131
|
+
elif mode in ('markType', 'lastIsName', 'markName'):
|
|
132
|
+
# Each element should be a pending xref targeting the complete
|
|
133
|
+
# prefix.
|
|
134
|
+
prefix = ''
|
|
135
|
+
first = True
|
|
136
|
+
names = self.names[:-1] if mode == 'lastIsName' else self.names
|
|
137
|
+
# If lastIsName, then wrap all of the prefix in a desc_addname,
|
|
138
|
+
# else append directly to signode.
|
|
139
|
+
# TODO: also for C?
|
|
140
|
+
# NOTE: Breathe previously relied on the prefix being in the desc_addname node,
|
|
141
|
+
# so it can remove it in inner declarations.
|
|
142
|
+
dest = signode
|
|
143
|
+
if mode == 'lastIsName':
|
|
144
|
+
dest = addnodes.desc_addname()
|
|
145
|
+
if self.rooted:
|
|
146
|
+
prefix += '.'
|
|
147
|
+
if mode == 'lastIsName' and len(names) == 0:
|
|
148
|
+
signode += addnodes.desc_sig_punctuation('.', '.')
|
|
149
|
+
else:
|
|
150
|
+
dest += addnodes.desc_sig_punctuation('.', '.')
|
|
151
|
+
for i in range(len(names)):
|
|
152
|
+
ident = names[i]
|
|
153
|
+
if not first:
|
|
154
|
+
dest += addnodes.desc_sig_punctuation('.', '.')
|
|
155
|
+
prefix += '.'
|
|
156
|
+
first = False
|
|
157
|
+
txt_ident = str(ident)
|
|
158
|
+
if txt_ident != '':
|
|
159
|
+
ident.describe_signature(dest, 'markType', env, prefix, symbol)
|
|
160
|
+
prefix += txt_ident
|
|
161
|
+
if mode == 'lastIsName':
|
|
162
|
+
if len(self.names) > 1:
|
|
163
|
+
dest += addnodes.desc_sig_punctuation('.', '.')
|
|
164
|
+
signode += dest
|
|
165
|
+
self.names[-1].describe_signature(signode, mode, env, '', symbol)
|
|
166
|
+
else:
|
|
167
|
+
raise Exception('Unknown description mode: %s' % mode)
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
################################################################################
|
|
171
|
+
# Expressions
|
|
172
|
+
################################################################################
|
|
173
|
+
|
|
174
|
+
class ASTExpression(ASTBase):
|
|
175
|
+
pass
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
# Primary expressions
|
|
179
|
+
################################################################################
|
|
180
|
+
|
|
181
|
+
class ASTLiteral(ASTExpression):
|
|
182
|
+
pass
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
class ASTBooleanLiteral(ASTLiteral):
|
|
186
|
+
def __init__(self, value: bool) -> None:
|
|
187
|
+
self.value = value
|
|
188
|
+
|
|
189
|
+
def _stringify(self, transform: StringifyTransform) -> str:
|
|
190
|
+
if self.value:
|
|
191
|
+
return 'true'
|
|
192
|
+
else:
|
|
193
|
+
return 'false'
|
|
194
|
+
|
|
195
|
+
def describe_signature(self, signode: TextElement, mode: str,
|
|
196
|
+
env: BuildEnvironment, symbol: Symbol) -> None:
|
|
197
|
+
txt = str(self)
|
|
198
|
+
signode += addnodes.desc_sig_keyword(txt, txt)
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
class ASTNumberLiteral(ASTLiteral):
|
|
202
|
+
def __init__(self, data: str) -> None:
|
|
203
|
+
self.data = data
|
|
204
|
+
|
|
205
|
+
def _stringify(self, transform: StringifyTransform) -> str:
|
|
206
|
+
return self.data
|
|
207
|
+
|
|
208
|
+
def describe_signature(self, signode: TextElement, mode: str,
|
|
209
|
+
env: BuildEnvironment, symbol: Symbol) -> None:
|
|
210
|
+
txt = str(self)
|
|
211
|
+
signode += addnodes.desc_sig_literal_number(txt, txt)
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
class ASTCharLiteral(ASTLiteral):
|
|
215
|
+
def __init__(self, prefix: str, data: str) -> None:
|
|
216
|
+
self.prefix = prefix # may be None when no prefix
|
|
217
|
+
self.data = data
|
|
218
|
+
decoded = data.encode().decode('unicode-escape')
|
|
219
|
+
if len(decoded) == 1:
|
|
220
|
+
self.value = ord(decoded)
|
|
221
|
+
else:
|
|
222
|
+
raise UnsupportedMultiCharacterCharLiteral(decoded)
|
|
223
|
+
|
|
224
|
+
def _stringify(self, transform: StringifyTransform) -> str:
|
|
225
|
+
if self.prefix is None:
|
|
226
|
+
return "'" + self.data + "'"
|
|
227
|
+
else:
|
|
228
|
+
return self.prefix + "'" + self.data + "'"
|
|
229
|
+
|
|
230
|
+
def describe_signature(self, signode: TextElement, mode: str,
|
|
231
|
+
env: BuildEnvironment, symbol: Symbol) -> None:
|
|
232
|
+
txt = str(self)
|
|
233
|
+
signode += addnodes.desc_sig_literal_char(txt, txt)
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
class ASTStringLiteral(ASTLiteral):
|
|
237
|
+
def __init__(self, data: str) -> None:
|
|
238
|
+
self.data = data
|
|
239
|
+
|
|
240
|
+
def _stringify(self, transform: StringifyTransform) -> str:
|
|
241
|
+
return self.data
|
|
242
|
+
|
|
243
|
+
def describe_signature(self, signode: TextElement, mode: str,
|
|
244
|
+
env: BuildEnvironment, symbol: Symbol) -> None:
|
|
245
|
+
txt = str(self)
|
|
246
|
+
signode += addnodes.desc_sig_literal_string(txt, txt)
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
class ASTIdExpression(ASTExpression):
|
|
250
|
+
def __init__(self, name: ASTNestedName) -> None:
|
|
251
|
+
# note: this class is basically to cast a nested name as an expression
|
|
252
|
+
self.name = name
|
|
253
|
+
|
|
254
|
+
def _stringify(self, transform: StringifyTransform) -> str:
|
|
255
|
+
return transform(self.name)
|
|
256
|
+
|
|
257
|
+
def get_id(self, version: int) -> str:
|
|
258
|
+
return self.name.get_id(version)
|
|
259
|
+
|
|
260
|
+
def describe_signature(self, signode: TextElement, mode: str,
|
|
261
|
+
env: BuildEnvironment, symbol: Symbol) -> None:
|
|
262
|
+
self.name.describe_signature(signode, mode, env, symbol)
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
class ASTParenExpr(ASTExpression):
|
|
266
|
+
def __init__(self, expr: ASTExpression) -> None:
|
|
267
|
+
self.expr = expr
|
|
268
|
+
|
|
269
|
+
def _stringify(self, transform: StringifyTransform) -> str:
|
|
270
|
+
return '(' + transform(self.expr) + ')'
|
|
271
|
+
|
|
272
|
+
def get_id(self, version: int) -> str:
|
|
273
|
+
return self.expr.get_id(version) # type: ignore[attr-defined]
|
|
274
|
+
|
|
275
|
+
def describe_signature(self, signode: TextElement, mode: str,
|
|
276
|
+
env: BuildEnvironment, symbol: Symbol) -> None:
|
|
277
|
+
signode += addnodes.desc_sig_punctuation('(', '(')
|
|
278
|
+
self.expr.describe_signature(signode, mode, env, symbol)
|
|
279
|
+
signode += addnodes.desc_sig_punctuation(')', ')')
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
# Postfix expressions
|
|
283
|
+
################################################################################
|
|
284
|
+
|
|
285
|
+
class ASTPostfixOp(ASTBase):
|
|
286
|
+
pass
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
class ASTPostfixCallExpr(ASTPostfixOp):
|
|
290
|
+
def __init__(self, lst: ASTParenExprList | ASTBracedInitList) -> None:
|
|
291
|
+
self.lst = lst
|
|
292
|
+
|
|
293
|
+
def _stringify(self, transform: StringifyTransform) -> str:
|
|
294
|
+
return transform(self.lst)
|
|
295
|
+
|
|
296
|
+
def describe_signature(self, signode: TextElement, mode: str,
|
|
297
|
+
env: BuildEnvironment, symbol: Symbol) -> None:
|
|
298
|
+
self.lst.describe_signature(signode, mode, env, symbol)
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
class ASTPostfixArray(ASTPostfixOp):
|
|
302
|
+
def __init__(self, expr: ASTExpression) -> None:
|
|
303
|
+
self.expr = expr
|
|
304
|
+
|
|
305
|
+
def _stringify(self, transform: StringifyTransform) -> str:
|
|
306
|
+
return '[' + transform(self.expr) + ']'
|
|
307
|
+
|
|
308
|
+
def describe_signature(self, signode: TextElement, mode: str,
|
|
309
|
+
env: BuildEnvironment, symbol: Symbol) -> None:
|
|
310
|
+
signode += addnodes.desc_sig_punctuation('[', '[')
|
|
311
|
+
self.expr.describe_signature(signode, mode, env, symbol)
|
|
312
|
+
signode += addnodes.desc_sig_punctuation(']', ']')
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
class ASTPostfixInc(ASTPostfixOp):
|
|
316
|
+
def _stringify(self, transform: StringifyTransform) -> str:
|
|
317
|
+
return '++'
|
|
318
|
+
|
|
319
|
+
def describe_signature(self, signode: TextElement, mode: str,
|
|
320
|
+
env: BuildEnvironment, symbol: Symbol) -> None:
|
|
321
|
+
signode += addnodes.desc_sig_operator('++', '++')
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
class ASTPostfixDec(ASTPostfixOp):
|
|
325
|
+
def _stringify(self, transform: StringifyTransform) -> str:
|
|
326
|
+
return '--'
|
|
327
|
+
|
|
328
|
+
def describe_signature(self, signode: TextElement, mode: str,
|
|
329
|
+
env: BuildEnvironment, symbol: Symbol) -> None:
|
|
330
|
+
signode += addnodes.desc_sig_operator('--', '--')
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
class ASTPostfixMemberOfPointer(ASTPostfixOp):
|
|
334
|
+
def __init__(self, name: ASTNestedName) -> None:
|
|
335
|
+
self.name = name
|
|
336
|
+
|
|
337
|
+
def _stringify(self, transform: StringifyTransform) -> str:
|
|
338
|
+
return '->' + transform(self.name)
|
|
339
|
+
|
|
340
|
+
def describe_signature(self, signode: TextElement, mode: str,
|
|
341
|
+
env: BuildEnvironment, symbol: Symbol) -> None:
|
|
342
|
+
signode += addnodes.desc_sig_operator('->', '->')
|
|
343
|
+
self.name.describe_signature(signode, 'noneIsName', env, symbol)
|
|
344
|
+
|
|
345
|
+
|
|
346
|
+
class ASTPostfixExpr(ASTExpression):
|
|
347
|
+
def __init__(self, prefix: ASTExpression, postFixes: list[ASTPostfixOp]) -> None:
|
|
348
|
+
self.prefix = prefix
|
|
349
|
+
self.postFixes = postFixes
|
|
350
|
+
|
|
351
|
+
def _stringify(self, transform: StringifyTransform) -> str:
|
|
352
|
+
return ''.join([transform(self.prefix), *(transform(p) for p in self.postFixes)])
|
|
353
|
+
|
|
354
|
+
def describe_signature(self, signode: TextElement, mode: str,
|
|
355
|
+
env: BuildEnvironment, symbol: Symbol) -> None:
|
|
356
|
+
self.prefix.describe_signature(signode, mode, env, symbol)
|
|
357
|
+
for p in self.postFixes:
|
|
358
|
+
p.describe_signature(signode, mode, env, symbol)
|
|
359
|
+
|
|
360
|
+
|
|
361
|
+
# Unary expressions
|
|
362
|
+
################################################################################
|
|
363
|
+
|
|
364
|
+
class ASTUnaryOpExpr(ASTExpression):
|
|
365
|
+
def __init__(self, op: str, expr: ASTExpression) -> None:
|
|
366
|
+
self.op = op
|
|
367
|
+
self.expr = expr
|
|
368
|
+
|
|
369
|
+
def _stringify(self, transform: StringifyTransform) -> str:
|
|
370
|
+
if self.op[0] in 'cn':
|
|
371
|
+
return self.op + " " + transform(self.expr)
|
|
372
|
+
else:
|
|
373
|
+
return self.op + transform(self.expr)
|
|
374
|
+
|
|
375
|
+
def describe_signature(self, signode: TextElement, mode: str,
|
|
376
|
+
env: BuildEnvironment, symbol: Symbol) -> None:
|
|
377
|
+
if self.op[0] in 'cn':
|
|
378
|
+
signode += addnodes.desc_sig_keyword(self.op, self.op)
|
|
379
|
+
signode += addnodes.desc_sig_space()
|
|
380
|
+
else:
|
|
381
|
+
signode += addnodes.desc_sig_operator(self.op, self.op)
|
|
382
|
+
self.expr.describe_signature(signode, mode, env, symbol)
|
|
383
|
+
|
|
384
|
+
|
|
385
|
+
class ASTSizeofType(ASTExpression):
|
|
386
|
+
def __init__(self, typ: ASTType) -> None:
|
|
387
|
+
self.typ = typ
|
|
388
|
+
|
|
389
|
+
def _stringify(self, transform: StringifyTransform) -> str:
|
|
390
|
+
return "sizeof(" + transform(self.typ) + ")"
|
|
391
|
+
|
|
392
|
+
def describe_signature(self, signode: TextElement, mode: str,
|
|
393
|
+
env: BuildEnvironment, symbol: Symbol) -> None:
|
|
394
|
+
signode += addnodes.desc_sig_keyword('sizeof', 'sizeof')
|
|
395
|
+
signode += addnodes.desc_sig_punctuation('(', '(')
|
|
396
|
+
self.typ.describe_signature(signode, mode, env, symbol)
|
|
397
|
+
signode += addnodes.desc_sig_punctuation(')', ')')
|
|
398
|
+
|
|
399
|
+
|
|
400
|
+
class ASTSizeofExpr(ASTExpression):
|
|
401
|
+
def __init__(self, expr: ASTExpression) -> None:
|
|
402
|
+
self.expr = expr
|
|
403
|
+
|
|
404
|
+
def _stringify(self, transform: StringifyTransform) -> str:
|
|
405
|
+
return "sizeof " + transform(self.expr)
|
|
406
|
+
|
|
407
|
+
def describe_signature(self, signode: TextElement, mode: str,
|
|
408
|
+
env: BuildEnvironment, symbol: Symbol) -> None:
|
|
409
|
+
signode += addnodes.desc_sig_keyword('sizeof', 'sizeof')
|
|
410
|
+
signode += addnodes.desc_sig_space()
|
|
411
|
+
self.expr.describe_signature(signode, mode, env, symbol)
|
|
412
|
+
|
|
413
|
+
|
|
414
|
+
class ASTAlignofExpr(ASTExpression):
|
|
415
|
+
def __init__(self, typ: ASTType) -> None:
|
|
416
|
+
self.typ = typ
|
|
417
|
+
|
|
418
|
+
def _stringify(self, transform: StringifyTransform) -> str:
|
|
419
|
+
return "alignof(" + transform(self.typ) + ")"
|
|
420
|
+
|
|
421
|
+
def describe_signature(self, signode: TextElement, mode: str,
|
|
422
|
+
env: BuildEnvironment, symbol: Symbol) -> None:
|
|
423
|
+
signode += addnodes.desc_sig_keyword('alignof', 'alignof')
|
|
424
|
+
signode += addnodes.desc_sig_punctuation('(', '(')
|
|
425
|
+
self.typ.describe_signature(signode, mode, env, symbol)
|
|
426
|
+
signode += addnodes.desc_sig_punctuation(')', ')')
|
|
427
|
+
|
|
428
|
+
|
|
429
|
+
# Other expressions
|
|
430
|
+
################################################################################
|
|
431
|
+
|
|
432
|
+
class ASTCastExpr(ASTExpression):
|
|
433
|
+
def __init__(self, typ: ASTType, expr: ASTExpression) -> None:
|
|
434
|
+
self.typ = typ
|
|
435
|
+
self.expr = expr
|
|
436
|
+
|
|
437
|
+
def _stringify(self, transform: StringifyTransform) -> str:
|
|
438
|
+
res = ['(']
|
|
439
|
+
res.append(transform(self.typ))
|
|
440
|
+
res.append(')')
|
|
441
|
+
res.append(transform(self.expr))
|
|
442
|
+
return ''.join(res)
|
|
443
|
+
|
|
444
|
+
def describe_signature(self, signode: TextElement, mode: str,
|
|
445
|
+
env: BuildEnvironment, symbol: Symbol) -> None:
|
|
446
|
+
signode += addnodes.desc_sig_punctuation('(', '(')
|
|
447
|
+
self.typ.describe_signature(signode, mode, env, symbol)
|
|
448
|
+
signode += addnodes.desc_sig_punctuation(')', ')')
|
|
449
|
+
self.expr.describe_signature(signode, mode, env, symbol)
|
|
450
|
+
|
|
451
|
+
|
|
452
|
+
class ASTBinOpExpr(ASTBase):
|
|
453
|
+
def __init__(self, exprs: list[ASTExpression], ops: list[str]) -> None:
|
|
454
|
+
assert len(exprs) > 0
|
|
455
|
+
assert len(exprs) == len(ops) + 1
|
|
456
|
+
self.exprs = exprs
|
|
457
|
+
self.ops = ops
|
|
458
|
+
|
|
459
|
+
def _stringify(self, transform: StringifyTransform) -> str:
|
|
460
|
+
res = []
|
|
461
|
+
res.append(transform(self.exprs[0]))
|
|
462
|
+
for i in range(1, len(self.exprs)):
|
|
463
|
+
res.append(' ')
|
|
464
|
+
res.append(self.ops[i - 1])
|
|
465
|
+
res.append(' ')
|
|
466
|
+
res.append(transform(self.exprs[i]))
|
|
467
|
+
return ''.join(res)
|
|
468
|
+
|
|
469
|
+
def describe_signature(self, signode: TextElement, mode: str,
|
|
470
|
+
env: BuildEnvironment, symbol: Symbol) -> None:
|
|
471
|
+
self.exprs[0].describe_signature(signode, mode, env, symbol)
|
|
472
|
+
for i in range(1, len(self.exprs)):
|
|
473
|
+
signode += addnodes.desc_sig_space()
|
|
474
|
+
op = self.ops[i - 1]
|
|
475
|
+
if ord(op[0]) >= ord('a') and ord(op[0]) <= ord('z'):
|
|
476
|
+
signode += addnodes.desc_sig_keyword(op, op)
|
|
477
|
+
else:
|
|
478
|
+
signode += addnodes.desc_sig_operator(op, op)
|
|
479
|
+
signode += addnodes.desc_sig_space()
|
|
480
|
+
self.exprs[i].describe_signature(signode, mode, env, symbol)
|
|
481
|
+
|
|
482
|
+
|
|
483
|
+
class ASTAssignmentExpr(ASTExpression):
|
|
484
|
+
def __init__(self, exprs: list[ASTExpression], ops: list[str]) -> None:
|
|
485
|
+
assert len(exprs) > 0
|
|
486
|
+
assert len(exprs) == len(ops) + 1
|
|
487
|
+
self.exprs = exprs
|
|
488
|
+
self.ops = ops
|
|
489
|
+
|
|
490
|
+
def _stringify(self, transform: StringifyTransform) -> str:
|
|
491
|
+
res = []
|
|
492
|
+
res.append(transform(self.exprs[0]))
|
|
493
|
+
for i in range(1, len(self.exprs)):
|
|
494
|
+
res.append(' ')
|
|
495
|
+
res.append(self.ops[i - 1])
|
|
496
|
+
res.append(' ')
|
|
497
|
+
res.append(transform(self.exprs[i]))
|
|
498
|
+
return ''.join(res)
|
|
499
|
+
|
|
500
|
+
def describe_signature(self, signode: TextElement, mode: str,
|
|
501
|
+
env: BuildEnvironment, symbol: Symbol) -> None:
|
|
502
|
+
self.exprs[0].describe_signature(signode, mode, env, symbol)
|
|
503
|
+
for i in range(1, len(self.exprs)):
|
|
504
|
+
signode += addnodes.desc_sig_space()
|
|
505
|
+
op = self.ops[i - 1]
|
|
506
|
+
if ord(op[0]) >= ord('a') and ord(op[0]) <= ord('z'):
|
|
507
|
+
signode += addnodes.desc_sig_keyword(op, op)
|
|
508
|
+
else:
|
|
509
|
+
signode += addnodes.desc_sig_operator(op, op)
|
|
510
|
+
signode += addnodes.desc_sig_space()
|
|
511
|
+
self.exprs[i].describe_signature(signode, mode, env, symbol)
|
|
512
|
+
|
|
513
|
+
|
|
514
|
+
class ASTFallbackExpr(ASTExpression):
|
|
515
|
+
def __init__(self, expr: str) -> None:
|
|
516
|
+
self.expr = expr
|
|
517
|
+
|
|
518
|
+
def _stringify(self, transform: StringifyTransform) -> str:
|
|
519
|
+
return self.expr
|
|
520
|
+
|
|
521
|
+
def get_id(self, version: int) -> str:
|
|
522
|
+
return str(self.expr)
|
|
523
|
+
|
|
524
|
+
def describe_signature(self, signode: TextElement, mode: str,
|
|
525
|
+
env: BuildEnvironment, symbol: Symbol) -> None:
|
|
526
|
+
signode += nodes.literal(self.expr, self.expr)
|
|
527
|
+
|
|
528
|
+
|
|
529
|
+
################################################################################
|
|
530
|
+
# Types
|
|
531
|
+
################################################################################
|
|
532
|
+
|
|
533
|
+
class ASTTrailingTypeSpec(ASTBase):
|
|
534
|
+
pass
|
|
535
|
+
|
|
536
|
+
|
|
537
|
+
class ASTTrailingTypeSpecFundamental(ASTTrailingTypeSpec):
|
|
538
|
+
def __init__(self, names: list[str]) -> None:
|
|
539
|
+
assert len(names) != 0
|
|
540
|
+
self.names = names
|
|
541
|
+
|
|
542
|
+
def _stringify(self, transform: StringifyTransform) -> str:
|
|
543
|
+
return ' '.join(self.names)
|
|
544
|
+
|
|
545
|
+
def describe_signature(self, signode: TextElement, mode: str,
|
|
546
|
+
env: BuildEnvironment, symbol: Symbol) -> None:
|
|
547
|
+
first = True
|
|
548
|
+
for n in self.names:
|
|
549
|
+
if not first:
|
|
550
|
+
signode += addnodes.desc_sig_space()
|
|
551
|
+
else:
|
|
552
|
+
first = False
|
|
553
|
+
signode += addnodes.desc_sig_keyword_type(n, n)
|
|
554
|
+
|
|
555
|
+
|
|
556
|
+
class ASTTrailingTypeSpecName(ASTTrailingTypeSpec):
|
|
557
|
+
def __init__(self, prefix: str, nestedName: ASTNestedName) -> None:
|
|
558
|
+
self.prefix = prefix
|
|
559
|
+
self.nestedName = nestedName
|
|
560
|
+
|
|
561
|
+
@property
|
|
562
|
+
def name(self) -> ASTNestedName:
|
|
563
|
+
return self.nestedName
|
|
564
|
+
|
|
565
|
+
def _stringify(self, transform: StringifyTransform) -> str:
|
|
566
|
+
res = []
|
|
567
|
+
if self.prefix:
|
|
568
|
+
res.append(self.prefix)
|
|
569
|
+
res.append(' ')
|
|
570
|
+
res.append(transform(self.nestedName))
|
|
571
|
+
return ''.join(res)
|
|
572
|
+
|
|
573
|
+
def describe_signature(self, signode: TextElement, mode: str,
|
|
574
|
+
env: BuildEnvironment, symbol: Symbol) -> None:
|
|
575
|
+
if self.prefix:
|
|
576
|
+
signode += addnodes.desc_sig_keyword(self.prefix, self.prefix)
|
|
577
|
+
signode += addnodes.desc_sig_space()
|
|
578
|
+
self.nestedName.describe_signature(signode, mode, env, symbol=symbol)
|
|
579
|
+
|
|
580
|
+
|
|
581
|
+
class ASTFunctionParameter(ASTBase):
|
|
582
|
+
def __init__(self, arg: ASTTypeWithInit | None, ellipsis: bool = False) -> None:
|
|
583
|
+
self.arg = arg
|
|
584
|
+
self.ellipsis = ellipsis
|
|
585
|
+
|
|
586
|
+
def get_id(self, version: int, objectType: str, symbol: Symbol) -> str:
|
|
587
|
+
# the anchor will be our parent
|
|
588
|
+
return symbol.parent.declaration.get_id(version, prefixed=False)
|
|
589
|
+
|
|
590
|
+
def _stringify(self, transform: StringifyTransform) -> str:
|
|
591
|
+
if self.ellipsis:
|
|
592
|
+
return '...'
|
|
593
|
+
else:
|
|
594
|
+
return transform(self.arg)
|
|
595
|
+
|
|
596
|
+
def describe_signature(self, signode: Any, mode: str,
|
|
597
|
+
env: BuildEnvironment, symbol: Symbol) -> None:
|
|
598
|
+
verify_description_mode(mode)
|
|
599
|
+
if self.ellipsis:
|
|
600
|
+
signode += addnodes.desc_sig_punctuation('...', '...')
|
|
601
|
+
else:
|
|
602
|
+
self.arg.describe_signature(signode, mode, env, symbol=symbol)
|
|
603
|
+
|
|
604
|
+
|
|
605
|
+
class ASTParameters(ASTBase):
|
|
606
|
+
def __init__(self, args: list[ASTFunctionParameter], attrs: ASTAttributeList) -> None:
|
|
607
|
+
self.args = args
|
|
608
|
+
self.attrs = attrs
|
|
609
|
+
|
|
610
|
+
@property
|
|
611
|
+
def function_params(self) -> list[ASTFunctionParameter]:
|
|
612
|
+
return self.args
|
|
613
|
+
|
|
614
|
+
def _stringify(self, transform: StringifyTransform) -> str:
|
|
615
|
+
res = []
|
|
616
|
+
res.append('(')
|
|
617
|
+
first = True
|
|
618
|
+
for a in self.args:
|
|
619
|
+
if not first:
|
|
620
|
+
res.append(', ')
|
|
621
|
+
first = False
|
|
622
|
+
res.append(str(a))
|
|
623
|
+
res.append(')')
|
|
624
|
+
if len(self.attrs) != 0:
|
|
625
|
+
res.append(' ')
|
|
626
|
+
res.append(transform(self.attrs))
|
|
627
|
+
return ''.join(res)
|
|
628
|
+
|
|
629
|
+
def describe_signature(self, signode: TextElement, mode: str,
|
|
630
|
+
env: BuildEnvironment, symbol: Symbol) -> None:
|
|
631
|
+
verify_description_mode(mode)
|
|
632
|
+
multi_line_parameter_list = False
|
|
633
|
+
test_node: Element = signode
|
|
634
|
+
while test_node.parent:
|
|
635
|
+
if not isinstance(test_node, addnodes.desc_signature):
|
|
636
|
+
test_node = test_node.parent
|
|
637
|
+
continue
|
|
638
|
+
multi_line_parameter_list = test_node.get('multi_line_parameter_list', False)
|
|
639
|
+
break
|
|
640
|
+
|
|
641
|
+
# only use the desc_parameterlist for the outer list, not for inner lists
|
|
642
|
+
if mode == 'lastIsName':
|
|
643
|
+
paramlist = addnodes.desc_parameterlist()
|
|
644
|
+
paramlist['multi_line_parameter_list'] = multi_line_parameter_list
|
|
645
|
+
for arg in self.args:
|
|
646
|
+
param = addnodes.desc_parameter('', '', noemph=True)
|
|
647
|
+
arg.describe_signature(param, 'param', env, symbol=symbol)
|
|
648
|
+
paramlist += param
|
|
649
|
+
signode += paramlist
|
|
650
|
+
else:
|
|
651
|
+
signode += addnodes.desc_sig_punctuation('(', '(')
|
|
652
|
+
first = True
|
|
653
|
+
for arg in self.args:
|
|
654
|
+
if not first:
|
|
655
|
+
signode += addnodes.desc_sig_punctuation(',', ',')
|
|
656
|
+
signode += addnodes.desc_sig_space()
|
|
657
|
+
first = False
|
|
658
|
+
arg.describe_signature(signode, 'markType', env, symbol=symbol)
|
|
659
|
+
signode += addnodes.desc_sig_punctuation(')', ')')
|
|
660
|
+
|
|
661
|
+
if len(self.attrs) != 0:
|
|
662
|
+
signode += addnodes.desc_sig_space()
|
|
663
|
+
self.attrs.describe_signature(signode)
|
|
664
|
+
|
|
665
|
+
|
|
666
|
+
class ASTDeclSpecsSimple(ASTBaseBase):
|
|
667
|
+
def __init__(self, storage: str, threadLocal: str, inline: bool,
|
|
668
|
+
restrict: bool, volatile: bool, const: bool, attrs: ASTAttributeList) -> None:
|
|
669
|
+
self.storage = storage
|
|
670
|
+
self.threadLocal = threadLocal
|
|
671
|
+
self.inline = inline
|
|
672
|
+
self.restrict = restrict
|
|
673
|
+
self.volatile = volatile
|
|
674
|
+
self.const = const
|
|
675
|
+
self.attrs = attrs
|
|
676
|
+
|
|
677
|
+
def mergeWith(self, other: ASTDeclSpecsSimple) -> ASTDeclSpecsSimple:
|
|
678
|
+
if not other:
|
|
679
|
+
return self
|
|
680
|
+
return ASTDeclSpecsSimple(self.storage or other.storage,
|
|
681
|
+
self.threadLocal or other.threadLocal,
|
|
682
|
+
self.inline or other.inline,
|
|
683
|
+
self.volatile or other.volatile,
|
|
684
|
+
self.const or other.const,
|
|
685
|
+
self.restrict or other.restrict,
|
|
686
|
+
self.attrs + other.attrs)
|
|
687
|
+
|
|
688
|
+
def _stringify(self, transform: StringifyTransform) -> str:
|
|
689
|
+
res: list[str] = []
|
|
690
|
+
if len(self.attrs) != 0:
|
|
691
|
+
res.append(transform(self.attrs))
|
|
692
|
+
if self.storage:
|
|
693
|
+
res.append(self.storage)
|
|
694
|
+
if self.threadLocal:
|
|
695
|
+
res.append(self.threadLocal)
|
|
696
|
+
if self.inline:
|
|
697
|
+
res.append('inline')
|
|
698
|
+
if self.restrict:
|
|
699
|
+
res.append('restrict')
|
|
700
|
+
if self.volatile:
|
|
701
|
+
res.append('volatile')
|
|
702
|
+
if self.const:
|
|
703
|
+
res.append('const')
|
|
704
|
+
return ' '.join(res)
|
|
705
|
+
|
|
706
|
+
def describe_signature(self, modifiers: list[Node]) -> None:
|
|
707
|
+
def _add(modifiers: list[Node], text: str) -> None:
|
|
708
|
+
if len(modifiers) != 0:
|
|
709
|
+
modifiers.append(addnodes.desc_sig_space())
|
|
710
|
+
modifiers.append(addnodes.desc_sig_keyword(text, text))
|
|
711
|
+
|
|
712
|
+
if len(modifiers) != 0 and len(self.attrs) != 0:
|
|
713
|
+
modifiers.append(addnodes.desc_sig_space())
|
|
714
|
+
tempNode = nodes.TextElement()
|
|
715
|
+
self.attrs.describe_signature(tempNode)
|
|
716
|
+
modifiers.extend(tempNode.children)
|
|
717
|
+
if self.storage:
|
|
718
|
+
_add(modifiers, self.storage)
|
|
719
|
+
if self.threadLocal:
|
|
720
|
+
_add(modifiers, self.threadLocal)
|
|
721
|
+
if self.inline:
|
|
722
|
+
_add(modifiers, 'inline')
|
|
723
|
+
if self.restrict:
|
|
724
|
+
_add(modifiers, 'restrict')
|
|
725
|
+
if self.volatile:
|
|
726
|
+
_add(modifiers, 'volatile')
|
|
727
|
+
if self.const:
|
|
728
|
+
_add(modifiers, 'const')
|
|
729
|
+
|
|
730
|
+
|
|
731
|
+
class ASTDeclSpecs(ASTBase):
|
|
732
|
+
def __init__(self, outer: str,
|
|
733
|
+
leftSpecs: ASTDeclSpecsSimple,
|
|
734
|
+
rightSpecs: ASTDeclSpecsSimple,
|
|
735
|
+
trailing: ASTTrailingTypeSpec) -> None:
|
|
736
|
+
# leftSpecs and rightSpecs are used for output
|
|
737
|
+
# allSpecs are used for id generation TODO: remove?
|
|
738
|
+
self.outer = outer
|
|
739
|
+
self.leftSpecs = leftSpecs
|
|
740
|
+
self.rightSpecs = rightSpecs
|
|
741
|
+
self.allSpecs = self.leftSpecs.mergeWith(self.rightSpecs)
|
|
742
|
+
self.trailingTypeSpec = trailing
|
|
743
|
+
|
|
744
|
+
def _stringify(self, transform: StringifyTransform) -> str:
|
|
745
|
+
res: list[str] = []
|
|
746
|
+
l = transform(self.leftSpecs)
|
|
747
|
+
if len(l) > 0:
|
|
748
|
+
res.append(l)
|
|
749
|
+
if self.trailingTypeSpec:
|
|
750
|
+
if len(res) > 0:
|
|
751
|
+
res.append(" ")
|
|
752
|
+
res.append(transform(self.trailingTypeSpec))
|
|
753
|
+
r = str(self.rightSpecs)
|
|
754
|
+
if len(r) > 0:
|
|
755
|
+
if len(res) > 0:
|
|
756
|
+
res.append(" ")
|
|
757
|
+
res.append(r)
|
|
758
|
+
return "".join(res)
|
|
759
|
+
|
|
760
|
+
def describe_signature(self, signode: TextElement, mode: str,
|
|
761
|
+
env: BuildEnvironment, symbol: Symbol) -> None:
|
|
762
|
+
verify_description_mode(mode)
|
|
763
|
+
modifiers: list[Node] = []
|
|
764
|
+
|
|
765
|
+
self.leftSpecs.describe_signature(modifiers)
|
|
766
|
+
|
|
767
|
+
for m in modifiers:
|
|
768
|
+
signode += m
|
|
769
|
+
if self.trailingTypeSpec:
|
|
770
|
+
if len(modifiers) > 0:
|
|
771
|
+
signode += addnodes.desc_sig_space()
|
|
772
|
+
self.trailingTypeSpec.describe_signature(signode, mode, env,
|
|
773
|
+
symbol=symbol)
|
|
774
|
+
modifiers = []
|
|
775
|
+
self.rightSpecs.describe_signature(modifiers)
|
|
776
|
+
if len(modifiers) > 0:
|
|
777
|
+
signode += addnodes.desc_sig_space()
|
|
778
|
+
for m in modifiers:
|
|
779
|
+
signode += m
|
|
780
|
+
|
|
781
|
+
|
|
782
|
+
# Declarator
|
|
783
|
+
################################################################################
|
|
784
|
+
|
|
785
|
+
class ASTArray(ASTBase):
|
|
786
|
+
def __init__(self, static: bool, const: bool, volatile: bool, restrict: bool,
|
|
787
|
+
vla: bool, size: ASTExpression) -> None:
|
|
788
|
+
self.static = static
|
|
789
|
+
self.const = const
|
|
790
|
+
self.volatile = volatile
|
|
791
|
+
self.restrict = restrict
|
|
792
|
+
self.vla = vla
|
|
793
|
+
self.size = size
|
|
794
|
+
if vla:
|
|
795
|
+
assert size is None
|
|
796
|
+
if size is not None:
|
|
797
|
+
assert not vla
|
|
798
|
+
|
|
799
|
+
def _stringify(self, transform: StringifyTransform) -> str:
|
|
800
|
+
el = []
|
|
801
|
+
if self.static:
|
|
802
|
+
el.append('static')
|
|
803
|
+
if self.restrict:
|
|
804
|
+
el.append('restrict')
|
|
805
|
+
if self.volatile:
|
|
806
|
+
el.append('volatile')
|
|
807
|
+
if self.const:
|
|
808
|
+
el.append('const')
|
|
809
|
+
if self.vla:
|
|
810
|
+
return '[' + ' '.join(el) + '*]'
|
|
811
|
+
elif self.size:
|
|
812
|
+
el.append(transform(self.size))
|
|
813
|
+
return '[' + ' '.join(el) + ']'
|
|
814
|
+
|
|
815
|
+
def describe_signature(self, signode: TextElement, mode: str,
|
|
816
|
+
env: BuildEnvironment, symbol: Symbol) -> None:
|
|
817
|
+
verify_description_mode(mode)
|
|
818
|
+
signode += addnodes.desc_sig_punctuation('[', '[')
|
|
819
|
+
addSpace = False
|
|
820
|
+
|
|
821
|
+
def _add(signode: TextElement, text: str) -> bool:
|
|
822
|
+
if addSpace:
|
|
823
|
+
signode += addnodes.desc_sig_space()
|
|
824
|
+
signode += addnodes.desc_sig_keyword(text, text)
|
|
825
|
+
return True
|
|
826
|
+
|
|
827
|
+
if self.static:
|
|
828
|
+
addSpace = _add(signode, 'static')
|
|
829
|
+
if self.restrict:
|
|
830
|
+
addSpace = _add(signode, 'restrict')
|
|
831
|
+
if self.volatile:
|
|
832
|
+
addSpace = _add(signode, 'volatile')
|
|
833
|
+
if self.const:
|
|
834
|
+
addSpace = _add(signode, 'const')
|
|
835
|
+
if self.vla:
|
|
836
|
+
signode += addnodes.desc_sig_punctuation('*', '*')
|
|
837
|
+
elif self.size:
|
|
838
|
+
if addSpace:
|
|
839
|
+
signode += addnodes.desc_sig_space()
|
|
840
|
+
self.size.describe_signature(signode, 'markType', env, symbol)
|
|
841
|
+
signode += addnodes.desc_sig_punctuation(']', ']')
|
|
842
|
+
|
|
843
|
+
|
|
844
|
+
class ASTDeclarator(ASTBase):
|
|
845
|
+
@property
|
|
846
|
+
def name(self) -> ASTNestedName:
|
|
847
|
+
raise NotImplementedError(repr(self))
|
|
848
|
+
|
|
849
|
+
@property
|
|
850
|
+
def function_params(self) -> list[ASTFunctionParameter]:
|
|
851
|
+
raise NotImplementedError(repr(self))
|
|
852
|
+
|
|
853
|
+
def require_space_after_declSpecs(self) -> bool:
|
|
854
|
+
raise NotImplementedError(repr(self))
|
|
855
|
+
|
|
856
|
+
|
|
857
|
+
class ASTDeclaratorNameParam(ASTDeclarator):
|
|
858
|
+
def __init__(self, declId: ASTNestedName,
|
|
859
|
+
arrayOps: list[ASTArray], param: ASTParameters) -> None:
|
|
860
|
+
self.declId = declId
|
|
861
|
+
self.arrayOps = arrayOps
|
|
862
|
+
self.param = param
|
|
863
|
+
|
|
864
|
+
@property
|
|
865
|
+
def name(self) -> ASTNestedName:
|
|
866
|
+
return self.declId
|
|
867
|
+
|
|
868
|
+
@property
|
|
869
|
+
def function_params(self) -> list[ASTFunctionParameter]:
|
|
870
|
+
return self.param.function_params
|
|
871
|
+
|
|
872
|
+
# ------------------------------------------------------------------------
|
|
873
|
+
|
|
874
|
+
def require_space_after_declSpecs(self) -> bool:
|
|
875
|
+
return self.declId is not None
|
|
876
|
+
|
|
877
|
+
def _stringify(self, transform: StringifyTransform) -> str:
|
|
878
|
+
res = []
|
|
879
|
+
if self.declId:
|
|
880
|
+
res.append(transform(self.declId))
|
|
881
|
+
res.extend(transform(op) for op in self.arrayOps)
|
|
882
|
+
if self.param:
|
|
883
|
+
res.append(transform(self.param))
|
|
884
|
+
return ''.join(res)
|
|
885
|
+
|
|
886
|
+
def describe_signature(self, signode: TextElement, mode: str,
|
|
887
|
+
env: BuildEnvironment, symbol: Symbol) -> None:
|
|
888
|
+
verify_description_mode(mode)
|
|
889
|
+
if self.declId:
|
|
890
|
+
self.declId.describe_signature(signode, mode, env, symbol)
|
|
891
|
+
for op in self.arrayOps:
|
|
892
|
+
op.describe_signature(signode, mode, env, symbol)
|
|
893
|
+
if self.param:
|
|
894
|
+
self.param.describe_signature(signode, mode, env, symbol)
|
|
895
|
+
|
|
896
|
+
|
|
897
|
+
class ASTDeclaratorNameBitField(ASTDeclarator):
|
|
898
|
+
def __init__(self, declId: ASTNestedName, size: ASTExpression) -> None:
|
|
899
|
+
self.declId = declId
|
|
900
|
+
self.size = size
|
|
901
|
+
|
|
902
|
+
@property
|
|
903
|
+
def name(self) -> ASTNestedName:
|
|
904
|
+
return self.declId
|
|
905
|
+
|
|
906
|
+
# ------------------------------------------------------------------------
|
|
907
|
+
|
|
908
|
+
def require_space_after_declSpecs(self) -> bool:
|
|
909
|
+
return self.declId is not None
|
|
910
|
+
|
|
911
|
+
def _stringify(self, transform: StringifyTransform) -> str:
|
|
912
|
+
res = []
|
|
913
|
+
if self.declId:
|
|
914
|
+
res.append(transform(self.declId))
|
|
915
|
+
res.append(" : ")
|
|
916
|
+
res.append(transform(self.size))
|
|
917
|
+
return ''.join(res)
|
|
918
|
+
|
|
919
|
+
def describe_signature(self, signode: TextElement, mode: str,
|
|
920
|
+
env: BuildEnvironment, symbol: Symbol) -> None:
|
|
921
|
+
verify_description_mode(mode)
|
|
922
|
+
if self.declId:
|
|
923
|
+
self.declId.describe_signature(signode, mode, env, symbol)
|
|
924
|
+
signode += addnodes.desc_sig_space()
|
|
925
|
+
signode += addnodes.desc_sig_punctuation(':', ':')
|
|
926
|
+
signode += addnodes.desc_sig_space()
|
|
927
|
+
self.size.describe_signature(signode, mode, env, symbol)
|
|
928
|
+
|
|
929
|
+
|
|
930
|
+
class ASTDeclaratorPtr(ASTDeclarator):
|
|
931
|
+
def __init__(self, next: ASTDeclarator, restrict: bool, volatile: bool, const: bool,
|
|
932
|
+
attrs: ASTAttributeList) -> None:
|
|
933
|
+
assert next
|
|
934
|
+
self.next = next
|
|
935
|
+
self.restrict = restrict
|
|
936
|
+
self.volatile = volatile
|
|
937
|
+
self.const = const
|
|
938
|
+
self.attrs = attrs
|
|
939
|
+
|
|
940
|
+
@property
|
|
941
|
+
def name(self) -> ASTNestedName:
|
|
942
|
+
return self.next.name
|
|
943
|
+
|
|
944
|
+
@property
|
|
945
|
+
def function_params(self) -> list[ASTFunctionParameter]:
|
|
946
|
+
return self.next.function_params
|
|
947
|
+
|
|
948
|
+
def require_space_after_declSpecs(self) -> bool:
|
|
949
|
+
return self.const or self.volatile or self.restrict or \
|
|
950
|
+
len(self.attrs) > 0 or \
|
|
951
|
+
self.next.require_space_after_declSpecs()
|
|
952
|
+
|
|
953
|
+
def _stringify(self, transform: StringifyTransform) -> str:
|
|
954
|
+
res = ['*']
|
|
955
|
+
res.append(transform(self.attrs))
|
|
956
|
+
if len(self.attrs) != 0 and (self.restrict or self.volatile or self.const):
|
|
957
|
+
res.append(' ')
|
|
958
|
+
if self.restrict:
|
|
959
|
+
res.append('restrict')
|
|
960
|
+
if self.volatile:
|
|
961
|
+
if self.restrict:
|
|
962
|
+
res.append(' ')
|
|
963
|
+
res.append('volatile')
|
|
964
|
+
if self.const:
|
|
965
|
+
if self.restrict or self.volatile:
|
|
966
|
+
res.append(' ')
|
|
967
|
+
res.append('const')
|
|
968
|
+
if self.const or self.volatile or self.restrict or len(self.attrs) > 0:
|
|
969
|
+
if self.next.require_space_after_declSpecs():
|
|
970
|
+
res.append(' ')
|
|
971
|
+
res.append(transform(self.next))
|
|
972
|
+
return ''.join(res)
|
|
973
|
+
|
|
974
|
+
def describe_signature(self, signode: TextElement, mode: str,
|
|
975
|
+
env: BuildEnvironment, symbol: Symbol) -> None:
|
|
976
|
+
verify_description_mode(mode)
|
|
977
|
+
signode += addnodes.desc_sig_punctuation('*', '*')
|
|
978
|
+
self.attrs.describe_signature(signode)
|
|
979
|
+
if len(self.attrs) != 0 and (self.restrict or self.volatile or self.const):
|
|
980
|
+
signode += addnodes.desc_sig_space()
|
|
981
|
+
|
|
982
|
+
def _add_anno(signode: TextElement, text: str) -> None:
|
|
983
|
+
signode += addnodes.desc_sig_keyword(text, text)
|
|
984
|
+
|
|
985
|
+
if self.restrict:
|
|
986
|
+
_add_anno(signode, 'restrict')
|
|
987
|
+
if self.volatile:
|
|
988
|
+
if self.restrict:
|
|
989
|
+
signode += addnodes.desc_sig_space()
|
|
990
|
+
_add_anno(signode, 'volatile')
|
|
991
|
+
if self.const:
|
|
992
|
+
if self.restrict or self.volatile:
|
|
993
|
+
signode += addnodes.desc_sig_space()
|
|
994
|
+
_add_anno(signode, 'const')
|
|
995
|
+
if self.const or self.volatile or self.restrict or len(self.attrs) > 0:
|
|
996
|
+
if self.next.require_space_after_declSpecs():
|
|
997
|
+
signode += addnodes.desc_sig_space()
|
|
998
|
+
self.next.describe_signature(signode, mode, env, symbol)
|
|
999
|
+
|
|
1000
|
+
|
|
1001
|
+
class ASTDeclaratorParen(ASTDeclarator):
|
|
1002
|
+
def __init__(self, inner: ASTDeclarator, next: ASTDeclarator) -> None:
|
|
1003
|
+
assert inner
|
|
1004
|
+
assert next
|
|
1005
|
+
self.inner = inner
|
|
1006
|
+
self.next = next
|
|
1007
|
+
# TODO: we assume the name and params are in inner
|
|
1008
|
+
|
|
1009
|
+
@property
|
|
1010
|
+
def name(self) -> ASTNestedName:
|
|
1011
|
+
return self.inner.name
|
|
1012
|
+
|
|
1013
|
+
@property
|
|
1014
|
+
def function_params(self) -> list[ASTFunctionParameter]:
|
|
1015
|
+
return self.inner.function_params
|
|
1016
|
+
|
|
1017
|
+
def require_space_after_declSpecs(self) -> bool:
|
|
1018
|
+
return True
|
|
1019
|
+
|
|
1020
|
+
def _stringify(self, transform: StringifyTransform) -> str:
|
|
1021
|
+
res = ['(']
|
|
1022
|
+
res.append(transform(self.inner))
|
|
1023
|
+
res.append(')')
|
|
1024
|
+
res.append(transform(self.next))
|
|
1025
|
+
return ''.join(res)
|
|
1026
|
+
|
|
1027
|
+
def describe_signature(self, signode: TextElement, mode: str,
|
|
1028
|
+
env: BuildEnvironment, symbol: Symbol) -> None:
|
|
1029
|
+
verify_description_mode(mode)
|
|
1030
|
+
signode += addnodes.desc_sig_punctuation('(', '(')
|
|
1031
|
+
self.inner.describe_signature(signode, mode, env, symbol)
|
|
1032
|
+
signode += addnodes.desc_sig_punctuation(')', ')')
|
|
1033
|
+
self.next.describe_signature(signode, "noneIsName", env, symbol)
|
|
1034
|
+
|
|
1035
|
+
|
|
1036
|
+
# Initializer
|
|
1037
|
+
################################################################################
|
|
1038
|
+
|
|
1039
|
+
class ASTParenExprList(ASTBaseParenExprList):
|
|
1040
|
+
def __init__(self, exprs: list[ASTExpression]) -> None:
|
|
1041
|
+
self.exprs = exprs
|
|
1042
|
+
|
|
1043
|
+
def _stringify(self, transform: StringifyTransform) -> str:
|
|
1044
|
+
exprs = [transform(e) for e in self.exprs]
|
|
1045
|
+
return '(%s)' % ', '.join(exprs)
|
|
1046
|
+
|
|
1047
|
+
def describe_signature(self, signode: TextElement, mode: str,
|
|
1048
|
+
env: BuildEnvironment, symbol: Symbol) -> None:
|
|
1049
|
+
verify_description_mode(mode)
|
|
1050
|
+
signode += addnodes.desc_sig_punctuation('(', '(')
|
|
1051
|
+
first = True
|
|
1052
|
+
for e in self.exprs:
|
|
1053
|
+
if not first:
|
|
1054
|
+
signode += addnodes.desc_sig_punctuation(',', ',')
|
|
1055
|
+
signode += addnodes.desc_sig_space()
|
|
1056
|
+
else:
|
|
1057
|
+
first = False
|
|
1058
|
+
e.describe_signature(signode, mode, env, symbol)
|
|
1059
|
+
signode += addnodes.desc_sig_punctuation(')', ')')
|
|
1060
|
+
|
|
1061
|
+
|
|
1062
|
+
class ASTBracedInitList(ASTBase):
|
|
1063
|
+
def __init__(self, exprs: list[ASTExpression], trailingComma: bool) -> None:
|
|
1064
|
+
self.exprs = exprs
|
|
1065
|
+
self.trailingComma = trailingComma
|
|
1066
|
+
|
|
1067
|
+
def _stringify(self, transform: StringifyTransform) -> str:
|
|
1068
|
+
exprs = ', '.join(transform(e) for e in self.exprs)
|
|
1069
|
+
trailingComma = ',' if self.trailingComma else ''
|
|
1070
|
+
return f'{{{exprs}{trailingComma}}}'
|
|
1071
|
+
|
|
1072
|
+
def describe_signature(self, signode: TextElement, mode: str,
|
|
1073
|
+
env: BuildEnvironment, symbol: Symbol) -> None:
|
|
1074
|
+
verify_description_mode(mode)
|
|
1075
|
+
signode += addnodes.desc_sig_punctuation('{', '{')
|
|
1076
|
+
first = True
|
|
1077
|
+
for e in self.exprs:
|
|
1078
|
+
if not first:
|
|
1079
|
+
signode += addnodes.desc_sig_punctuation(',', ',')
|
|
1080
|
+
signode += addnodes.desc_sig_space()
|
|
1081
|
+
else:
|
|
1082
|
+
first = False
|
|
1083
|
+
e.describe_signature(signode, mode, env, symbol)
|
|
1084
|
+
if self.trailingComma:
|
|
1085
|
+
signode += addnodes.desc_sig_punctuation(',', ',')
|
|
1086
|
+
signode += addnodes.desc_sig_punctuation('}', '}')
|
|
1087
|
+
|
|
1088
|
+
|
|
1089
|
+
class ASTInitializer(ASTBase):
|
|
1090
|
+
def __init__(self, value: ASTBracedInitList | ASTExpression,
|
|
1091
|
+
hasAssign: bool = True) -> None:
|
|
1092
|
+
self.value = value
|
|
1093
|
+
self.hasAssign = hasAssign
|
|
1094
|
+
|
|
1095
|
+
def _stringify(self, transform: StringifyTransform) -> str:
|
|
1096
|
+
val = transform(self.value)
|
|
1097
|
+
if self.hasAssign:
|
|
1098
|
+
return ' = ' + val
|
|
1099
|
+
else:
|
|
1100
|
+
return val
|
|
1101
|
+
|
|
1102
|
+
def describe_signature(self, signode: TextElement, mode: str,
|
|
1103
|
+
env: BuildEnvironment, symbol: Symbol) -> None:
|
|
1104
|
+
verify_description_mode(mode)
|
|
1105
|
+
if self.hasAssign:
|
|
1106
|
+
signode += addnodes.desc_sig_space()
|
|
1107
|
+
signode += addnodes.desc_sig_punctuation('=', '=')
|
|
1108
|
+
signode += addnodes.desc_sig_space()
|
|
1109
|
+
self.value.describe_signature(signode, 'markType', env, symbol)
|
|
1110
|
+
|
|
1111
|
+
|
|
1112
|
+
class ASTType(ASTBase):
|
|
1113
|
+
def __init__(self, declSpecs: ASTDeclSpecs, decl: ASTDeclarator) -> None:
|
|
1114
|
+
assert declSpecs
|
|
1115
|
+
assert decl
|
|
1116
|
+
self.declSpecs = declSpecs
|
|
1117
|
+
self.decl = decl
|
|
1118
|
+
|
|
1119
|
+
@property
|
|
1120
|
+
def name(self) -> ASTNestedName:
|
|
1121
|
+
return self.decl.name
|
|
1122
|
+
|
|
1123
|
+
def get_id(self, version: int, objectType: str, symbol: Symbol) -> str:
|
|
1124
|
+
return symbol.get_full_nested_name().get_id(version)
|
|
1125
|
+
|
|
1126
|
+
@property
|
|
1127
|
+
def function_params(self) -> list[ASTFunctionParameter]:
|
|
1128
|
+
return self.decl.function_params
|
|
1129
|
+
|
|
1130
|
+
def _stringify(self, transform: StringifyTransform) -> str:
|
|
1131
|
+
res = []
|
|
1132
|
+
declSpecs = transform(self.declSpecs)
|
|
1133
|
+
res.append(declSpecs)
|
|
1134
|
+
if self.decl.require_space_after_declSpecs() and len(declSpecs) > 0:
|
|
1135
|
+
res.append(' ')
|
|
1136
|
+
res.append(transform(self.decl))
|
|
1137
|
+
return ''.join(res)
|
|
1138
|
+
|
|
1139
|
+
def get_type_declaration_prefix(self) -> str:
|
|
1140
|
+
if self.declSpecs.trailingTypeSpec:
|
|
1141
|
+
return 'typedef'
|
|
1142
|
+
else:
|
|
1143
|
+
return 'type'
|
|
1144
|
+
|
|
1145
|
+
def describe_signature(self, signode: TextElement, mode: str,
|
|
1146
|
+
env: BuildEnvironment, symbol: Symbol) -> None:
|
|
1147
|
+
verify_description_mode(mode)
|
|
1148
|
+
self.declSpecs.describe_signature(signode, 'markType', env, symbol)
|
|
1149
|
+
if (self.decl.require_space_after_declSpecs() and
|
|
1150
|
+
len(str(self.declSpecs)) > 0):
|
|
1151
|
+
signode += addnodes.desc_sig_space()
|
|
1152
|
+
# for parameters that don't really declare new names we get 'markType',
|
|
1153
|
+
# this should not be propagated, but be 'noneIsName'.
|
|
1154
|
+
if mode == 'markType':
|
|
1155
|
+
mode = 'noneIsName'
|
|
1156
|
+
self.decl.describe_signature(signode, mode, env, symbol)
|
|
1157
|
+
|
|
1158
|
+
|
|
1159
|
+
class ASTTypeWithInit(ASTBase):
|
|
1160
|
+
def __init__(self, type: ASTType, init: ASTInitializer) -> None:
|
|
1161
|
+
self.type = type
|
|
1162
|
+
self.init = init
|
|
1163
|
+
|
|
1164
|
+
@property
|
|
1165
|
+
def name(self) -> ASTNestedName:
|
|
1166
|
+
return self.type.name
|
|
1167
|
+
|
|
1168
|
+
def get_id(self, version: int, objectType: str, symbol: Symbol) -> str:
|
|
1169
|
+
return self.type.get_id(version, objectType, symbol)
|
|
1170
|
+
|
|
1171
|
+
def _stringify(self, transform: StringifyTransform) -> str:
|
|
1172
|
+
res = []
|
|
1173
|
+
res.append(transform(self.type))
|
|
1174
|
+
if self.init:
|
|
1175
|
+
res.append(transform(self.init))
|
|
1176
|
+
return ''.join(res)
|
|
1177
|
+
|
|
1178
|
+
def describe_signature(self, signode: TextElement, mode: str,
|
|
1179
|
+
env: BuildEnvironment, symbol: Symbol) -> None:
|
|
1180
|
+
verify_description_mode(mode)
|
|
1181
|
+
self.type.describe_signature(signode, mode, env, symbol)
|
|
1182
|
+
if self.init:
|
|
1183
|
+
self.init.describe_signature(signode, mode, env, symbol)
|
|
1184
|
+
|
|
1185
|
+
|
|
1186
|
+
class ASTMacroParameter(ASTBase):
|
|
1187
|
+
def __init__(self, arg: ASTNestedName | None, ellipsis: bool = False,
|
|
1188
|
+
variadic: bool = False) -> None:
|
|
1189
|
+
self.arg = arg
|
|
1190
|
+
self.ellipsis = ellipsis
|
|
1191
|
+
self.variadic = variadic
|
|
1192
|
+
|
|
1193
|
+
def _stringify(self, transform: StringifyTransform) -> str:
|
|
1194
|
+
if self.ellipsis:
|
|
1195
|
+
return '...'
|
|
1196
|
+
elif self.variadic:
|
|
1197
|
+
return transform(self.arg) + '...'
|
|
1198
|
+
else:
|
|
1199
|
+
return transform(self.arg)
|
|
1200
|
+
|
|
1201
|
+
def describe_signature(self, signode: Any, mode: str,
|
|
1202
|
+
env: BuildEnvironment, symbol: Symbol) -> None:
|
|
1203
|
+
verify_description_mode(mode)
|
|
1204
|
+
if self.ellipsis:
|
|
1205
|
+
signode += addnodes.desc_sig_punctuation('...', '...')
|
|
1206
|
+
elif self.variadic:
|
|
1207
|
+
name = str(self)
|
|
1208
|
+
signode += addnodes.desc_sig_name(name, name)
|
|
1209
|
+
else:
|
|
1210
|
+
self.arg.describe_signature(signode, mode, env, symbol=symbol)
|
|
1211
|
+
|
|
1212
|
+
|
|
1213
|
+
class ASTMacro(ASTBase):
|
|
1214
|
+
def __init__(self, ident: ASTNestedName, args: list[ASTMacroParameter] | None) -> None:
|
|
1215
|
+
self.ident = ident
|
|
1216
|
+
self.args = args
|
|
1217
|
+
|
|
1218
|
+
@property
|
|
1219
|
+
def name(self) -> ASTNestedName:
|
|
1220
|
+
return self.ident
|
|
1221
|
+
|
|
1222
|
+
def get_id(self, version: int, objectType: str, symbol: Symbol) -> str:
|
|
1223
|
+
return symbol.get_full_nested_name().get_id(version)
|
|
1224
|
+
|
|
1225
|
+
def _stringify(self, transform: StringifyTransform) -> str:
|
|
1226
|
+
res = []
|
|
1227
|
+
res.append(transform(self.ident))
|
|
1228
|
+
if self.args is not None:
|
|
1229
|
+
res.append('(')
|
|
1230
|
+
first = True
|
|
1231
|
+
for arg in self.args:
|
|
1232
|
+
if not first:
|
|
1233
|
+
res.append(', ')
|
|
1234
|
+
first = False
|
|
1235
|
+
res.append(transform(arg))
|
|
1236
|
+
res.append(')')
|
|
1237
|
+
return ''.join(res)
|
|
1238
|
+
|
|
1239
|
+
def describe_signature(self, signode: TextElement, mode: str,
|
|
1240
|
+
env: BuildEnvironment, symbol: Symbol) -> None:
|
|
1241
|
+
verify_description_mode(mode)
|
|
1242
|
+
self.ident.describe_signature(signode, mode, env, symbol)
|
|
1243
|
+
if self.args is None:
|
|
1244
|
+
return
|
|
1245
|
+
paramlist = addnodes.desc_parameterlist()
|
|
1246
|
+
for arg in self.args:
|
|
1247
|
+
param = addnodes.desc_parameter('', '', noemph=True)
|
|
1248
|
+
arg.describe_signature(param, 'param', env, symbol=symbol)
|
|
1249
|
+
paramlist += param
|
|
1250
|
+
signode += paramlist
|
|
1251
|
+
|
|
1252
|
+
|
|
1253
|
+
class ASTStruct(ASTBase):
|
|
1254
|
+
def __init__(self, name: ASTNestedName) -> None:
|
|
1255
|
+
self.name = name
|
|
1256
|
+
|
|
1257
|
+
def get_id(self, version: int, objectType: str, symbol: Symbol) -> str:
|
|
1258
|
+
return symbol.get_full_nested_name().get_id(version)
|
|
1259
|
+
|
|
1260
|
+
def _stringify(self, transform: StringifyTransform) -> str:
|
|
1261
|
+
return transform(self.name)
|
|
1262
|
+
|
|
1263
|
+
def describe_signature(self, signode: TextElement, mode: str,
|
|
1264
|
+
env: BuildEnvironment, symbol: Symbol) -> None:
|
|
1265
|
+
verify_description_mode(mode)
|
|
1266
|
+
self.name.describe_signature(signode, mode, env, symbol=symbol)
|
|
1267
|
+
|
|
1268
|
+
|
|
1269
|
+
class ASTUnion(ASTBase):
|
|
1270
|
+
def __init__(self, name: ASTNestedName) -> None:
|
|
1271
|
+
self.name = name
|
|
1272
|
+
|
|
1273
|
+
def get_id(self, version: int, objectType: str, symbol: Symbol) -> str:
|
|
1274
|
+
return symbol.get_full_nested_name().get_id(version)
|
|
1275
|
+
|
|
1276
|
+
def _stringify(self, transform: StringifyTransform) -> str:
|
|
1277
|
+
return transform(self.name)
|
|
1278
|
+
|
|
1279
|
+
def describe_signature(self, signode: TextElement, mode: str,
|
|
1280
|
+
env: BuildEnvironment, symbol: Symbol) -> None:
|
|
1281
|
+
verify_description_mode(mode)
|
|
1282
|
+
self.name.describe_signature(signode, mode, env, symbol=symbol)
|
|
1283
|
+
|
|
1284
|
+
|
|
1285
|
+
class ASTEnum(ASTBase):
|
|
1286
|
+
def __init__(self, name: ASTNestedName) -> None:
|
|
1287
|
+
self.name = name
|
|
1288
|
+
|
|
1289
|
+
def get_id(self, version: int, objectType: str, symbol: Symbol) -> str:
|
|
1290
|
+
return symbol.get_full_nested_name().get_id(version)
|
|
1291
|
+
|
|
1292
|
+
def _stringify(self, transform: StringifyTransform) -> str:
|
|
1293
|
+
return transform(self.name)
|
|
1294
|
+
|
|
1295
|
+
def describe_signature(self, signode: TextElement, mode: str,
|
|
1296
|
+
env: BuildEnvironment, symbol: Symbol) -> None:
|
|
1297
|
+
verify_description_mode(mode)
|
|
1298
|
+
self.name.describe_signature(signode, mode, env, symbol=symbol)
|
|
1299
|
+
|
|
1300
|
+
|
|
1301
|
+
class ASTEnumerator(ASTBase):
|
|
1302
|
+
def __init__(self, name: ASTNestedName, init: ASTInitializer | None,
|
|
1303
|
+
attrs: ASTAttributeList) -> None:
|
|
1304
|
+
self.name = name
|
|
1305
|
+
self.init = init
|
|
1306
|
+
self.attrs = attrs
|
|
1307
|
+
|
|
1308
|
+
def get_id(self, version: int, objectType: str, symbol: Symbol) -> str:
|
|
1309
|
+
return symbol.get_full_nested_name().get_id(version)
|
|
1310
|
+
|
|
1311
|
+
def _stringify(self, transform: StringifyTransform) -> str:
|
|
1312
|
+
res = []
|
|
1313
|
+
res.append(transform(self.name))
|
|
1314
|
+
if len(self.attrs) != 0:
|
|
1315
|
+
res.append(' ')
|
|
1316
|
+
res.append(transform(self.attrs))
|
|
1317
|
+
if self.init:
|
|
1318
|
+
res.append(transform(self.init))
|
|
1319
|
+
return ''.join(res)
|
|
1320
|
+
|
|
1321
|
+
def describe_signature(self, signode: TextElement, mode: str,
|
|
1322
|
+
env: BuildEnvironment, symbol: Symbol) -> None:
|
|
1323
|
+
verify_description_mode(mode)
|
|
1324
|
+
self.name.describe_signature(signode, mode, env, symbol)
|
|
1325
|
+
if len(self.attrs) != 0:
|
|
1326
|
+
signode += addnodes.desc_sig_space()
|
|
1327
|
+
self.attrs.describe_signature(signode)
|
|
1328
|
+
if self.init:
|
|
1329
|
+
self.init.describe_signature(signode, 'markType', env, symbol)
|
|
1330
|
+
|
|
1331
|
+
|
|
1332
|
+
class ASTDeclaration(ASTBaseBase):
|
|
1333
|
+
def __init__(self, objectType: str, directiveType: str | None,
|
|
1334
|
+
declaration: DeclarationType | ASTFunctionParameter,
|
|
1335
|
+
semicolon: bool = False) -> None:
|
|
1336
|
+
self.objectType = objectType
|
|
1337
|
+
self.directiveType = directiveType
|
|
1338
|
+
self.declaration = declaration
|
|
1339
|
+
self.semicolon = semicolon
|
|
1340
|
+
|
|
1341
|
+
self.symbol: Symbol | None = None
|
|
1342
|
+
# set by CObject._add_enumerator_to_parent
|
|
1343
|
+
self.enumeratorScopedSymbol: Symbol | None = None
|
|
1344
|
+
|
|
1345
|
+
# the cache assumes that by the time get_newest_id is called, no
|
|
1346
|
+
# further changes will be made to this object
|
|
1347
|
+
self._newest_id_cache: str | None = None
|
|
1348
|
+
|
|
1349
|
+
def clone(self) -> ASTDeclaration:
|
|
1350
|
+
return ASTDeclaration(self.objectType, self.directiveType,
|
|
1351
|
+
self.declaration.clone(), self.semicolon)
|
|
1352
|
+
|
|
1353
|
+
@property
|
|
1354
|
+
def name(self) -> ASTNestedName:
|
|
1355
|
+
decl = cast(DeclarationType, self.declaration)
|
|
1356
|
+
return decl.name
|
|
1357
|
+
|
|
1358
|
+
@property
|
|
1359
|
+
def function_params(self) -> list[ASTFunctionParameter] | None:
|
|
1360
|
+
if self.objectType != 'function':
|
|
1361
|
+
return None
|
|
1362
|
+
decl = cast(ASTType, self.declaration)
|
|
1363
|
+
return decl.function_params
|
|
1364
|
+
|
|
1365
|
+
def get_id(self, version: int, prefixed: bool = True) -> str:
|
|
1366
|
+
if self.objectType == 'enumerator' and self.enumeratorScopedSymbol:
|
|
1367
|
+
return self.enumeratorScopedSymbol.declaration.get_id(version, prefixed)
|
|
1368
|
+
id_ = self.declaration.get_id(version, self.objectType, self.symbol)
|
|
1369
|
+
if prefixed:
|
|
1370
|
+
return _id_prefix[version] + id_
|
|
1371
|
+
else:
|
|
1372
|
+
return id_
|
|
1373
|
+
|
|
1374
|
+
def get_newest_id(self) -> str:
|
|
1375
|
+
if self._newest_id_cache is None:
|
|
1376
|
+
self._newest_id_cache = self.get_id(_max_id, True)
|
|
1377
|
+
return self._newest_id_cache
|
|
1378
|
+
|
|
1379
|
+
def _stringify(self, transform: StringifyTransform) -> str:
|
|
1380
|
+
res = transform(self.declaration)
|
|
1381
|
+
if self.semicolon:
|
|
1382
|
+
res += ';'
|
|
1383
|
+
return res
|
|
1384
|
+
|
|
1385
|
+
def describe_signature(self, signode: TextElement, mode: str,
|
|
1386
|
+
env: BuildEnvironment, options: dict[str, bool]) -> None:
|
|
1387
|
+
verify_description_mode(mode)
|
|
1388
|
+
assert self.symbol
|
|
1389
|
+
# The caller of the domain added a desc_signature node.
|
|
1390
|
+
# Always enable multiline:
|
|
1391
|
+
signode['is_multiline'] = True
|
|
1392
|
+
# Put each line in a desc_signature_line node.
|
|
1393
|
+
mainDeclNode = addnodes.desc_signature_line()
|
|
1394
|
+
mainDeclNode.sphinx_line_type = 'declarator'
|
|
1395
|
+
mainDeclNode['add_permalink'] = not self.symbol.isRedeclaration
|
|
1396
|
+
signode += mainDeclNode
|
|
1397
|
+
|
|
1398
|
+
if self.objectType in {'member', 'function', 'macro'}:
|
|
1399
|
+
pass
|
|
1400
|
+
elif self.objectType == 'struct':
|
|
1401
|
+
mainDeclNode += addnodes.desc_sig_keyword('struct', 'struct')
|
|
1402
|
+
mainDeclNode += addnodes.desc_sig_space()
|
|
1403
|
+
elif self.objectType == 'union':
|
|
1404
|
+
mainDeclNode += addnodes.desc_sig_keyword('union', 'union')
|
|
1405
|
+
mainDeclNode += addnodes.desc_sig_space()
|
|
1406
|
+
elif self.objectType == 'enum':
|
|
1407
|
+
mainDeclNode += addnodes.desc_sig_keyword('enum', 'enum')
|
|
1408
|
+
mainDeclNode += addnodes.desc_sig_space()
|
|
1409
|
+
elif self.objectType == 'enumerator':
|
|
1410
|
+
mainDeclNode += addnodes.desc_sig_keyword('enumerator', 'enumerator')
|
|
1411
|
+
mainDeclNode += addnodes.desc_sig_space()
|
|
1412
|
+
elif self.objectType == 'type':
|
|
1413
|
+
decl = cast(ASTType, self.declaration)
|
|
1414
|
+
prefix = decl.get_type_declaration_prefix()
|
|
1415
|
+
mainDeclNode += addnodes.desc_sig_keyword(prefix, prefix)
|
|
1416
|
+
mainDeclNode += addnodes.desc_sig_space()
|
|
1417
|
+
else:
|
|
1418
|
+
raise AssertionError
|
|
1419
|
+
self.declaration.describe_signature(mainDeclNode, mode, env, self.symbol)
|
|
1420
|
+
if self.semicolon:
|
|
1421
|
+
mainDeclNode += addnodes.desc_sig_punctuation(';', ';')
|