Sphinx 8.1.2__py3-none-any.whl → 8.2.0rc1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of Sphinx might be problematic. Click here for more details.

Files changed (193) hide show
  1. sphinx/__init__.py +8 -4
  2. sphinx/__main__.py +2 -0
  3. sphinx/_cli/__init__.py +2 -5
  4. sphinx/_cli/util/colour.py +34 -11
  5. sphinx/_cli/util/errors.py +128 -61
  6. sphinx/addnodes.py +51 -35
  7. sphinx/application.py +362 -230
  8. sphinx/builders/__init__.py +87 -64
  9. sphinx/builders/_epub_base.py +65 -56
  10. sphinx/builders/changes.py +17 -23
  11. sphinx/builders/dirhtml.py +8 -13
  12. sphinx/builders/epub3.py +70 -38
  13. sphinx/builders/gettext.py +93 -73
  14. sphinx/builders/html/__init__.py +240 -186
  15. sphinx/builders/html/_assets.py +9 -2
  16. sphinx/builders/html/_build_info.py +3 -0
  17. sphinx/builders/latex/__init__.py +64 -54
  18. sphinx/builders/latex/constants.py +14 -11
  19. sphinx/builders/latex/nodes.py +2 -0
  20. sphinx/builders/latex/theming.py +8 -9
  21. sphinx/builders/latex/transforms.py +7 -5
  22. sphinx/builders/linkcheck.py +193 -149
  23. sphinx/builders/manpage.py +17 -17
  24. sphinx/builders/singlehtml.py +28 -16
  25. sphinx/builders/texinfo.py +28 -21
  26. sphinx/builders/text.py +10 -15
  27. sphinx/builders/xml.py +10 -19
  28. sphinx/cmd/build.py +49 -119
  29. sphinx/cmd/make_mode.py +35 -31
  30. sphinx/cmd/quickstart.py +78 -62
  31. sphinx/config.py +265 -163
  32. sphinx/directives/__init__.py +51 -54
  33. sphinx/directives/admonitions.py +107 -0
  34. sphinx/directives/code.py +24 -19
  35. sphinx/directives/other.py +21 -42
  36. sphinx/directives/patches.py +28 -16
  37. sphinx/domains/__init__.py +54 -31
  38. sphinx/domains/_domains_container.py +22 -17
  39. sphinx/domains/_index.py +5 -8
  40. sphinx/domains/c/__init__.py +366 -245
  41. sphinx/domains/c/_ast.py +378 -256
  42. sphinx/domains/c/_ids.py +89 -31
  43. sphinx/domains/c/_parser.py +283 -214
  44. sphinx/domains/c/_symbol.py +269 -198
  45. sphinx/domains/changeset.py +39 -24
  46. sphinx/domains/citation.py +54 -24
  47. sphinx/domains/cpp/__init__.py +517 -362
  48. sphinx/domains/cpp/_ast.py +999 -682
  49. sphinx/domains/cpp/_ids.py +133 -65
  50. sphinx/domains/cpp/_parser.py +746 -588
  51. sphinx/domains/cpp/_symbol.py +692 -489
  52. sphinx/domains/index.py +10 -8
  53. sphinx/domains/javascript.py +152 -74
  54. sphinx/domains/math.py +48 -40
  55. sphinx/domains/python/__init__.py +402 -211
  56. sphinx/domains/python/_annotations.py +114 -57
  57. sphinx/domains/python/_object.py +151 -67
  58. sphinx/domains/rst.py +94 -49
  59. sphinx/domains/std/__init__.py +510 -249
  60. sphinx/environment/__init__.py +345 -61
  61. sphinx/environment/adapters/asset.py +7 -1
  62. sphinx/environment/adapters/indexentries.py +15 -20
  63. sphinx/environment/adapters/toctree.py +19 -9
  64. sphinx/environment/collectors/__init__.py +3 -1
  65. sphinx/environment/collectors/asset.py +18 -15
  66. sphinx/environment/collectors/dependencies.py +8 -10
  67. sphinx/environment/collectors/metadata.py +6 -4
  68. sphinx/environment/collectors/title.py +3 -1
  69. sphinx/environment/collectors/toctree.py +4 -4
  70. sphinx/errors.py +1 -3
  71. sphinx/events.py +4 -4
  72. sphinx/ext/apidoc/__init__.py +21 -0
  73. sphinx/ext/apidoc/__main__.py +9 -0
  74. sphinx/ext/apidoc/_cli.py +356 -0
  75. sphinx/ext/apidoc/_generate.py +356 -0
  76. sphinx/ext/apidoc/_shared.py +66 -0
  77. sphinx/ext/autodoc/__init__.py +837 -483
  78. sphinx/ext/autodoc/directive.py +57 -21
  79. sphinx/ext/autodoc/importer.py +184 -67
  80. sphinx/ext/autodoc/mock.py +25 -10
  81. sphinx/ext/autodoc/preserve_defaults.py +17 -9
  82. sphinx/ext/autodoc/type_comment.py +56 -29
  83. sphinx/ext/autodoc/typehints.py +49 -26
  84. sphinx/ext/autosectionlabel.py +28 -11
  85. sphinx/ext/autosummary/__init__.py +271 -143
  86. sphinx/ext/autosummary/generate.py +121 -51
  87. sphinx/ext/coverage.py +152 -91
  88. sphinx/ext/doctest.py +169 -101
  89. sphinx/ext/duration.py +12 -6
  90. sphinx/ext/extlinks.py +33 -21
  91. sphinx/ext/githubpages.py +8 -8
  92. sphinx/ext/graphviz.py +175 -109
  93. sphinx/ext/ifconfig.py +11 -6
  94. sphinx/ext/imgconverter.py +48 -25
  95. sphinx/ext/imgmath.py +127 -97
  96. sphinx/ext/inheritance_diagram.py +177 -103
  97. sphinx/ext/intersphinx/__init__.py +22 -13
  98. sphinx/ext/intersphinx/__main__.py +3 -1
  99. sphinx/ext/intersphinx/_cli.py +18 -14
  100. sphinx/ext/intersphinx/_load.py +91 -82
  101. sphinx/ext/intersphinx/_resolve.py +108 -74
  102. sphinx/ext/intersphinx/_shared.py +2 -2
  103. sphinx/ext/linkcode.py +28 -12
  104. sphinx/ext/mathjax.py +60 -29
  105. sphinx/ext/napoleon/__init__.py +19 -7
  106. sphinx/ext/napoleon/docstring.py +229 -231
  107. sphinx/ext/todo.py +44 -49
  108. sphinx/ext/viewcode.py +105 -57
  109. sphinx/extension.py +3 -1
  110. sphinx/highlighting.py +13 -7
  111. sphinx/io.py +9 -13
  112. sphinx/jinja2glue.py +29 -26
  113. sphinx/locale/__init__.py +8 -9
  114. sphinx/parsers.py +8 -7
  115. sphinx/project.py +2 -2
  116. sphinx/pycode/__init__.py +31 -21
  117. sphinx/pycode/ast.py +6 -3
  118. sphinx/pycode/parser.py +14 -8
  119. sphinx/pygments_styles.py +4 -5
  120. sphinx/registry.py +192 -92
  121. sphinx/roles.py +58 -7
  122. sphinx/search/__init__.py +75 -54
  123. sphinx/search/en.py +11 -13
  124. sphinx/search/fi.py +1 -1
  125. sphinx/search/ja.py +8 -6
  126. sphinx/search/nl.py +1 -1
  127. sphinx/search/zh.py +19 -21
  128. sphinx/testing/fixtures.py +26 -29
  129. sphinx/testing/path.py +26 -62
  130. sphinx/testing/restructuredtext.py +14 -8
  131. sphinx/testing/util.py +21 -19
  132. sphinx/texinputs/make.bat.jinja +50 -50
  133. sphinx/texinputs/sphinx.sty +4 -3
  134. sphinx/texinputs/sphinxlatexadmonitions.sty +1 -1
  135. sphinx/texinputs/sphinxlatexobjects.sty +29 -10
  136. sphinx/themes/basic/static/searchtools.js +8 -5
  137. sphinx/theming.py +49 -61
  138. sphinx/transforms/__init__.py +17 -38
  139. sphinx/transforms/compact_bullet_list.py +5 -3
  140. sphinx/transforms/i18n.py +8 -21
  141. sphinx/transforms/post_transforms/__init__.py +142 -93
  142. sphinx/transforms/post_transforms/code.py +5 -5
  143. sphinx/transforms/post_transforms/images.py +28 -24
  144. sphinx/transforms/references.py +3 -1
  145. sphinx/util/__init__.py +109 -60
  146. sphinx/util/_files.py +39 -23
  147. sphinx/util/_importer.py +4 -1
  148. sphinx/util/_inventory_file_reader.py +76 -0
  149. sphinx/util/_io.py +2 -2
  150. sphinx/util/_lines.py +6 -3
  151. sphinx/util/_pathlib.py +40 -2
  152. sphinx/util/build_phase.py +2 -0
  153. sphinx/util/cfamily.py +19 -14
  154. sphinx/util/console.py +44 -179
  155. sphinx/util/display.py +9 -10
  156. sphinx/util/docfields.py +140 -122
  157. sphinx/util/docstrings.py +1 -1
  158. sphinx/util/docutils.py +118 -77
  159. sphinx/util/fileutil.py +25 -26
  160. sphinx/util/http_date.py +2 -0
  161. sphinx/util/i18n.py +77 -64
  162. sphinx/util/images.py +8 -6
  163. sphinx/util/inspect.py +147 -38
  164. sphinx/util/inventory.py +215 -116
  165. sphinx/util/logging.py +33 -33
  166. sphinx/util/matching.py +12 -4
  167. sphinx/util/nodes.py +18 -13
  168. sphinx/util/osutil.py +38 -39
  169. sphinx/util/parallel.py +22 -13
  170. sphinx/util/parsing.py +2 -1
  171. sphinx/util/png.py +6 -2
  172. sphinx/util/requests.py +33 -2
  173. sphinx/util/rst.py +3 -2
  174. sphinx/util/tags.py +1 -1
  175. sphinx/util/template.py +18 -10
  176. sphinx/util/texescape.py +8 -6
  177. sphinx/util/typing.py +148 -122
  178. sphinx/versioning.py +3 -3
  179. sphinx/writers/html.py +3 -1
  180. sphinx/writers/html5.py +61 -50
  181. sphinx/writers/latex.py +80 -65
  182. sphinx/writers/manpage.py +19 -38
  183. sphinx/writers/texinfo.py +44 -45
  184. sphinx/writers/text.py +48 -30
  185. sphinx/writers/xml.py +11 -8
  186. {sphinx-8.1.2.dist-info → sphinx-8.2.0rc1.dist-info}/LICENSE.rst +1 -1
  187. {sphinx-8.1.2.dist-info → sphinx-8.2.0rc1.dist-info}/METADATA +23 -15
  188. {sphinx-8.1.2.dist-info → sphinx-8.2.0rc1.dist-info}/RECORD +190 -186
  189. {sphinx-8.1.2.dist-info → sphinx-8.2.0rc1.dist-info}/WHEEL +1 -1
  190. sphinx/builders/html/transforms.py +0 -90
  191. sphinx/ext/apidoc.py +0 -721
  192. sphinx/util/exceptions.py +0 -74
  193. {sphinx-8.1.2.dist-info → sphinx-8.2.0rc1.dist-info}/entry_points.txt +0 -0
sphinx/domains/c/_ast.py CHANGED
@@ -2,14 +2,13 @@ from __future__ import annotations
2
2
 
3
3
  import sys
4
4
  import warnings
5
- from typing import TYPE_CHECKING, Any, Union, cast
5
+ from typing import TYPE_CHECKING, Union, cast
6
6
 
7
7
  from docutils import nodes
8
8
 
9
9
  from sphinx import addnodes
10
10
  from sphinx.domains.c._ids import _id_prefix, _max_id
11
11
  from sphinx.util.cfamily import (
12
- ASTAttributeList,
13
12
  ASTBaseBase,
14
13
  ASTBaseParenExprList,
15
14
  UnsupportedMultiCharacterCharLiteral,
@@ -17,29 +16,39 @@ from sphinx.util.cfamily import (
17
16
  )
18
17
 
19
18
  if TYPE_CHECKING:
20
- from typing import TypeAlias
19
+ from typing import Any, TypeAlias
21
20
 
22
21
  from docutils.nodes import Element, Node, TextElement
23
22
 
24
23
  from sphinx.domains.c._symbol import Symbol
25
24
  from sphinx.environment import BuildEnvironment
26
- from sphinx.util.cfamily import StringifyTransform
27
-
28
- DeclarationType: TypeAlias = Union[ # NoQA: UP007
29
- "ASTStruct", "ASTUnion", "ASTEnum", "ASTEnumerator",
30
- "ASTType", "ASTTypeWithInit", "ASTMacro",
25
+ from sphinx.util.cfamily import (
26
+ ASTAttributeList,
27
+ StringifyTransform,
28
+ )
29
+
30
+ DeclarationType: TypeAlias = Union[
31
+ 'ASTStruct',
32
+ 'ASTUnion',
33
+ 'ASTEnum',
34
+ 'ASTEnumerator',
35
+ 'ASTType',
36
+ 'ASTTypeWithInit',
37
+ 'ASTMacro',
31
38
  ]
32
39
 
33
40
 
34
41
  class ASTBase(ASTBaseBase):
35
- def describe_signature(self, signode: TextElement, mode: str,
36
- env: BuildEnvironment, symbol: Symbol) -> None:
42
+ def describe_signature(
43
+ self, signode: TextElement, mode: str, env: BuildEnvironment, symbol: Symbol
44
+ ) -> None:
37
45
  raise NotImplementedError(repr(self))
38
46
 
39
47
 
40
48
  # Names
41
49
  ################################################################################
42
50
 
51
+
43
52
  class ASTIdentifier(ASTBaseBase):
44
53
  def __init__(self, name: str) -> None:
45
54
  if not isinstance(name, str) or len(name) == 0:
@@ -54,6 +63,9 @@ class ASTIdentifier(ASTBaseBase):
54
63
  return NotImplemented
55
64
  return self.name == other.name
56
65
 
66
+ def __hash__(self) -> int:
67
+ return hash((self.name, self.is_anonymous))
68
+
57
69
  def is_anon(self) -> bool:
58
70
  return self.is_anonymous
59
71
 
@@ -63,29 +75,42 @@ class ASTIdentifier(ASTBaseBase):
63
75
  return self.name
64
76
 
65
77
  def get_display_string(self) -> str:
66
- return "[anonymous]" if self.is_anonymous else self.name
78
+ return '[anonymous]' if self.is_anonymous else self.name
67
79
 
68
- def describe_signature(self, signode: TextElement, mode: str, env: BuildEnvironment,
69
- prefix: str, symbol: Symbol) -> None:
80
+ def _stringify(self, transform: StringifyTransform) -> str:
81
+ return transform(self.get_display_string())
82
+
83
+ def describe_signature(
84
+ self,
85
+ signode: TextElement,
86
+ mode: str,
87
+ env: BuildEnvironment,
88
+ prefix: str,
89
+ symbol: Symbol,
90
+ ) -> None:
70
91
  # note: slightly different signature of describe_signature due to the prefix
71
92
  verify_description_mode(mode)
72
93
  if self.is_anonymous:
73
- node = addnodes.desc_sig_name(text="[anonymous]")
94
+ node = addnodes.desc_sig_name(text='[anonymous]')
74
95
  else:
75
96
  node = addnodes.desc_sig_name(self.name, self.name)
76
97
  if mode == 'markType':
77
- targetText = prefix + self.name
78
- pnode = addnodes.pending_xref('', refdomain='c',
79
- reftype='identifier',
80
- reftarget=targetText, modname=None,
81
- classname=None)
98
+ target_text = prefix + self.name
99
+ pnode = addnodes.pending_xref(
100
+ '',
101
+ refdomain='c',
102
+ reftype='identifier',
103
+ reftarget=target_text,
104
+ modname=None,
105
+ classname=None,
106
+ )
82
107
  pnode['c:parent_key'] = symbol.get_lookup_key()
83
108
  pnode += node
84
109
  signode += pnode
85
110
  elif mode == 'lastIsName':
86
- nameNode = addnodes.desc_name()
87
- nameNode += node
88
- signode += nameNode
111
+ name_node = addnodes.desc_name()
112
+ name_node += node
113
+ signode += name_node
89
114
  elif mode == 'noneIsName':
90
115
  signode += node
91
116
  else:
@@ -95,7 +120,8 @@ class ASTIdentifier(ASTBaseBase):
95
120
  def identifier(self) -> str:
96
121
  warnings.warn(
97
122
  '`ASTIdentifier.identifier` is deprecated, use `ASTIdentifier.name` instead',
98
- DeprecationWarning, stacklevel=2,
123
+ DeprecationWarning,
124
+ stacklevel=2,
99
125
  )
100
126
  return self.name
101
127
 
@@ -128,19 +154,20 @@ class ASTNestedName(ASTBase):
128
154
  else:
129
155
  return res
130
156
 
131
- def describe_signature(self, signode: TextElement, mode: str,
132
- env: BuildEnvironment, symbol: Symbol) -> None:
157
+ def describe_signature(
158
+ self, signode: TextElement, mode: str, env: BuildEnvironment, symbol: Symbol
159
+ ) -> None:
133
160
  verify_description_mode(mode)
134
161
  # just print the name part, with template args, not template params
135
162
  if mode == 'noneIsName':
136
163
  if self.rooted:
137
- unreachable = "Can this happen?"
138
- raise AssertionError(unreachable) # TODO
164
+ unreachable = 'Can this happen?'
165
+ raise AssertionError(unreachable) # TODO: Can this happen?
139
166
  signode += nodes.Text('.')
140
167
  for i in range(len(self.names)):
141
168
  if i != 0:
142
- unreachable = "Can this happen?"
143
- raise AssertionError(unreachable) # TODO
169
+ unreachable = 'Can this happen?'
170
+ raise AssertionError(unreachable) # TODO: Can this happen?
144
171
  signode += nodes.Text('.')
145
172
  n = self.names[i]
146
173
  n.describe_signature(signode, mode, env, '', symbol)
@@ -148,7 +175,7 @@ class ASTNestedName(ASTBase):
148
175
  assert not self.rooted, str(self)
149
176
  assert len(self.names) == 1
150
177
  self.names[0].describe_signature(signode, 'noneIsName', env, '', symbol)
151
- elif mode in ('markType', 'lastIsName', 'markName'):
178
+ elif mode in {'markType', 'lastIsName', 'markName'}:
152
179
  # Each element should be a pending xref targeting the complete
153
180
  # prefix.
154
181
  prefix = ''
@@ -175,7 +202,7 @@ class ASTNestedName(ASTBase):
175
202
  prefix += '.'
176
203
  first = False
177
204
  txt_ident = str(ident)
178
- if txt_ident != '':
205
+ if txt_ident:
179
206
  ident.describe_signature(dest, 'markType', env, prefix, symbol)
180
207
  prefix += txt_ident
181
208
  if mode == 'lastIsName':
@@ -191,6 +218,7 @@ class ASTNestedName(ASTBase):
191
218
  # Expressions
192
219
  ################################################################################
193
220
 
221
+
194
222
  class ASTExpression(ASTBase):
195
223
  pass
196
224
 
@@ -198,6 +226,7 @@ class ASTExpression(ASTBase):
198
226
  # Primary expressions
199
227
  ################################################################################
200
228
 
229
+
201
230
  class ASTLiteral(ASTExpression):
202
231
  pass
203
232
 
@@ -220,8 +249,9 @@ class ASTBooleanLiteral(ASTLiteral):
220
249
  else:
221
250
  return 'false'
222
251
 
223
- def describe_signature(self, signode: TextElement, mode: str,
224
- env: BuildEnvironment, symbol: Symbol) -> None:
252
+ def describe_signature(
253
+ self, signode: TextElement, mode: str, env: BuildEnvironment, symbol: Symbol
254
+ ) -> None:
225
255
  txt = str(self)
226
256
  signode += addnodes.desc_sig_keyword(txt, txt)
227
257
 
@@ -241,8 +271,9 @@ class ASTNumberLiteral(ASTLiteral):
241
271
  def _stringify(self, transform: StringifyTransform) -> str:
242
272
  return self.data
243
273
 
244
- def describe_signature(self, signode: TextElement, mode: str,
245
- env: BuildEnvironment, symbol: Symbol) -> None:
274
+ def describe_signature(
275
+ self, signode: TextElement, mode: str, env: BuildEnvironment, symbol: Symbol
276
+ ) -> None:
246
277
  txt = str(self)
247
278
  signode += addnodes.desc_sig_literal_number(txt, txt)
248
279
 
@@ -260,10 +291,7 @@ class ASTCharLiteral(ASTLiteral):
260
291
  def __eq__(self, other: object) -> bool:
261
292
  if not isinstance(other, ASTCharLiteral):
262
293
  return NotImplemented
263
- return (
264
- self.prefix == other.prefix
265
- and self.value == other.value
266
- )
294
+ return self.prefix == other.prefix and self.value == other.value
267
295
 
268
296
  def __hash__(self) -> int:
269
297
  return hash((self.prefix, self.value))
@@ -274,8 +302,9 @@ class ASTCharLiteral(ASTLiteral):
274
302
  else:
275
303
  return self.prefix + "'" + self.data + "'"
276
304
 
277
- def describe_signature(self, signode: TextElement, mode: str,
278
- env: BuildEnvironment, symbol: Symbol) -> None:
305
+ def describe_signature(
306
+ self, signode: TextElement, mode: str, env: BuildEnvironment, symbol: Symbol
307
+ ) -> None:
279
308
  txt = str(self)
280
309
  signode += addnodes.desc_sig_literal_char(txt, txt)
281
310
 
@@ -295,8 +324,9 @@ class ASTStringLiteral(ASTLiteral):
295
324
  def _stringify(self, transform: StringifyTransform) -> str:
296
325
  return self.data
297
326
 
298
- def describe_signature(self, signode: TextElement, mode: str,
299
- env: BuildEnvironment, symbol: Symbol) -> None:
327
+ def describe_signature(
328
+ self, signode: TextElement, mode: str, env: BuildEnvironment, symbol: Symbol
329
+ ) -> None:
300
330
  txt = str(self)
301
331
  signode += addnodes.desc_sig_literal_string(txt, txt)
302
332
 
@@ -320,8 +350,9 @@ class ASTIdExpression(ASTExpression):
320
350
  def get_id(self, version: int) -> str:
321
351
  return self.name.get_id(version)
322
352
 
323
- def describe_signature(self, signode: TextElement, mode: str,
324
- env: BuildEnvironment, symbol: Symbol) -> None:
353
+ def describe_signature(
354
+ self, signode: TextElement, mode: str, env: BuildEnvironment, symbol: Symbol
355
+ ) -> None:
325
356
  self.name.describe_signature(signode, mode, env, symbol)
326
357
 
327
358
 
@@ -343,8 +374,9 @@ class ASTParenExpr(ASTExpression):
343
374
  def get_id(self, version: int) -> str:
344
375
  return self.expr.get_id(version) # type: ignore[attr-defined]
345
376
 
346
- def describe_signature(self, signode: TextElement, mode: str,
347
- env: BuildEnvironment, symbol: Symbol) -> None:
377
+ def describe_signature(
378
+ self, signode: TextElement, mode: str, env: BuildEnvironment, symbol: Symbol
379
+ ) -> None:
348
380
  signode += addnodes.desc_sig_punctuation('(', '(')
349
381
  self.expr.describe_signature(signode, mode, env, symbol)
350
382
  signode += addnodes.desc_sig_punctuation(')', ')')
@@ -353,6 +385,7 @@ class ASTParenExpr(ASTExpression):
353
385
  # Postfix expressions
354
386
  ################################################################################
355
387
 
388
+
356
389
  class ASTPostfixOp(ASTBase):
357
390
  pass
358
391
 
@@ -372,8 +405,9 @@ class ASTPostfixCallExpr(ASTPostfixOp):
372
405
  def _stringify(self, transform: StringifyTransform) -> str:
373
406
  return transform(self.lst)
374
407
 
375
- def describe_signature(self, signode: TextElement, mode: str,
376
- env: BuildEnvironment, symbol: Symbol) -> None:
408
+ def describe_signature(
409
+ self, signode: TextElement, mode: str, env: BuildEnvironment, symbol: Symbol
410
+ ) -> None:
377
411
  self.lst.describe_signature(signode, mode, env, symbol)
378
412
 
379
413
 
@@ -392,8 +426,9 @@ class ASTPostfixArray(ASTPostfixOp):
392
426
  def _stringify(self, transform: StringifyTransform) -> str:
393
427
  return '[' + transform(self.expr) + ']'
394
428
 
395
- def describe_signature(self, signode: TextElement, mode: str,
396
- env: BuildEnvironment, symbol: Symbol) -> None:
429
+ def describe_signature(
430
+ self, signode: TextElement, mode: str, env: BuildEnvironment, symbol: Symbol
431
+ ) -> None:
397
432
  signode += addnodes.desc_sig_punctuation('[', '[')
398
433
  self.expr.describe_signature(signode, mode, env, symbol)
399
434
  signode += addnodes.desc_sig_punctuation(']', ']')
@@ -403,8 +438,9 @@ class ASTPostfixInc(ASTPostfixOp):
403
438
  def _stringify(self, transform: StringifyTransform) -> str:
404
439
  return '++'
405
440
 
406
- def describe_signature(self, signode: TextElement, mode: str,
407
- env: BuildEnvironment, symbol: Symbol) -> None:
441
+ def describe_signature(
442
+ self, signode: TextElement, mode: str, env: BuildEnvironment, symbol: Symbol
443
+ ) -> None:
408
444
  signode += addnodes.desc_sig_operator('++', '++')
409
445
 
410
446
 
@@ -412,8 +448,9 @@ class ASTPostfixDec(ASTPostfixOp):
412
448
  def _stringify(self, transform: StringifyTransform) -> str:
413
449
  return '--'
414
450
 
415
- def describe_signature(self, signode: TextElement, mode: str,
416
- env: BuildEnvironment, symbol: Symbol) -> None:
451
+ def describe_signature(
452
+ self, signode: TextElement, mode: str, env: BuildEnvironment, symbol: Symbol
453
+ ) -> None:
417
454
  signode += addnodes.desc_sig_operator('--', '--')
418
455
 
419
456
 
@@ -432,8 +469,9 @@ class ASTPostfixMemberOfPointer(ASTPostfixOp):
432
469
  def _stringify(self, transform: StringifyTransform) -> str:
433
470
  return '->' + transform(self.name)
434
471
 
435
- def describe_signature(self, signode: TextElement, mode: str,
436
- env: BuildEnvironment, symbol: Symbol) -> None:
472
+ def describe_signature(
473
+ self, signode: TextElement, mode: str, env: BuildEnvironment, symbol: Symbol
474
+ ) -> None:
437
475
  signode += addnodes.desc_sig_operator('->', '->')
438
476
  self.name.describe_signature(signode, 'noneIsName', env, symbol)
439
477
 
@@ -452,10 +490,14 @@ class ASTPostfixExpr(ASTExpression):
452
490
  return hash((self.prefix, self.postFixes))
453
491
 
454
492
  def _stringify(self, transform: StringifyTransform) -> str:
455
- return ''.join([transform(self.prefix), *(transform(p) for p in self.postFixes)])
456
-
457
- def describe_signature(self, signode: TextElement, mode: str,
458
- env: BuildEnvironment, symbol: Symbol) -> None:
493
+ return ''.join([
494
+ transform(self.prefix),
495
+ *(transform(p) for p in self.postFixes),
496
+ ])
497
+
498
+ def describe_signature(
499
+ self, signode: TextElement, mode: str, env: BuildEnvironment, symbol: Symbol
500
+ ) -> None:
459
501
  self.prefix.describe_signature(signode, mode, env, symbol)
460
502
  for p in self.postFixes:
461
503
  p.describe_signature(signode, mode, env, symbol)
@@ -464,6 +506,7 @@ class ASTPostfixExpr(ASTExpression):
464
506
  # Unary expressions
465
507
  ################################################################################
466
508
 
509
+
467
510
  class ASTUnaryOpExpr(ASTExpression):
468
511
  def __init__(self, op: str, expr: ASTExpression) -> None:
469
512
  self.op = op
@@ -479,12 +522,13 @@ class ASTUnaryOpExpr(ASTExpression):
479
522
 
480
523
  def _stringify(self, transform: StringifyTransform) -> str:
481
524
  if self.op[0] in 'cn':
482
- return self.op + " " + transform(self.expr)
525
+ return self.op + ' ' + transform(self.expr)
483
526
  else:
484
527
  return self.op + transform(self.expr)
485
528
 
486
- def describe_signature(self, signode: TextElement, mode: str,
487
- env: BuildEnvironment, symbol: Symbol) -> None:
529
+ def describe_signature(
530
+ self, signode: TextElement, mode: str, env: BuildEnvironment, symbol: Symbol
531
+ ) -> None:
488
532
  if self.op[0] in 'cn':
489
533
  signode += addnodes.desc_sig_keyword(self.op, self.op)
490
534
  signode += addnodes.desc_sig_space()
@@ -506,10 +550,11 @@ class ASTSizeofType(ASTExpression):
506
550
  return hash(self.typ)
507
551
 
508
552
  def _stringify(self, transform: StringifyTransform) -> str:
509
- return "sizeof(" + transform(self.typ) + ")"
553
+ return 'sizeof(' + transform(self.typ) + ')'
510
554
 
511
- def describe_signature(self, signode: TextElement, mode: str,
512
- env: BuildEnvironment, symbol: Symbol) -> None:
555
+ def describe_signature(
556
+ self, signode: TextElement, mode: str, env: BuildEnvironment, symbol: Symbol
557
+ ) -> None:
513
558
  signode += addnodes.desc_sig_keyword('sizeof', 'sizeof')
514
559
  signode += addnodes.desc_sig_punctuation('(', '(')
515
560
  self.typ.describe_signature(signode, mode, env, symbol)
@@ -529,10 +574,11 @@ class ASTSizeofExpr(ASTExpression):
529
574
  return hash(self.expr)
530
575
 
531
576
  def _stringify(self, transform: StringifyTransform) -> str:
532
- return "sizeof " + transform(self.expr)
577
+ return 'sizeof ' + transform(self.expr)
533
578
 
534
- def describe_signature(self, signode: TextElement, mode: str,
535
- env: BuildEnvironment, symbol: Symbol) -> None:
579
+ def describe_signature(
580
+ self, signode: TextElement, mode: str, env: BuildEnvironment, symbol: Symbol
581
+ ) -> None:
536
582
  signode += addnodes.desc_sig_keyword('sizeof', 'sizeof')
537
583
  signode += addnodes.desc_sig_space()
538
584
  self.expr.describe_signature(signode, mode, env, symbol)
@@ -551,10 +597,11 @@ class ASTAlignofExpr(ASTExpression):
551
597
  return hash(self.typ)
552
598
 
553
599
  def _stringify(self, transform: StringifyTransform) -> str:
554
- return "alignof(" + transform(self.typ) + ")"
600
+ return 'alignof(' + transform(self.typ) + ')'
555
601
 
556
- def describe_signature(self, signode: TextElement, mode: str,
557
- env: BuildEnvironment, symbol: Symbol) -> None:
602
+ def describe_signature(
603
+ self, signode: TextElement, mode: str, env: BuildEnvironment, symbol: Symbol
604
+ ) -> None:
558
605
  signode += addnodes.desc_sig_keyword('alignof', 'alignof')
559
606
  signode += addnodes.desc_sig_punctuation('(', '(')
560
607
  self.typ.describe_signature(signode, mode, env, symbol)
@@ -564,6 +611,7 @@ class ASTAlignofExpr(ASTExpression):
564
611
  # Other expressions
565
612
  ################################################################################
566
613
 
614
+
567
615
  class ASTCastExpr(ASTExpression):
568
616
  def __init__(self, typ: ASTType, expr: ASTExpression) -> None:
569
617
  self.typ = typ
@@ -572,23 +620,23 @@ class ASTCastExpr(ASTExpression):
572
620
  def __eq__(self, other: object) -> bool:
573
621
  if not isinstance(other, ASTCastExpr):
574
622
  return NotImplemented
575
- return (
576
- self.typ == other.typ
577
- and self.expr == other.expr
578
- )
623
+ return self.typ == other.typ and self.expr == other.expr
579
624
 
580
625
  def __hash__(self) -> int:
581
626
  return hash((self.typ, self.expr))
582
627
 
583
628
  def _stringify(self, transform: StringifyTransform) -> str:
584
629
  res = ['(']
585
- res.append(transform(self.typ))
586
- res.append(')')
587
- res.append(transform(self.expr))
630
+ res.extend((
631
+ transform(self.typ),
632
+ ')',
633
+ transform(self.expr),
634
+ ))
588
635
  return ''.join(res)
589
636
 
590
- def describe_signature(self, signode: TextElement, mode: str,
591
- env: BuildEnvironment, symbol: Symbol) -> None:
637
+ def describe_signature(
638
+ self, signode: TextElement, mode: str, env: BuildEnvironment, symbol: Symbol
639
+ ) -> None:
592
640
  signode += addnodes.desc_sig_punctuation('(', '(')
593
641
  self.typ.describe_signature(signode, mode, env, symbol)
594
642
  signode += addnodes.desc_sig_punctuation(')', ')')
@@ -605,26 +653,25 @@ class ASTBinOpExpr(ASTBase):
605
653
  def __eq__(self, other: object) -> bool:
606
654
  if not isinstance(other, ASTBinOpExpr):
607
655
  return NotImplemented
608
- return (
609
- self.exprs == other.exprs
610
- and self.ops == other.ops
611
- )
656
+ return self.exprs == other.exprs and self.ops == other.ops
612
657
 
613
658
  def __hash__(self) -> int:
614
659
  return hash((self.exprs, self.ops))
615
660
 
616
661
  def _stringify(self, transform: StringifyTransform) -> str:
617
- res = []
618
- res.append(transform(self.exprs[0]))
662
+ res = [transform(self.exprs[0])]
619
663
  for i in range(1, len(self.exprs)):
620
- res.append(' ')
621
- res.append(self.ops[i - 1])
622
- res.append(' ')
623
- res.append(transform(self.exprs[i]))
664
+ res.extend((
665
+ ' ',
666
+ self.ops[i - 1],
667
+ ' ',
668
+ transform(self.exprs[i]),
669
+ ))
624
670
  return ''.join(res)
625
671
 
626
- def describe_signature(self, signode: TextElement, mode: str,
627
- env: BuildEnvironment, symbol: Symbol) -> None:
672
+ def describe_signature(
673
+ self, signode: TextElement, mode: str, env: BuildEnvironment, symbol: Symbol
674
+ ) -> None:
628
675
  self.exprs[0].describe_signature(signode, mode, env, symbol)
629
676
  for i in range(1, len(self.exprs)):
630
677
  signode += addnodes.desc_sig_space()
@@ -647,26 +694,25 @@ class ASTAssignmentExpr(ASTExpression):
647
694
  def __eq__(self, other: object) -> bool:
648
695
  if not isinstance(other, ASTAssignmentExpr):
649
696
  return NotImplemented
650
- return (
651
- self.exprs == other.exprs
652
- and self.ops == other.ops
653
- )
697
+ return self.exprs == other.exprs and self.ops == other.ops
654
698
 
655
699
  def __hash__(self) -> int:
656
700
  return hash((self.exprs, self.ops))
657
701
 
658
702
  def _stringify(self, transform: StringifyTransform) -> str:
659
- res = []
660
- res.append(transform(self.exprs[0]))
703
+ res = [transform(self.exprs[0])]
661
704
  for i in range(1, len(self.exprs)):
662
- res.append(' ')
663
- res.append(self.ops[i - 1])
664
- res.append(' ')
665
- res.append(transform(self.exprs[i]))
705
+ res.extend((
706
+ ' ',
707
+ self.ops[i - 1],
708
+ ' ',
709
+ transform(self.exprs[i]),
710
+ ))
666
711
  return ''.join(res)
667
712
 
668
- def describe_signature(self, signode: TextElement, mode: str,
669
- env: BuildEnvironment, symbol: Symbol) -> None:
713
+ def describe_signature(
714
+ self, signode: TextElement, mode: str, env: BuildEnvironment, symbol: Symbol
715
+ ) -> None:
670
716
  self.exprs[0].describe_signature(signode, mode, env, symbol)
671
717
  for i in range(1, len(self.exprs)):
672
718
  signode += addnodes.desc_sig_space()
@@ -697,8 +743,9 @@ class ASTFallbackExpr(ASTExpression):
697
743
  def get_id(self, version: int) -> str:
698
744
  return str(self.expr)
699
745
 
700
- def describe_signature(self, signode: TextElement, mode: str,
701
- env: BuildEnvironment, symbol: Symbol) -> None:
746
+ def describe_signature(
747
+ self, signode: TextElement, mode: str, env: BuildEnvironment, symbol: Symbol
748
+ ) -> None:
702
749
  signode += nodes.literal(self.expr, self.expr)
703
750
 
704
751
 
@@ -706,6 +753,7 @@ class ASTFallbackExpr(ASTExpression):
706
753
  # Types
707
754
  ################################################################################
708
755
 
756
+
709
757
  class ASTTrailingTypeSpec(ASTBase):
710
758
  pass
711
759
 
@@ -726,8 +774,9 @@ class ASTTrailingTypeSpecFundamental(ASTTrailingTypeSpec):
726
774
  def _stringify(self, transform: StringifyTransform) -> str:
727
775
  return ' '.join(self.names)
728
776
 
729
- def describe_signature(self, signode: TextElement, mode: str,
730
- env: BuildEnvironment, symbol: Symbol) -> None:
777
+ def describe_signature(
778
+ self, signode: TextElement, mode: str, env: BuildEnvironment, symbol: Symbol
779
+ ) -> None:
731
780
  first = True
732
781
  for n in self.names:
733
782
  if not first:
@@ -745,10 +794,7 @@ class ASTTrailingTypeSpecName(ASTTrailingTypeSpec):
745
794
  def __eq__(self, other: object) -> bool:
746
795
  if not isinstance(other, ASTTrailingTypeSpecName):
747
796
  return NotImplemented
748
- return (
749
- self.prefix == other.prefix
750
- and self.nestedName == other.nestedName
751
- )
797
+ return self.prefix == other.prefix and self.nestedName == other.nestedName
752
798
 
753
799
  def __hash__(self) -> int:
754
800
  return hash((self.prefix, self.nestedName))
@@ -758,15 +804,15 @@ class ASTTrailingTypeSpecName(ASTTrailingTypeSpec):
758
804
  return self.nestedName
759
805
 
760
806
  def _stringify(self, transform: StringifyTransform) -> str:
761
- res = []
807
+ res: list[str] = []
762
808
  if self.prefix:
763
- res.append(self.prefix)
764
- res.append(' ')
809
+ res.extend((self.prefix, ' '))
765
810
  res.append(transform(self.nestedName))
766
811
  return ''.join(res)
767
812
 
768
- def describe_signature(self, signode: TextElement, mode: str,
769
- env: BuildEnvironment, symbol: Symbol) -> None:
813
+ def describe_signature(
814
+ self, signode: TextElement, mode: str, env: BuildEnvironment, symbol: Symbol
815
+ ) -> None:
770
816
  if self.prefix:
771
817
  signode += addnodes.desc_sig_keyword(self.prefix, self.prefix)
772
818
  signode += addnodes.desc_sig_space()
@@ -796,8 +842,9 @@ class ASTFunctionParameter(ASTBase):
796
842
  else:
797
843
  return transform(self.arg)
798
844
 
799
- def describe_signature(self, signode: Any, mode: str,
800
- env: BuildEnvironment, symbol: Symbol) -> None:
845
+ def describe_signature(
846
+ self, signode: Any, mode: str, env: BuildEnvironment, symbol: Symbol
847
+ ) -> None:
801
848
  verify_description_mode(mode)
802
849
  if self.ellipsis:
803
850
  signode += addnodes.desc_sig_punctuation('...', '...')
@@ -806,7 +853,9 @@ class ASTFunctionParameter(ASTBase):
806
853
 
807
854
 
808
855
  class ASTParameters(ASTBase):
809
- def __init__(self, args: list[ASTFunctionParameter], attrs: ASTAttributeList) -> None:
856
+ def __init__(
857
+ self, args: list[ASTFunctionParameter], attrs: ASTAttributeList
858
+ ) -> None:
810
859
  self.args = args
811
860
  self.attrs = attrs
812
861
 
@@ -823,8 +872,7 @@ class ASTParameters(ASTBase):
823
872
  return self.args
824
873
 
825
874
  def _stringify(self, transform: StringifyTransform) -> str:
826
- res = []
827
- res.append('(')
875
+ res = ['(']
828
876
  first = True
829
877
  for a in self.args:
830
878
  if not first:
@@ -833,12 +881,12 @@ class ASTParameters(ASTBase):
833
881
  res.append(str(a))
834
882
  res.append(')')
835
883
  if len(self.attrs) != 0:
836
- res.append(' ')
837
- res.append(transform(self.attrs))
884
+ res.extend((' ', transform(self.attrs)))
838
885
  return ''.join(res)
839
886
 
840
- def describe_signature(self, signode: TextElement, mode: str,
841
- env: BuildEnvironment, symbol: Symbol) -> None:
887
+ def describe_signature(
888
+ self, signode: TextElement, mode: str, env: BuildEnvironment, symbol: Symbol
889
+ ) -> None:
842
890
  verify_description_mode(mode)
843
891
  multi_line_parameter_list = False
844
892
  test_node: Element = signode
@@ -846,7 +894,9 @@ class ASTParameters(ASTBase):
846
894
  if not isinstance(test_node, addnodes.desc_signature):
847
895
  test_node = test_node.parent
848
896
  continue
849
- multi_line_parameter_list = test_node.get('multi_line_parameter_list', False)
897
+ multi_line_parameter_list = test_node.get(
898
+ 'multi_line_parameter_list', False
899
+ )
850
900
  break
851
901
 
852
902
  # only use the desc_parameterlist for the outer list, not for inner lists
@@ -875,8 +925,16 @@ class ASTParameters(ASTBase):
875
925
 
876
926
 
877
927
  class ASTDeclSpecsSimple(ASTBaseBase):
878
- def __init__(self, storage: str, threadLocal: str, inline: bool,
879
- restrict: bool, volatile: bool, const: bool, attrs: ASTAttributeList) -> None:
928
+ def __init__(
929
+ self,
930
+ storage: str,
931
+ threadLocal: str,
932
+ inline: bool,
933
+ restrict: bool,
934
+ volatile: bool,
935
+ const: bool,
936
+ attrs: ASTAttributeList,
937
+ ) -> None:
880
938
  self.storage = storage
881
939
  self.threadLocal = threadLocal
882
940
  self.inline = inline
@@ -912,13 +970,15 @@ class ASTDeclSpecsSimple(ASTBaseBase):
912
970
  def mergeWith(self, other: ASTDeclSpecsSimple) -> ASTDeclSpecsSimple:
913
971
  if not other:
914
972
  return self
915
- return ASTDeclSpecsSimple(self.storage or other.storage,
916
- self.threadLocal or other.threadLocal,
917
- self.inline or other.inline,
918
- self.volatile or other.volatile,
919
- self.const or other.const,
920
- self.restrict or other.restrict,
921
- self.attrs + other.attrs)
973
+ return ASTDeclSpecsSimple(
974
+ self.storage or other.storage,
975
+ self.threadLocal or other.threadLocal,
976
+ self.inline or other.inline,
977
+ self.volatile or other.volatile,
978
+ self.const or other.const,
979
+ self.restrict or other.restrict,
980
+ self.attrs + other.attrs,
981
+ )
922
982
 
923
983
  def _stringify(self, transform: StringifyTransform) -> str:
924
984
  res: list[str] = []
@@ -946,9 +1006,9 @@ class ASTDeclSpecsSimple(ASTBaseBase):
946
1006
 
947
1007
  if len(modifiers) != 0 and len(self.attrs) != 0:
948
1008
  modifiers.append(addnodes.desc_sig_space())
949
- tempNode = nodes.TextElement()
950
- self.attrs.describe_signature(tempNode)
951
- modifiers.extend(tempNode.children)
1009
+ temp_node = nodes.TextElement()
1010
+ self.attrs.describe_signature(temp_node)
1011
+ modifiers.extend(temp_node.children)
952
1012
  if self.storage:
953
1013
  _add(modifiers, self.storage)
954
1014
  if self.threadLocal:
@@ -964,10 +1024,13 @@ class ASTDeclSpecsSimple(ASTBaseBase):
964
1024
 
965
1025
 
966
1026
  class ASTDeclSpecs(ASTBase):
967
- def __init__(self, outer: str,
968
- leftSpecs: ASTDeclSpecsSimple,
969
- rightSpecs: ASTDeclSpecsSimple,
970
- trailing: ASTTrailingTypeSpec) -> None:
1027
+ def __init__(
1028
+ self,
1029
+ outer: str,
1030
+ leftSpecs: ASTDeclSpecsSimple,
1031
+ rightSpecs: ASTDeclSpecsSimple,
1032
+ trailing: ASTTrailingTypeSpec,
1033
+ ) -> None:
971
1034
  # leftSpecs and rightSpecs are used for output
972
1035
  # allSpecs are used for id generation TODO: remove?
973
1036
  self.outer = outer
@@ -1001,17 +1064,18 @@ class ASTDeclSpecs(ASTBase):
1001
1064
  res.append(l)
1002
1065
  if self.trailingTypeSpec:
1003
1066
  if len(res) > 0:
1004
- res.append(" ")
1067
+ res.append(' ')
1005
1068
  res.append(transform(self.trailingTypeSpec))
1006
1069
  r = str(self.rightSpecs)
1007
1070
  if len(r) > 0:
1008
1071
  if len(res) > 0:
1009
- res.append(" ")
1072
+ res.append(' ')
1010
1073
  res.append(r)
1011
- return "".join(res)
1074
+ return ''.join(res)
1012
1075
 
1013
- def describe_signature(self, signode: TextElement, mode: str,
1014
- env: BuildEnvironment, symbol: Symbol) -> None:
1076
+ def describe_signature(
1077
+ self, signode: TextElement, mode: str, env: BuildEnvironment, symbol: Symbol
1078
+ ) -> None:
1015
1079
  verify_description_mode(mode)
1016
1080
  modifiers: list[Node] = []
1017
1081
 
@@ -1022,8 +1086,7 @@ class ASTDeclSpecs(ASTBase):
1022
1086
  if self.trailingTypeSpec:
1023
1087
  if len(modifiers) > 0:
1024
1088
  signode += addnodes.desc_sig_space()
1025
- self.trailingTypeSpec.describe_signature(signode, mode, env,
1026
- symbol=symbol)
1089
+ self.trailingTypeSpec.describe_signature(signode, mode, env, symbol=symbol)
1027
1090
  modifiers = []
1028
1091
  self.rightSpecs.describe_signature(modifiers)
1029
1092
  if len(modifiers) > 0:
@@ -1035,9 +1098,17 @@ class ASTDeclSpecs(ASTBase):
1035
1098
  # Declarator
1036
1099
  ################################################################################
1037
1100
 
1101
+
1038
1102
  class ASTArray(ASTBase):
1039
- def __init__(self, static: bool, const: bool, volatile: bool, restrict: bool,
1040
- vla: bool, size: ASTExpression) -> None:
1103
+ def __init__(
1104
+ self,
1105
+ static: bool,
1106
+ const: bool,
1107
+ volatile: bool,
1108
+ restrict: bool,
1109
+ vla: bool,
1110
+ size: ASTExpression,
1111
+ ) -> None:
1041
1112
  self.static = static
1042
1113
  self.const = const
1043
1114
  self.volatile = volatile
@@ -1087,30 +1158,31 @@ class ASTArray(ASTBase):
1087
1158
  el.append(transform(self.size))
1088
1159
  return '[' + ' '.join(el) + ']'
1089
1160
 
1090
- def describe_signature(self, signode: TextElement, mode: str,
1091
- env: BuildEnvironment, symbol: Symbol) -> None:
1161
+ def describe_signature(
1162
+ self, signode: TextElement, mode: str, env: BuildEnvironment, symbol: Symbol
1163
+ ) -> None:
1092
1164
  verify_description_mode(mode)
1093
1165
  signode += addnodes.desc_sig_punctuation('[', '[')
1094
- addSpace = False
1166
+ add_space = False
1095
1167
 
1096
1168
  def _add(signode: TextElement, text: str) -> bool:
1097
- if addSpace:
1169
+ if add_space:
1098
1170
  signode += addnodes.desc_sig_space()
1099
1171
  signode += addnodes.desc_sig_keyword(text, text)
1100
1172
  return True
1101
1173
 
1102
1174
  if self.static:
1103
- addSpace = _add(signode, 'static')
1175
+ add_space = _add(signode, 'static')
1104
1176
  if self.restrict:
1105
- addSpace = _add(signode, 'restrict')
1177
+ add_space = _add(signode, 'restrict')
1106
1178
  if self.volatile:
1107
- addSpace = _add(signode, 'volatile')
1179
+ add_space = _add(signode, 'volatile')
1108
1180
  if self.const:
1109
- addSpace = _add(signode, 'const')
1181
+ add_space = _add(signode, 'const')
1110
1182
  if self.vla:
1111
1183
  signode += addnodes.desc_sig_punctuation('*', '*')
1112
1184
  elif self.size:
1113
- if addSpace:
1185
+ if add_space:
1114
1186
  signode += addnodes.desc_sig_space()
1115
1187
  self.size.describe_signature(signode, 'markType', env, symbol)
1116
1188
  signode += addnodes.desc_sig_punctuation(']', ']')
@@ -1130,8 +1202,9 @@ class ASTDeclarator(ASTBase):
1130
1202
 
1131
1203
 
1132
1204
  class ASTDeclaratorNameParam(ASTDeclarator):
1133
- def __init__(self, declId: ASTNestedName,
1134
- arrayOps: list[ASTArray], param: ASTParameters) -> None:
1205
+ def __init__(
1206
+ self, declId: ASTNestedName, arrayOps: list[ASTArray], param: ASTParameters
1207
+ ) -> None:
1135
1208
  self.declId = declId
1136
1209
  self.arrayOps = arrayOps
1137
1210
  self.param = param
@@ -1170,8 +1243,9 @@ class ASTDeclaratorNameParam(ASTDeclarator):
1170
1243
  res.append(transform(self.param))
1171
1244
  return ''.join(res)
1172
1245
 
1173
- def describe_signature(self, signode: TextElement, mode: str,
1174
- env: BuildEnvironment, symbol: Symbol) -> None:
1246
+ def describe_signature(
1247
+ self, signode: TextElement, mode: str, env: BuildEnvironment, symbol: Symbol
1248
+ ) -> None:
1175
1249
  verify_description_mode(mode)
1176
1250
  if self.declId:
1177
1251
  self.declId.describe_signature(signode, mode, env, symbol)
@@ -1207,12 +1281,12 @@ class ASTDeclaratorNameBitField(ASTDeclarator):
1207
1281
  res = []
1208
1282
  if self.declId:
1209
1283
  res.append(transform(self.declId))
1210
- res.append(" : ")
1211
- res.append(transform(self.size))
1284
+ res.extend((' : ', transform(self.size)))
1212
1285
  return ''.join(res)
1213
1286
 
1214
- def describe_signature(self, signode: TextElement, mode: str,
1215
- env: BuildEnvironment, symbol: Symbol) -> None:
1287
+ def describe_signature(
1288
+ self, signode: TextElement, mode: str, env: BuildEnvironment, symbol: Symbol
1289
+ ) -> None:
1216
1290
  verify_description_mode(mode)
1217
1291
  if self.declId:
1218
1292
  self.declId.describe_signature(signode, mode, env, symbol)
@@ -1223,8 +1297,14 @@ class ASTDeclaratorNameBitField(ASTDeclarator):
1223
1297
 
1224
1298
 
1225
1299
  class ASTDeclaratorPtr(ASTDeclarator):
1226
- def __init__(self, next: ASTDeclarator, restrict: bool, volatile: bool, const: bool,
1227
- attrs: ASTAttributeList) -> None:
1300
+ def __init__(
1301
+ self,
1302
+ next: ASTDeclarator,
1303
+ restrict: bool,
1304
+ volatile: bool,
1305
+ const: bool,
1306
+ attrs: ASTAttributeList,
1307
+ ) -> None:
1228
1308
  assert next
1229
1309
  self.next = next
1230
1310
  self.restrict = restrict
@@ -1255,13 +1335,16 @@ class ASTDeclaratorPtr(ASTDeclarator):
1255
1335
  return self.next.function_params
1256
1336
 
1257
1337
  def require_space_after_declSpecs(self) -> bool:
1258
- return self.const or self.volatile or self.restrict or \
1259
- len(self.attrs) > 0 or \
1260
- self.next.require_space_after_declSpecs()
1338
+ return (
1339
+ self.const
1340
+ or self.volatile
1341
+ or self.restrict
1342
+ or len(self.attrs) > 0
1343
+ or self.next.require_space_after_declSpecs()
1344
+ )
1261
1345
 
1262
1346
  def _stringify(self, transform: StringifyTransform) -> str:
1263
- res = ['*']
1264
- res.append(transform(self.attrs))
1347
+ res = ['*', transform(self.attrs)]
1265
1348
  if len(self.attrs) != 0 and (self.restrict or self.volatile or self.const):
1266
1349
  res.append(' ')
1267
1350
  if self.restrict:
@@ -1280,8 +1363,9 @@ class ASTDeclaratorPtr(ASTDeclarator):
1280
1363
  res.append(transform(self.next))
1281
1364
  return ''.join(res)
1282
1365
 
1283
- def describe_signature(self, signode: TextElement, mode: str,
1284
- env: BuildEnvironment, symbol: Symbol) -> None:
1366
+ def describe_signature(
1367
+ self, signode: TextElement, mode: str, env: BuildEnvironment, symbol: Symbol
1368
+ ) -> None:
1285
1369
  verify_description_mode(mode)
1286
1370
  signode += addnodes.desc_sig_punctuation('*', '*')
1287
1371
  self.attrs.describe_signature(signode)
@@ -1336,23 +1420,27 @@ class ASTDeclaratorParen(ASTDeclarator):
1336
1420
 
1337
1421
  def _stringify(self, transform: StringifyTransform) -> str:
1338
1422
  res = ['(']
1339
- res.append(transform(self.inner))
1340
- res.append(')')
1341
- res.append(transform(self.next))
1423
+ res.extend((
1424
+ transform(self.inner),
1425
+ ')',
1426
+ transform(self.next),
1427
+ ))
1342
1428
  return ''.join(res)
1343
1429
 
1344
- def describe_signature(self, signode: TextElement, mode: str,
1345
- env: BuildEnvironment, symbol: Symbol) -> None:
1430
+ def describe_signature(
1431
+ self, signode: TextElement, mode: str, env: BuildEnvironment, symbol: Symbol
1432
+ ) -> None:
1346
1433
  verify_description_mode(mode)
1347
1434
  signode += addnodes.desc_sig_punctuation('(', '(')
1348
1435
  self.inner.describe_signature(signode, mode, env, symbol)
1349
1436
  signode += addnodes.desc_sig_punctuation(')', ')')
1350
- self.next.describe_signature(signode, "noneIsName", env, symbol)
1437
+ self.next.describe_signature(signode, 'noneIsName', env, symbol)
1351
1438
 
1352
1439
 
1353
1440
  # Initializer
1354
1441
  ################################################################################
1355
1442
 
1443
+
1356
1444
  class ASTParenExprList(ASTBaseParenExprList):
1357
1445
  def __init__(self, exprs: list[ASTExpression]) -> None:
1358
1446
  self.exprs = exprs
@@ -1369,8 +1457,9 @@ class ASTParenExprList(ASTBaseParenExprList):
1369
1457
  exprs = [transform(e) for e in self.exprs]
1370
1458
  return '(%s)' % ', '.join(exprs)
1371
1459
 
1372
- def describe_signature(self, signode: TextElement, mode: str,
1373
- env: BuildEnvironment, symbol: Symbol) -> None:
1460
+ def describe_signature(
1461
+ self, signode: TextElement, mode: str, env: BuildEnvironment, symbol: Symbol
1462
+ ) -> None:
1374
1463
  verify_description_mode(mode)
1375
1464
  signode += addnodes.desc_sig_punctuation('(', '(')
1376
1465
  first = True
@@ -1399,11 +1488,12 @@ class ASTBracedInitList(ASTBase):
1399
1488
 
1400
1489
  def _stringify(self, transform: StringifyTransform) -> str:
1401
1490
  exprs = ', '.join(transform(e) for e in self.exprs)
1402
- trailingComma = ',' if self.trailingComma else ''
1403
- return f'{{{exprs}{trailingComma}}}'
1491
+ trailing_comma = ',' if self.trailingComma else ''
1492
+ return f'{{{exprs}{trailing_comma}}}'
1404
1493
 
1405
- def describe_signature(self, signode: TextElement, mode: str,
1406
- env: BuildEnvironment, symbol: Symbol) -> None:
1494
+ def describe_signature(
1495
+ self, signode: TextElement, mode: str, env: BuildEnvironment, symbol: Symbol
1496
+ ) -> None:
1407
1497
  verify_description_mode(mode)
1408
1498
  signode += addnodes.desc_sig_punctuation('{', '{')
1409
1499
  first = True
@@ -1420,8 +1510,9 @@ class ASTBracedInitList(ASTBase):
1420
1510
 
1421
1511
 
1422
1512
  class ASTInitializer(ASTBase):
1423
- def __init__(self, value: ASTBracedInitList | ASTExpression,
1424
- hasAssign: bool = True) -> None:
1513
+ def __init__(
1514
+ self, value: ASTBracedInitList | ASTExpression, hasAssign: bool = True
1515
+ ) -> None:
1425
1516
  self.value = value
1426
1517
  self.hasAssign = hasAssign
1427
1518
 
@@ -1440,8 +1531,9 @@ class ASTInitializer(ASTBase):
1440
1531
  else:
1441
1532
  return val
1442
1533
 
1443
- def describe_signature(self, signode: TextElement, mode: str,
1444
- env: BuildEnvironment, symbol: Symbol) -> None:
1534
+ def describe_signature(
1535
+ self, signode: TextElement, mode: str, env: BuildEnvironment, symbol: Symbol
1536
+ ) -> None:
1445
1537
  verify_description_mode(mode)
1446
1538
  if self.hasAssign:
1447
1539
  signode += addnodes.desc_sig_space()
@@ -1478,9 +1570,9 @@ class ASTType(ASTBase):
1478
1570
 
1479
1571
  def _stringify(self, transform: StringifyTransform) -> str:
1480
1572
  res = []
1481
- declSpecs = transform(self.declSpecs)
1482
- res.append(declSpecs)
1483
- if self.decl.require_space_after_declSpecs() and len(declSpecs) > 0:
1573
+ decl_specs = transform(self.declSpecs)
1574
+ res.append(decl_specs)
1575
+ if self.decl.require_space_after_declSpecs() and len(decl_specs) > 0:
1484
1576
  res.append(' ')
1485
1577
  res.append(transform(self.decl))
1486
1578
  return ''.join(res)
@@ -1491,12 +1583,12 @@ class ASTType(ASTBase):
1491
1583
  else:
1492
1584
  return 'type'
1493
1585
 
1494
- def describe_signature(self, signode: TextElement, mode: str,
1495
- env: BuildEnvironment, symbol: Symbol) -> None:
1586
+ def describe_signature(
1587
+ self, signode: TextElement, mode: str, env: BuildEnvironment, symbol: Symbol
1588
+ ) -> None:
1496
1589
  verify_description_mode(mode)
1497
1590
  self.declSpecs.describe_signature(signode, 'markType', env, symbol)
1498
- if (self.decl.require_space_after_declSpecs() and
1499
- len(str(self.declSpecs)) > 0):
1591
+ if self.decl.require_space_after_declSpecs() and len(str(self.declSpecs)) > 0:
1500
1592
  signode += addnodes.desc_sig_space()
1501
1593
  # for parameters that don't really declare new names we get 'markType',
1502
1594
  # this should not be propagated, but be 'noneIsName'.
@@ -1526,14 +1618,14 @@ class ASTTypeWithInit(ASTBase):
1526
1618
  return self.type.get_id(version, objectType, symbol)
1527
1619
 
1528
1620
  def _stringify(self, transform: StringifyTransform) -> str:
1529
- res = []
1530
- res.append(transform(self.type))
1621
+ res = [transform(self.type)]
1531
1622
  if self.init:
1532
1623
  res.append(transform(self.init))
1533
1624
  return ''.join(res)
1534
1625
 
1535
- def describe_signature(self, signode: TextElement, mode: str,
1536
- env: BuildEnvironment, symbol: Symbol) -> None:
1626
+ def describe_signature(
1627
+ self, signode: TextElement, mode: str, env: BuildEnvironment, symbol: Symbol
1628
+ ) -> None:
1537
1629
  verify_description_mode(mode)
1538
1630
  self.type.describe_signature(signode, mode, env, symbol)
1539
1631
  if self.init:
@@ -1541,8 +1633,9 @@ class ASTTypeWithInit(ASTBase):
1541
1633
 
1542
1634
 
1543
1635
  class ASTMacroParameter(ASTBase):
1544
- def __init__(self, arg: ASTNestedName | None, ellipsis: bool = False,
1545
- variadic: bool = False) -> None:
1636
+ def __init__(
1637
+ self, arg: ASTNestedName | None, ellipsis: bool = False, variadic: bool = False
1638
+ ) -> None:
1546
1639
  self.arg = arg
1547
1640
  self.ellipsis = ellipsis
1548
1641
  self.variadic = variadic
@@ -1567,8 +1660,9 @@ class ASTMacroParameter(ASTBase):
1567
1660
  else:
1568
1661
  return transform(self.arg)
1569
1662
 
1570
- def describe_signature(self, signode: Any, mode: str,
1571
- env: BuildEnvironment, symbol: Symbol) -> None:
1663
+ def describe_signature(
1664
+ self, signode: Any, mode: str, env: BuildEnvironment, symbol: Symbol
1665
+ ) -> None:
1572
1666
  verify_description_mode(mode)
1573
1667
  if self.ellipsis:
1574
1668
  signode += addnodes.desc_sig_punctuation('...', '...')
@@ -1580,7 +1674,9 @@ class ASTMacroParameter(ASTBase):
1580
1674
 
1581
1675
 
1582
1676
  class ASTMacro(ASTBase):
1583
- def __init__(self, ident: ASTNestedName, args: list[ASTMacroParameter] | None) -> None:
1677
+ def __init__(
1678
+ self, ident: ASTNestedName, args: list[ASTMacroParameter] | None
1679
+ ) -> None:
1584
1680
  self.ident = ident
1585
1681
  self.args = args
1586
1682
 
@@ -1600,8 +1696,7 @@ class ASTMacro(ASTBase):
1600
1696
  return symbol.get_full_nested_name().get_id(version)
1601
1697
 
1602
1698
  def _stringify(self, transform: StringifyTransform) -> str:
1603
- res = []
1604
- res.append(transform(self.ident))
1699
+ res = [transform(self.ident)]
1605
1700
  if self.args is not None:
1606
1701
  res.append('(')
1607
1702
  first = True
@@ -1613,8 +1708,9 @@ class ASTMacro(ASTBase):
1613
1708
  res.append(')')
1614
1709
  return ''.join(res)
1615
1710
 
1616
- def describe_signature(self, signode: TextElement, mode: str,
1617
- env: BuildEnvironment, symbol: Symbol) -> None:
1711
+ def describe_signature(
1712
+ self, signode: TextElement, mode: str, env: BuildEnvironment, symbol: Symbol
1713
+ ) -> None:
1618
1714
  verify_description_mode(mode)
1619
1715
  self.ident.describe_signature(signode, mode, env, symbol)
1620
1716
  if self.args is None:
@@ -1645,8 +1741,9 @@ class ASTStruct(ASTBase):
1645
1741
  def _stringify(self, transform: StringifyTransform) -> str:
1646
1742
  return transform(self.name)
1647
1743
 
1648
- def describe_signature(self, signode: TextElement, mode: str,
1649
- env: BuildEnvironment, symbol: Symbol) -> None:
1744
+ def describe_signature(
1745
+ self, signode: TextElement, mode: str, env: BuildEnvironment, symbol: Symbol
1746
+ ) -> None:
1650
1747
  verify_description_mode(mode)
1651
1748
  self.name.describe_signature(signode, mode, env, symbol=symbol)
1652
1749
 
@@ -1669,8 +1766,9 @@ class ASTUnion(ASTBase):
1669
1766
  def _stringify(self, transform: StringifyTransform) -> str:
1670
1767
  return transform(self.name)
1671
1768
 
1672
- def describe_signature(self, signode: TextElement, mode: str,
1673
- env: BuildEnvironment, symbol: Symbol) -> None:
1769
+ def describe_signature(
1770
+ self, signode: TextElement, mode: str, env: BuildEnvironment, symbol: Symbol
1771
+ ) -> None:
1674
1772
  verify_description_mode(mode)
1675
1773
  self.name.describe_signature(signode, mode, env, symbol=symbol)
1676
1774
 
@@ -1693,15 +1791,17 @@ class ASTEnum(ASTBase):
1693
1791
  def _stringify(self, transform: StringifyTransform) -> str:
1694
1792
  return transform(self.name)
1695
1793
 
1696
- def describe_signature(self, signode: TextElement, mode: str,
1697
- env: BuildEnvironment, symbol: Symbol) -> None:
1794
+ def describe_signature(
1795
+ self, signode: TextElement, mode: str, env: BuildEnvironment, symbol: Symbol
1796
+ ) -> None:
1698
1797
  verify_description_mode(mode)
1699
1798
  self.name.describe_signature(signode, mode, env, symbol=symbol)
1700
1799
 
1701
1800
 
1702
1801
  class ASTEnumerator(ASTBase):
1703
- def __init__(self, name: ASTNestedName, init: ASTInitializer | None,
1704
- attrs: ASTAttributeList) -> None:
1802
+ def __init__(
1803
+ self, name: ASTNestedName, init: ASTInitializer | None, attrs: ASTAttributeList
1804
+ ) -> None:
1705
1805
  self.name = name
1706
1806
  self.init = init
1707
1807
  self.attrs = attrs
@@ -1722,17 +1822,16 @@ class ASTEnumerator(ASTBase):
1722
1822
  return symbol.get_full_nested_name().get_id(version)
1723
1823
 
1724
1824
  def _stringify(self, transform: StringifyTransform) -> str:
1725
- res = []
1726
- res.append(transform(self.name))
1825
+ res = [transform(self.name)]
1727
1826
  if len(self.attrs) != 0:
1728
- res.append(' ')
1729
- res.append(transform(self.attrs))
1827
+ res.extend((' ', transform(self.attrs)))
1730
1828
  if self.init:
1731
1829
  res.append(transform(self.init))
1732
1830
  return ''.join(res)
1733
1831
 
1734
- def describe_signature(self, signode: TextElement, mode: str,
1735
- env: BuildEnvironment, symbol: Symbol) -> None:
1832
+ def describe_signature(
1833
+ self, signode: TextElement, mode: str, env: BuildEnvironment, symbol: Symbol
1834
+ ) -> None:
1736
1835
  verify_description_mode(mode)
1737
1836
  self.name.describe_signature(signode, mode, env, symbol)
1738
1837
  if len(self.attrs) != 0:
@@ -1743,9 +1842,13 @@ class ASTEnumerator(ASTBase):
1743
1842
 
1744
1843
 
1745
1844
  class ASTDeclaration(ASTBaseBase):
1746
- def __init__(self, objectType: str, directiveType: str | None,
1747
- declaration: DeclarationType | ASTFunctionParameter,
1748
- semicolon: bool = False) -> None:
1845
+ def __init__(
1846
+ self,
1847
+ objectType: str,
1848
+ directiveType: str | None,
1849
+ declaration: DeclarationType | ASTFunctionParameter,
1850
+ semicolon: bool = False,
1851
+ ) -> None:
1749
1852
  self.objectType = objectType
1750
1853
  self.directiveType = directiveType
1751
1854
  self.declaration = declaration
@@ -1771,20 +1874,34 @@ class ASTDeclaration(ASTBaseBase):
1771
1874
  and self.enumeratorScopedSymbol == other.enumeratorScopedSymbol
1772
1875
  )
1773
1876
 
1877
+ def __hash__(self) -> int:
1878
+ return hash((
1879
+ self.objectType,
1880
+ self.directiveType,
1881
+ self.declaration,
1882
+ self.semicolon,
1883
+ self.symbol,
1884
+ self.enumeratorScopedSymbol,
1885
+ ))
1886
+
1774
1887
  def clone(self) -> ASTDeclaration:
1775
- return ASTDeclaration(self.objectType, self.directiveType,
1776
- self.declaration.clone(), self.semicolon)
1888
+ return ASTDeclaration(
1889
+ self.objectType,
1890
+ self.directiveType,
1891
+ self.declaration.clone(),
1892
+ self.semicolon,
1893
+ )
1777
1894
 
1778
1895
  @property
1779
1896
  def name(self) -> ASTNestedName:
1780
- decl = cast(DeclarationType, self.declaration)
1897
+ decl = cast('DeclarationType', self.declaration)
1781
1898
  return decl.name
1782
1899
 
1783
1900
  @property
1784
1901
  def function_params(self) -> list[ASTFunctionParameter] | None:
1785
1902
  if self.objectType != 'function':
1786
1903
  return None
1787
- decl = cast(ASTType, self.declaration)
1904
+ decl = cast('ASTType', self.declaration)
1788
1905
  return decl.function_params
1789
1906
 
1790
1907
  def get_id(self, version: int, prefixed: bool = True) -> str:
@@ -1807,40 +1924,45 @@ class ASTDeclaration(ASTBaseBase):
1807
1924
  res += ';'
1808
1925
  return res
1809
1926
 
1810
- def describe_signature(self, signode: TextElement, mode: str,
1811
- env: BuildEnvironment, options: dict[str, bool]) -> None:
1927
+ def describe_signature(
1928
+ self,
1929
+ signode: TextElement,
1930
+ mode: str,
1931
+ env: BuildEnvironment,
1932
+ options: dict[str, bool],
1933
+ ) -> None:
1812
1934
  verify_description_mode(mode)
1813
1935
  assert self.symbol
1814
1936
  # The caller of the domain added a desc_signature node.
1815
1937
  # Always enable multiline:
1816
1938
  signode['is_multiline'] = True
1817
1939
  # Put each line in a desc_signature_line node.
1818
- mainDeclNode = addnodes.desc_signature_line()
1819
- mainDeclNode.sphinx_line_type = 'declarator'
1820
- mainDeclNode['add_permalink'] = not self.symbol.isRedeclaration
1821
- signode += mainDeclNode
1940
+ main_decl_node = addnodes.desc_signature_line()
1941
+ main_decl_node.sphinx_line_type = 'declarator'
1942
+ main_decl_node['add_permalink'] = not self.symbol.isRedeclaration
1943
+ signode += main_decl_node
1822
1944
 
1823
1945
  if self.objectType in {'member', 'function', 'macro'}:
1824
1946
  pass
1825
1947
  elif self.objectType == 'struct':
1826
- mainDeclNode += addnodes.desc_sig_keyword('struct', 'struct')
1827
- mainDeclNode += addnodes.desc_sig_space()
1948
+ main_decl_node += addnodes.desc_sig_keyword('struct', 'struct')
1949
+ main_decl_node += addnodes.desc_sig_space()
1828
1950
  elif self.objectType == 'union':
1829
- mainDeclNode += addnodes.desc_sig_keyword('union', 'union')
1830
- mainDeclNode += addnodes.desc_sig_space()
1951
+ main_decl_node += addnodes.desc_sig_keyword('union', 'union')
1952
+ main_decl_node += addnodes.desc_sig_space()
1831
1953
  elif self.objectType == 'enum':
1832
- mainDeclNode += addnodes.desc_sig_keyword('enum', 'enum')
1833
- mainDeclNode += addnodes.desc_sig_space()
1954
+ main_decl_node += addnodes.desc_sig_keyword('enum', 'enum')
1955
+ main_decl_node += addnodes.desc_sig_space()
1834
1956
  elif self.objectType == 'enumerator':
1835
- mainDeclNode += addnodes.desc_sig_keyword('enumerator', 'enumerator')
1836
- mainDeclNode += addnodes.desc_sig_space()
1957
+ main_decl_node += addnodes.desc_sig_keyword('enumerator', 'enumerator')
1958
+ main_decl_node += addnodes.desc_sig_space()
1837
1959
  elif self.objectType == 'type':
1838
- decl = cast(ASTType, self.declaration)
1960
+ decl = cast('ASTType', self.declaration)
1839
1961
  prefix = decl.get_type_declaration_prefix()
1840
- mainDeclNode += addnodes.desc_sig_keyword(prefix, prefix)
1841
- mainDeclNode += addnodes.desc_sig_space()
1962
+ main_decl_node += addnodes.desc_sig_keyword(prefix, prefix)
1963
+ main_decl_node += addnodes.desc_sig_space()
1842
1964
  else:
1843
1965
  raise AssertionError
1844
- self.declaration.describe_signature(mainDeclNode, mode, env, self.symbol)
1966
+ self.declaration.describe_signature(main_decl_node, mode, env, self.symbol)
1845
1967
  if self.semicolon:
1846
- mainDeclNode += addnodes.desc_sig_punctuation(';', ';')
1968
+ main_decl_node += addnodes.desc_sig_punctuation(';', ';')