sphinx-autoapi 3.3.2__tar.gz → 3.4.0__tar.gz

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.
Files changed (132) hide show
  1. {sphinx_autoapi-3.3.2/sphinx_autoapi.egg-info → sphinx_autoapi-3.4.0}/PKG-INFO +22 -35
  2. {sphinx_autoapi-3.3.2 → sphinx_autoapi-3.4.0}/README.rst +7 -15
  3. {sphinx_autoapi-3.3.2 → sphinx_autoapi-3.4.0}/autoapi/__init__.py +2 -2
  4. {sphinx_autoapi-3.3.2 → sphinx_autoapi-3.4.0}/autoapi/_astroid_utils.py +66 -18
  5. {sphinx_autoapi-3.3.2 → sphinx_autoapi-3.4.0}/autoapi/_objects.py +4 -1
  6. {sphinx_autoapi-3.3.2 → sphinx_autoapi-3.4.0}/autoapi/_parser.py +65 -1
  7. {sphinx_autoapi-3.3.2 → sphinx_autoapi-3.4.0}/autoapi/templates/python/module.rst +2 -16
  8. {sphinx_autoapi-3.3.2 → sphinx_autoapi-3.4.0}/autoapi/templates/python/property.rst +1 -0
  9. sphinx_autoapi-3.4.0/pyproject.toml +103 -0
  10. sphinx_autoapi-3.3.2/CHANGELOG.rst +0 -771
  11. sphinx_autoapi-3.3.2/LICENSE.rst +0 -26
  12. sphinx_autoapi-3.3.2/MANIFEST.in +0 -4
  13. sphinx_autoapi-3.3.2/PKG-INFO +0 -158
  14. sphinx_autoapi-3.3.2/pyproject.toml +0 -54
  15. sphinx_autoapi-3.3.2/setup.cfg +0 -60
  16. sphinx_autoapi-3.3.2/setup.py +0 -2
  17. sphinx_autoapi-3.3.2/sphinx_autoapi.egg-info/SOURCES.txt +0 -130
  18. sphinx_autoapi-3.3.2/sphinx_autoapi.egg-info/dependency_links.txt +0 -1
  19. sphinx_autoapi-3.3.2/sphinx_autoapi.egg-info/requires.txt +0 -17
  20. sphinx_autoapi-3.3.2/sphinx_autoapi.egg-info/top_level.txt +0 -1
  21. sphinx_autoapi-3.3.2/tests/python/conftest.py +0 -66
  22. sphinx_autoapi-3.3.2/tests/python/pep695/conf.py +0 -18
  23. sphinx_autoapi-3.3.2/tests/python/pep695/example/example.py +0 -4
  24. sphinx_autoapi-3.3.2/tests/python/pep695/index.rst +0 -26
  25. sphinx_autoapi-3.3.2/tests/python/py310unionpipe/conf.py +0 -18
  26. sphinx_autoapi-3.3.2/tests/python/py310unionpipe/example/example.py +0 -18
  27. sphinx_autoapi-3.3.2/tests/python/py310unionpipe/index.rst +0 -26
  28. sphinx_autoapi-3.3.2/tests/python/py38positionalparams/conf.py +0 -17
  29. sphinx_autoapi-3.3.2/tests/python/py38positionalparams/example/example.py +0 -39
  30. sphinx_autoapi-3.3.2/tests/python/py38positionalparams/index.rst +0 -26
  31. sphinx_autoapi-3.3.2/tests/python/py3example/conf.py +0 -27
  32. sphinx_autoapi-3.3.2/tests/python/py3example/example/example.py +0 -217
  33. sphinx_autoapi-3.3.2/tests/python/py3example/example/example2.py +0 -2
  34. sphinx_autoapi-3.3.2/tests/python/py3example/index.rst +0 -25
  35. sphinx_autoapi-3.3.2/tests/python/py3implicitnamespace/conf.py +0 -18
  36. sphinx_autoapi-3.3.2/tests/python/py3implicitnamespace/index.rst +0 -26
  37. sphinx_autoapi-3.3.2/tests/python/py3implicitnamespace/namespace/example/__init__.py +0 -7
  38. sphinx_autoapi-3.3.2/tests/python/py3implicitnamespace/namespace/sibling/__init__.py +0 -8
  39. sphinx_autoapi-3.3.2/tests/python/py3implicitnamespace/namespace/sibling/sub_sibling.py +0 -8
  40. sphinx_autoapi-3.3.2/tests/python/pyannotationcommentsexample/conf.py +0 -18
  41. sphinx_autoapi-3.3.2/tests/python/pyannotationcommentsexample/example/example.py +0 -68
  42. sphinx_autoapi-3.3.2/tests/python/pyannotationcommentsexample/index.rst +0 -26
  43. sphinx_autoapi-3.3.2/tests/python/pyautodoc_typehints/conf.py +0 -28
  44. sphinx_autoapi-3.3.2/tests/python/pyautodoc_typehints/example/example.py +0 -8
  45. sphinx_autoapi-3.3.2/tests/python/pyautodoc_typehints/example/example2.py +0 -8
  46. sphinx_autoapi-3.3.2/tests/python/pyautodoc_typehints/index.rst +0 -25
  47. sphinx_autoapi-3.3.2/tests/python/pyemptyexample/conf.py +0 -26
  48. sphinx_autoapi-3.3.2/tests/python/pyemptyexample/index.rst +0 -25
  49. sphinx_autoapi-3.3.2/tests/python/pyexample/conf.py +0 -19
  50. sphinx_autoapi-3.3.2/tests/python/pyexample/example/example.py +0 -197
  51. sphinx_autoapi-3.3.2/tests/python/pyexample/index.rst +0 -22
  52. sphinx_autoapi-3.3.2/tests/python/pyexample/manualapi.rst +0 -9
  53. sphinx_autoapi-3.3.2/tests/python/pyexample/null.rst +0 -2
  54. sphinx_autoapi-3.3.2/tests/python/pyiexample/conf.py +0 -17
  55. sphinx_autoapi-3.3.2/tests/python/pyiexample/example/example.py +0 -2
  56. sphinx_autoapi-3.3.2/tests/python/pyiexample/example/example.pyi +0 -46
  57. sphinx_autoapi-3.3.2/tests/python/pyiexample/index.rst +0 -15
  58. sphinx_autoapi-3.3.2/tests/python/pyiexample2/conf.py +0 -16
  59. sphinx_autoapi-3.3.2/tests/python/pyiexample2/example/example.py +0 -8
  60. sphinx_autoapi-3.3.2/tests/python/pyiexample2/example/example.pyi +0 -2
  61. sphinx_autoapi-3.3.2/tests/python/pyiexample2/index.rst +0 -15
  62. sphinx_autoapi-3.3.2/tests/python/pyisubmoduleinit/conf.py +0 -16
  63. sphinx_autoapi-3.3.2/tests/python/pyisubmoduleinit/example/example.py +0 -0
  64. sphinx_autoapi-3.3.2/tests/python/pyisubmoduleinit/example/submodule_foo/__init__.pyi +0 -19
  65. sphinx_autoapi-3.3.2/tests/python/pyisubmoduleinit/index.rst +0 -15
  66. sphinx_autoapi-3.3.2/tests/python/pymovedconfpy/confpy/conf.py +0 -19
  67. sphinx_autoapi-3.3.2/tests/python/pymovedconfpy/example/example.py +0 -197
  68. sphinx_autoapi-3.3.2/tests/python/pymovedconfpy/index.rst +0 -22
  69. sphinx_autoapi-3.3.2/tests/python/pymovedconfpy/manualapi.rst +0 -9
  70. sphinx_autoapi-3.3.2/tests/python/pynorender/conf.py +0 -22
  71. sphinx_autoapi-3.3.2/tests/python/pynorender/example/_example.py +0 -7
  72. sphinx_autoapi-3.3.2/tests/python/pynorender/index.rst +0 -25
  73. sphinx_autoapi-3.3.2/tests/python/pypackagecomplex/complex/__init__.py +0 -12
  74. sphinx_autoapi-3.3.2/tests/python/pypackagecomplex/complex/_private_module.py +0 -11
  75. sphinx_autoapi-3.3.2/tests/python/pypackagecomplex/complex/binary_data.py +0 -1
  76. sphinx_autoapi-3.3.2/tests/python/pypackagecomplex/complex/foo.py +0 -68
  77. sphinx_autoapi-3.3.2/tests/python/pypackagecomplex/complex/submodule.py +0 -6
  78. sphinx_autoapi-3.3.2/tests/python/pypackagecomplex/complex/subpackage/__init__.py +0 -8
  79. sphinx_autoapi-3.3.2/tests/python/pypackagecomplex/complex/subpackage/submodule.py +0 -21
  80. sphinx_autoapi-3.3.2/tests/python/pypackagecomplex/complex/unicode_data.py +0 -1
  81. sphinx_autoapi-3.3.2/tests/python/pypackagecomplex/complex/wildall/__init__.py +0 -1
  82. sphinx_autoapi-3.3.2/tests/python/pypackagecomplex/complex/wildall/simple/__init__.py +0 -27
  83. sphinx_autoapi-3.3.2/tests/python/pypackagecomplex/complex/wildcard/__init__.py +0 -1
  84. sphinx_autoapi-3.3.2/tests/python/pypackagecomplex/complex/wildchain/__init__.py +0 -2
  85. sphinx_autoapi-3.3.2/tests/python/pypackagecomplex/complex/wildwildchain/__init__.py +0 -1
  86. sphinx_autoapi-3.3.2/tests/python/pypackagecomplex/conf.py +0 -17
  87. sphinx_autoapi-3.3.2/tests/python/pypackagecomplex/index.rst +0 -25
  88. sphinx_autoapi-3.3.2/tests/python/pypackageexample/conf.py +0 -18
  89. sphinx_autoapi-3.3.2/tests/python/pypackageexample/index.rst +0 -25
  90. sphinx_autoapi-3.3.2/tests/python/pypackageexample/package/__init__.py +0 -42
  91. sphinx_autoapi-3.3.2/tests/python/pypackageexample/package/_private_submodule.py +0 -6
  92. sphinx_autoapi-3.3.2/tests/python/pypackageexample/package/_private_subpackage/__init__.py +0 -13
  93. sphinx_autoapi-3.3.2/tests/python/pypackageexample/package/_private_subpackage/submodule.py +0 -41
  94. sphinx_autoapi-3.3.2/tests/python/pypackageexample/package/_private_subpackage/subpackage/__init__.py +0 -13
  95. sphinx_autoapi-3.3.2/tests/python/pypackageexample/package/_private_subpackage/subpackage/submodule.py +0 -41
  96. sphinx_autoapi-3.3.2/tests/python/pypackageexample/package/submodule.py +0 -84
  97. sphinx_autoapi-3.3.2/tests/python/pypackageexample/package/subpackage/__init__.py +0 -13
  98. sphinx_autoapi-3.3.2/tests/python/pypackageexample/package/subpackage/submodule.py +0 -41
  99. sphinx_autoapi-3.3.2/tests/python/pyskipexample/conf.py +0 -27
  100. sphinx_autoapi-3.3.2/tests/python/pyskipexample/example/example.py +0 -32
  101. sphinx_autoapi-3.3.2/tests/python/pyskipexample/index.rst +0 -25
  102. sphinx_autoapi-3.3.2/tests/python/pystdlib/conf.py +0 -24
  103. sphinx_autoapi-3.3.2/tests/python/pystdlib/index.rst +0 -25
  104. sphinx_autoapi-3.3.2/tests/python/pystdlib/stdlib/json.py +0 -9
  105. sphinx_autoapi-3.3.2/tests/python/pystdlib/stdlib/myast.py +0 -10
  106. sphinx_autoapi-3.3.2/tests/python/pystdlib/stdlib/myjson.py +0 -10
  107. sphinx_autoapi-3.3.2/tests/python/test_own_page_option.py +0 -997
  108. sphinx_autoapi-3.3.2/tests/python/test_parser.py +0 -126
  109. sphinx_autoapi-3.3.2/tests/python/test_pyintegration.py +0 -1360
  110. sphinx_autoapi-3.3.2/tests/templateexample/conf.py +0 -21
  111. sphinx_autoapi-3.3.2/tests/templateexample/example/example.py +0 -8
  112. sphinx_autoapi-3.3.2/tests/templateexample/index.rst +0 -26
  113. sphinx_autoapi-3.3.2/tests/templateexample/template_overrides/python/function.rst +0 -1
  114. sphinx_autoapi-3.3.2/tests/test_astroid_utils.py +0 -237
  115. sphinx_autoapi-3.3.2/tests/test_integration.py +0 -56
  116. sphinx_autoapi-3.3.2/tests/toctreeexample/conf.py +0 -18
  117. sphinx_autoapi-3.3.2/tests/toctreeexample/example/example.py +0 -8
  118. sphinx_autoapi-3.3.2/tests/toctreeexample/index.rst +0 -7
  119. {sphinx_autoapi-3.3.2 → sphinx_autoapi-3.4.0}/autoapi/_mapper.py +0 -0
  120. {sphinx_autoapi-3.3.2 → sphinx_autoapi-3.4.0}/autoapi/directives.py +0 -0
  121. {sphinx_autoapi-3.3.2 → sphinx_autoapi-3.4.0}/autoapi/documenters.py +0 -0
  122. {sphinx_autoapi-3.3.2 → sphinx_autoapi-3.4.0}/autoapi/extension.py +0 -0
  123. {sphinx_autoapi-3.3.2 → sphinx_autoapi-3.4.0}/autoapi/inheritance_diagrams.py +0 -0
  124. {sphinx_autoapi-3.3.2 → sphinx_autoapi-3.4.0}/autoapi/settings.py +0 -0
  125. {sphinx_autoapi-3.3.2 → sphinx_autoapi-3.4.0}/autoapi/templates/index.rst +0 -0
  126. {sphinx_autoapi-3.3.2 → sphinx_autoapi-3.4.0}/autoapi/templates/python/attribute.rst +0 -0
  127. {sphinx_autoapi-3.3.2 → sphinx_autoapi-3.4.0}/autoapi/templates/python/class.rst +0 -0
  128. {sphinx_autoapi-3.3.2 → sphinx_autoapi-3.4.0}/autoapi/templates/python/data.rst +0 -0
  129. {sphinx_autoapi-3.3.2 → sphinx_autoapi-3.4.0}/autoapi/templates/python/exception.rst +0 -0
  130. {sphinx_autoapi-3.3.2 → sphinx_autoapi-3.4.0}/autoapi/templates/python/function.rst +0 -0
  131. {sphinx_autoapi-3.3.2 → sphinx_autoapi-3.4.0}/autoapi/templates/python/method.rst +0 -0
  132. {sphinx_autoapi-3.3.2 → sphinx_autoapi-3.4.0}/autoapi/templates/python/package.rst +0 -0
@@ -1,15 +1,12 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.3
2
2
  Name: sphinx-autoapi
3
- Version: 3.3.2
3
+ Version: 3.4.0
4
4
  Summary: Sphinx API documentation generator
5
- Home-page: http://github.com/readthedocs/sphinx-autoapi
6
- Author: Eric Holscher
7
- Author-email: eric@ericholscher.com
8
- Maintainer: Ashley Whetter
9
- Maintainer-email: ashley@awhetter.co.uk
10
- License: MIT
11
- Project-URL: Documentation, https://sphinx-autoapi.readthedocs.io/en/latest/
12
- Classifier: Development Status :: 4 - Beta
5
+ Author-email: Eric Holscher <eric@ericholscher.com>
6
+ Maintainer-email: Ashley Whetter <ashley@awhetter.co.uk>
7
+ Requires-Python: >=3.8
8
+ Description-Content-Type: text/x-rst
9
+ Classifier: Development Status :: 5 - Production/Stable
13
10
  Classifier: Environment :: Plugins
14
11
  Classifier: Framework :: Sphinx :: Extension
15
12
  Classifier: Intended Audience :: Developers
@@ -21,19 +18,16 @@ Classifier: Programming Language :: Python :: 3.8
21
18
  Classifier: Programming Language :: Python :: 3.9
22
19
  Classifier: Programming Language :: Python :: 3.10
23
20
  Classifier: Programming Language :: Python :: 3.11
24
- Requires-Python: >=3.8
25
- Description-Content-Type: text/x-rst
26
- License-File: LICENSE.rst
27
- Requires-Dist: astroid>=2.7; python_version < "3.12"
28
- Requires-Dist: astroid>=3.0.0a1; python_version >= "3.12"
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Programming Language :: Python :: 3.13
23
+ Requires-Dist: astroid>=2.7;python_version<"3.12"
24
+ Requires-Dist: astroid>=3.0.0a1;python_version>="3.12"
29
25
  Requires-Dist: Jinja2
30
26
  Requires-Dist: PyYAML
31
27
  Requires-Dist: sphinx>=6.1.0
32
- Requires-Dist: stdlib_list; python_version < "3.10"
33
- Provides-Extra: docs
34
- Requires-Dist: furo; extra == "docs"
35
- Requires-Dist: sphinx; extra == "docs"
36
- Requires-Dist: sphinx_design; extra == "docs"
28
+ Requires-Dist: stdlib_list;python_version<"3.10"
29
+ Project-URL: Documentation, https://sphinx-autoapi.readthedocs.io/en/latest/
30
+ Project-URL: Homepage, http://github.com/readthedocs/sphinx-autoapi
37
31
 
38
32
  Sphinx AutoAPI
39
33
  ==============
@@ -54,9 +48,9 @@ Sphinx AutoAPI
54
48
  :target: https://pypi.org/project/sphinx-autoapi/
55
49
  :alt: Supported Python Versions
56
50
 
57
- .. image:: https://img.shields.io/badge/code%20style-black-000000.svg
58
- :target: https://github.com/python/black
59
- :alt: Formatted with Black
51
+ .. image:: https://img.shields.io/badge/code%20style-ruff-000000.svg
52
+ :target: https://docs.astral.sh/ruff/
53
+ :alt: Formatted with Ruff
60
54
 
61
55
  Sphinx AutoAPI is a Sphinx extension for generating complete API documentation
62
56
  without needing to load, run, or import the project being documented.
@@ -114,27 +108,19 @@ Tests are executed through `tox <https://tox.readthedocs.io/en/latest/>`_.
114
108
  Code Style
115
109
  ~~~~~~~~~~
116
110
 
117
- Code is formatted using `black <https://github.com/python/black>`_.
111
+ Code is formatted using `ruff <https://docs.astral.sh/ruff>`_.
118
112
 
119
- You can check your formatting using black's check mode:
113
+ You can check your formatting using ruff format's check mode:
120
114
 
121
115
  .. code-block:: bash
122
116
 
123
117
  tox -e format
124
118
 
125
- You can also get black to format your changes for you:
119
+ You can also get ruff to format your changes for you:
126
120
 
127
121
  .. code-block:: bash
128
122
 
129
- black autoapi/ tests/
130
-
131
- You can even get black to format changes automatically when you commit using `pre-commit <https://pre-commit.com/>`_:
132
-
133
-
134
- .. code-block:: bash
135
-
136
- pip install pre-commit
137
- pre-commit install
123
+ ruff format
138
124
 
139
125
  Release Notes
140
126
  ~~~~~~~~~~~~~
@@ -156,3 +142,4 @@ License
156
142
 
157
143
  This project is licensed under the MIT License.
158
144
  See the `LICENSE.rst <LICENSE.rst>`_ file for details.
145
+
@@ -17,9 +17,9 @@ Sphinx AutoAPI
17
17
  :target: https://pypi.org/project/sphinx-autoapi/
18
18
  :alt: Supported Python Versions
19
19
 
20
- .. image:: https://img.shields.io/badge/code%20style-black-000000.svg
21
- :target: https://github.com/python/black
22
- :alt: Formatted with Black
20
+ .. image:: https://img.shields.io/badge/code%20style-ruff-000000.svg
21
+ :target: https://docs.astral.sh/ruff/
22
+ :alt: Formatted with Ruff
23
23
 
24
24
  Sphinx AutoAPI is a Sphinx extension for generating complete API documentation
25
25
  without needing to load, run, or import the project being documented.
@@ -77,27 +77,19 @@ Tests are executed through `tox <https://tox.readthedocs.io/en/latest/>`_.
77
77
  Code Style
78
78
  ~~~~~~~~~~
79
79
 
80
- Code is formatted using `black <https://github.com/python/black>`_.
80
+ Code is formatted using `ruff <https://docs.astral.sh/ruff>`_.
81
81
 
82
- You can check your formatting using black's check mode:
82
+ You can check your formatting using ruff format's check mode:
83
83
 
84
84
  .. code-block:: bash
85
85
 
86
86
  tox -e format
87
87
 
88
- You can also get black to format your changes for you:
88
+ You can also get ruff to format your changes for you:
89
89
 
90
90
  .. code-block:: bash
91
91
 
92
- black autoapi/ tests/
93
-
94
- You can even get black to format changes automatically when you commit using `pre-commit <https://pre-commit.com/>`_:
95
-
96
-
97
- .. code-block:: bash
98
-
99
- pip install pre-commit
100
- pre-commit install
92
+ ruff format
101
93
 
102
94
  Release Notes
103
95
  ~~~~~~~~~~~~~
@@ -3,5 +3,5 @@
3
3
  from .extension import setup
4
4
 
5
5
  __all__ = ("setup",)
6
- __version__ = "3.3.2"
7
- __version_info__ = (3, 3, 2)
6
+ __version__ = "3.4.0"
7
+ __version_info__ = (3, 4, 0)
@@ -129,13 +129,24 @@ def get_full_basenames(node: astroid.nodes.ClassDef) -> Iterable[str]:
129
129
  node: The class definition node to resolve the bases of.
130
130
 
131
131
  Returns:
132
- The fullly qualified names.
132
+ The fully qualified names.
133
133
  """
134
134
  for base in node.bases:
135
135
  yield _resolve_annotation(base)
136
136
 
137
137
 
138
- def _get_const_value(node: astroid.nodes.NodeNG) -> str | None:
138
+ def get_const_value(node: astroid.nodes.NodeNG) -> str | None:
139
+ """Get the string representation of the value represented by a node.
140
+
141
+ The value must be a constant or container of constants.
142
+
143
+ Args:
144
+ node: The node to get the representation of.
145
+
146
+ Returns:
147
+ The string representation of the value represented by the node
148
+ (if it can be converted).
149
+ """
139
150
  if isinstance(node, astroid.nodes.Const):
140
151
  if isinstance(node.value, str) and "\n" in node.value:
141
152
  return f'"""{node.value}"""'
@@ -145,9 +156,7 @@ def _get_const_value(node: astroid.nodes.NodeNG) -> str | None:
145
156
 
146
157
  def _inner(node: astroid.nodes.NodeNG) -> Any:
147
158
  if isinstance(node, (astroid.nodes.List, astroid.nodes.Tuple)):
148
- new_value = []
149
- for element in node.elts:
150
- new_value.append(_inner(element))
159
+ new_value = [_inner(element) for element in node.elts]
151
160
 
152
161
  if isinstance(node, astroid.nodes.Tuple):
153
162
  return tuple(new_value)
@@ -170,19 +179,18 @@ def _get_const_value(node: astroid.nodes.NodeNG) -> str | None:
170
179
  return repr(result)
171
180
 
172
181
 
173
- def get_assign_value(
182
+ def _get_assign_target_node(
174
183
  node: astroid.nodes.Assign | astroid.nodes.AnnAssign,
175
- ) -> tuple[str, str | None] | None:
176
- """Get the name and value of the assignment of the given node.
184
+ ) -> astroid.nodes.NodeNG | None:
185
+ """Get the target of the given assignment node.
177
186
 
178
- Assignments to multiple names are ignored, as per PEP 257.
187
+ Assignments to multiple names are ignored, as per :pep:`257`.
179
188
 
180
189
  Args:
181
190
  node: The node to get the assignment value from.
182
191
 
183
192
  Returns:
184
- The name that is assigned to, and the string representation of
185
- the value assigned to the name (if it can be converted).
193
+ The node representing the name that is assigned to.
186
194
  """
187
195
  try:
188
196
  targets = node.targets
@@ -191,17 +199,42 @@ def get_assign_value(
191
199
 
192
200
  if len(targets) == 1:
193
201
  target = targets[0]
194
- if isinstance(target, astroid.nodes.AssignName):
195
- name = target.name
196
- elif isinstance(target, astroid.nodes.AssignAttr):
197
- name = target.attrname
198
- else:
199
- return None
200
- return (name, _get_const_value(node.value))
202
+ if isinstance(target, (astroid.nodes.AssignName, astroid.nodes.AssignAttr)):
203
+ return target
201
204
 
202
205
  return None
203
206
 
204
207
 
208
+ def get_assign_value(
209
+ node: astroid.nodes.Assign | astroid.nodes.AnnAssign,
210
+ ) -> tuple[str, str | None] | None:
211
+ """Get the name and value of the assignment of the given node.
212
+
213
+ Assignments to multiple names are ignored, as per :pep:`257`.
214
+
215
+ Args:
216
+ node: The node to get the assignment value from.
217
+
218
+ Returns:
219
+ The name that is assigned to, and the string representation of
220
+ the value assigned to the name (if it can be converted).
221
+ """
222
+ target = _get_assign_target_node(node)
223
+
224
+ if isinstance(target, astroid.nodes.AssignName):
225
+ name = target.name
226
+ elif isinstance(target, astroid.nodes.AssignAttr):
227
+ name = target.attrname
228
+ else:
229
+ return None
230
+
231
+ value = next(target.infer())
232
+ if value is astroid.util.Uninferable:
233
+ value = None
234
+
235
+ return (name, value)
236
+
237
+
205
238
  def get_assign_annotation(
206
239
  node: astroid.nodes.Assign | astroid.nodes.AnnAssign,
207
240
  ) -> str | None:
@@ -682,3 +715,18 @@ def is_abstract_class(node: astroid.nodes.ClassDef) -> bool:
682
715
  return True
683
716
 
684
717
  return False
718
+
719
+
720
+ def is_functional_namedtuple(node: astroid.nodes.NodeNG) -> bool:
721
+ if not isinstance(node, astroid.nodes.Call):
722
+ return False
723
+
724
+ func = node.func
725
+ if isinstance(func, astroid.nodes.Attribute):
726
+ name = func.attrname
727
+ elif isinstance(func, astroid.nodes.Name):
728
+ name = func.name
729
+ else:
730
+ return False
731
+
732
+ return name in ("namedtuple", "NamedTuple")
@@ -248,7 +248,7 @@ class PythonObject:
248
248
  return ask_result if ask_result is not None else skip
249
249
 
250
250
  def _children_of_type(self, type_: str) -> list[PythonObject]:
251
- return list(child for child in self.children if child.type == type_)
251
+ return [child for child in self.children if child.type == type_]
252
252
 
253
253
 
254
254
  class PythonFunction(PythonObject):
@@ -506,6 +506,9 @@ class PythonClass(PythonObject):
506
506
  def constructor(self):
507
507
  for child in self.children:
508
508
  if child.short_name == "__init__":
509
+ if not child.type == "method":
510
+ break
511
+
509
512
  return child
510
513
 
511
514
  return None
@@ -87,11 +87,17 @@ class Parser:
87
87
  return []
88
88
 
89
89
  target = assign_value[0]
90
- value = assign_value[1]
90
+ value_node = assign_value[1]
91
91
 
92
92
  annotation = _astroid_utils.get_assign_annotation(node)
93
93
  if annotation in ("TypeAlias", "typing.TypeAlias"):
94
94
  value = node.value.as_string()
95
+ elif isinstance(
96
+ value_node, astroid.nodes.ClassDef
97
+ ) and _astroid_utils.is_functional_namedtuple(node.value):
98
+ return self._parse_namedtuple(value_node)
99
+ else:
100
+ value = _astroid_utils.get_const_value(value_node)
95
101
 
96
102
  data = {
97
103
  "type": type_,
@@ -107,6 +113,44 @@ class Parser:
107
113
 
108
114
  return [data]
109
115
 
116
+ def _parse_namedtuple(self, node):
117
+ qual_name = self._get_qual_name(node.name)
118
+ full_name = self._get_full_name(node.name)
119
+ self._qual_name_stack.append(node.name)
120
+ self._full_name_stack.append(node.name)
121
+
122
+ data = {
123
+ "type": "class",
124
+ "name": node.name,
125
+ "qual_name": qual_name,
126
+ "full_name": full_name,
127
+ "bases": list(_astroid_utils.get_full_basenames(node)),
128
+ "doc": _prepare_docstring(node.doc_node.value if node.doc_node else ""),
129
+ "from_line_no": node.fromlineno,
130
+ "to_line_no": node.tolineno,
131
+ "children": [],
132
+ "is_abstract": _astroid_utils.is_abstract_class(node),
133
+ }
134
+
135
+ for child in node.instance_attrs:
136
+ child_data = {
137
+ "type": "attribute",
138
+ "name": child,
139
+ "qual_name": self._get_qual_name(child),
140
+ "full_name": self._get_full_name(child),
141
+ "doc": _prepare_docstring(""),
142
+ "value": None,
143
+ "from_line_no": node.fromlineno,
144
+ "to_line_no": node.tolineno,
145
+ "annotation": None,
146
+ }
147
+ data["children"].append(child_data)
148
+
149
+ self._qual_name_stack.pop()
150
+ self._full_name_stack.pop()
151
+
152
+ return [data]
153
+
110
154
  def _parse_classdef(self, node, use_name_stacks):
111
155
  if use_name_stacks:
112
156
  qual_name = self._get_qual_name(node.name)
@@ -267,6 +311,26 @@ class Parser:
267
311
  if node.name == "__init__":
268
312
  for child in node.get_children():
269
313
  if isinstance(child, (astroid.nodes.Assign, astroid.nodes.AnnAssign)):
314
+ # Verify we are assigning to self.
315
+ if isinstance(child, astroid.nodes.Assign):
316
+ targets = child.targets
317
+ else:
318
+ targets = [child.target]
319
+
320
+ target_ok = True
321
+ for target in targets:
322
+ if not isinstance(target, astroid.nodes.AssignAttr):
323
+ target_ok = False
324
+ break
325
+ _object = target.expr
326
+ if (
327
+ not isinstance(_object, astroid.nodes.Name)
328
+ or _object.name != "self"
329
+ ):
330
+ target_ok = False
331
+ break
332
+ if not target_ok:
333
+ continue
270
334
  child_data = self._parse_assign(child)
271
335
  result.extend(data for data in child_data)
272
336
 
@@ -12,24 +12,10 @@
12
12
 
13
13
  {% endif %}
14
14
 
15
- {% block subpackages %}
16
- {% set visible_subpackages = obj.subpackages|selectattr("display")|list %}
17
- {% if visible_subpackages %}
18
- Subpackages
19
- -----------
20
-
21
- .. toctree::
22
- :maxdepth: 1
23
-
24
- {% for subpackage in visible_subpackages %}
25
- {{ subpackage.include_path }}
26
- {% endfor %}
27
-
28
-
29
- {% endif %}
30
- {% endblock %}
31
15
  {% block submodules %}
16
+ {% set visible_subpackages = obj.subpackages|selectattr("display")|list %}
32
17
  {% set visible_submodules = obj.submodules|selectattr("display")|list %}
18
+ {% set visible_submodules = (visible_subpackages + visible_submodules)|sort %}
33
19
  {% if visible_submodules %}
34
20
  Submodules
35
21
  ----------
@@ -15,6 +15,7 @@
15
15
  {% endfor %}
16
16
 
17
17
  {% if obj.docstring %}
18
+
18
19
  {{ obj.docstring|indent(3) }}
19
20
  {% endif %}
20
21
  {% endif %}
@@ -0,0 +1,103 @@
1
+ [build-system]
2
+ requires = ["flit_core >=3.2,<4"]
3
+ build-backend = "flit_core.buildapi"
4
+
5
+ [project]
6
+ name = "sphinx-autoapi"
7
+ authors = [{name = "Eric Holscher", email = "eric@ericholscher.com"}]
8
+ maintainers = [{name = "Ashley Whetter", email = "ashley@awhetter.co.uk"}]
9
+ description = "Sphinx API documentation generator"
10
+ license = {text = "LICENSE.rst"}
11
+ classifiers = [
12
+ "Development Status :: 5 - Production/Stable",
13
+ "Environment :: Plugins",
14
+ "Framework :: Sphinx :: Extension",
15
+ "Intended Audience :: Developers",
16
+ "License :: OSI Approved :: MIT License",
17
+ "Natural Language :: English",
18
+ "Programming Language :: Python",
19
+ "Programming Language :: Python :: 3",
20
+ "Programming Language :: Python :: 3.8",
21
+ "Programming Language :: Python :: 3.9",
22
+ "Programming Language :: Python :: 3.10",
23
+ "Programming Language :: Python :: 3.11",
24
+ "Programming Language :: Python :: 3.12",
25
+ "Programming Language :: Python :: 3.13",
26
+ ]
27
+ requires-python = ">=3.8"
28
+ dependencies = [
29
+ 'astroid>=2.7;python_version<"3.12"',
30
+ 'astroid>=3.0.0a1;python_version>="3.12"',
31
+ "Jinja2",
32
+ "PyYAML",
33
+ "sphinx>=6.1.0",
34
+ 'stdlib_list;python_version<"3.10"',
35
+ ]
36
+ dynamic = ["version"]
37
+
38
+ [project.readme]
39
+ file = "README.rst"
40
+ content-type = "text/x-rst"
41
+
42
+ [project.urls]
43
+ Homepage = "http://github.com/readthedocs/sphinx-autoapi"
44
+ Documentation = "https://sphinx-autoapi.readthedocs.io/en/latest/"
45
+
46
+ [tool.flit.module]
47
+ name = "autoapi"
48
+
49
+ [tool.mypy]
50
+ # Start off with these
51
+ warn_unused_configs = true
52
+ warn_redundant_casts = true
53
+ warn_unused_ignores = true
54
+
55
+ # Getting these passing should be easy
56
+ strict_equality = true
57
+
58
+ # These shouldn't be too much additional work, but may be tricky to
59
+ # get passing if you use a lot of untyped libraries
60
+ disallow_subclassing_any = true
61
+ disallow_untyped_decorators = true
62
+ disallow_any_generics = true
63
+
64
+ # This one isn't too hard to get passing, but return on investment is lower
65
+ no_implicit_reexport = true
66
+
67
+ [[tool.mypy.overrides]]
68
+ module = "astroid.*"
69
+ ignore_missing_imports = true
70
+
71
+ [[tool.mypy.overrides]]
72
+ module = "autoapi.documenters"
73
+ ignore_errors = true
74
+
75
+ [[tool.mypy.overrides]]
76
+ module = "autoapi._astroid_utils"
77
+
78
+ # Strongly recommend enabling this one as soon as you can
79
+ check_untyped_defs = true
80
+
81
+ # These next few are various gradations of forcing use of type annotations
82
+ disallow_untyped_calls = true
83
+ disallow_incomplete_defs = true
84
+ disallow_untyped_defs = true
85
+
86
+ # This one can be tricky to get passing if you use a lot of untyped libraries
87
+ # Ignore until astroid is typed (https://github.com/pylint-dev/astroid/issues/2060)
88
+ warn_return_any = false
89
+
90
+ [tool.pytest.ini_options]
91
+ markers = [
92
+ "network: Tests that use network access.",
93
+ ]
94
+
95
+ [tool.ruff.lint.pydocstyle]
96
+ convention = "google"
97
+
98
+ [tool.towncrier]
99
+ directory = "docs/changes"
100
+ filename = "CHANGELOG.rst"
101
+ package = "autoapi"
102
+ title_format = "v{version} ({project_date})"
103
+ underlines = ["-", "^", "\""]