Skip to content

Commit dc6b441

Browse files
committed
replace autosummary with built-in to fix warnings
1 parent ce88e8a commit dc6b441

File tree

1 file changed

+51
-12
lines changed

1 file changed

+51
-12
lines changed

api-docs/source/conf.py

Lines changed: 51 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -148,21 +148,57 @@ def generaterst():
148148
modulefile.write(f'''{modulename} module
149149
{underline}
150150
151-
.. autosummary::
152-
:toctree:
153-
154151
''')
152+
153+
# Generate custom summary table
154+
classes = list(classlist(module))
155+
if classes:
156+
modulefile.write(".. list-table::\n")
157+
modulefile.write(" :header-rows: 1\n")
158+
modulefile.write(" :widths: 30 70\n\n")
159+
modulefile.write(" * - Class\n")
160+
modulefile.write(" - Description\n")
161+
162+
for (classname, classref) in classes:
163+
if inspect.isclass(classref):
164+
role = 'py:class'
165+
else:
166+
role = 'py:func'
167+
168+
# Get docstring summary (first line)
169+
doc = inspect.getdoc(classref)
170+
summary = ""
171+
if doc and doc.strip():
172+
first_line = doc.split('\n')[0].strip()
173+
# Only use the description if it's actual documentation (not just prototype/signature)
174+
if first_line and not first_line.startswith(classname + "("):
175+
summary = first_line
176+
if len(summary) > 100:
177+
summary = summary[:97] + "..."
178+
179+
modulefile.write(f" * - :{role}:`{inspect.getmodule(classref).__name__}.{classname}`\n")
180+
modulefile.write(f" - {summary}\n")
155181

156-
for (classname, classref) in classlist(module):
157-
modulefile.write(f" {inspect.getmodule(classref).__name__}.{classname}\n")
158-
159-
modulefile.write('''\n.. toctree::
160-
:maxdepth: 2\n''')
161182

162183
modulefile.write(f'''\n\n.. automodule:: {module.__name__}
163184
:members:
164185
:undoc-members:
165-
:show-inheritance:''')
186+
:show-inheritance:
187+
:noindex:\n\n''')
188+
189+
# Generate individual class sections with proper headers
190+
for (classname, classref) in classes:
191+
# Only include classes that actually belong to this module
192+
if inspect.getmodule(classref).__name__ == module.__name__:
193+
modulefile.write(f'''{classname}
194+
{"-" * len(classname)}
195+
196+
.. autoclass:: {module.__name__}.{classname}
197+
:members:
198+
:undoc-members:
199+
:show-inheritance:
200+
201+
''')
166202
modulefile.write(stats)
167203
modulefile.close()
168204

@@ -186,21 +222,24 @@ def generaterst():
186222

187223
extensions = [
188224
'sphinx.ext.autodoc',
189-
'sphinx.ext.autosummary',
190225
'sphinx.ext.intersphinx',
191226
'sphinxcontrib.jquery',
192227
#'sphinx_tabs.tabs',
193-
'sphinx.ext.viewcode'
228+
'sphinx.ext.viewcode',
229+
'sphinx.ext.autosectionlabel'
194230
]
195231

196232
simplify_optional_unions = True
197233
autodoc_typehints = 'both'
198-
autosummary_generate = False
199234
autodoc_member_order = 'groupwise'
235+
autodoc_class_signature = 'separated'
200236
autodoc_type_aliases = {
201237
'int': 'ExpressionIndex'
202238
}
203239

240+
# Auto section label configuration
241+
autosectionlabel_prefix_document = True
242+
204243
python_use_unqualified_type_names=True
205244
# Add any paths that contain templates here, relative to this directory.
206245
templates_path = ['_templates']

0 commit comments

Comments
 (0)