autoclasstoc
raw JSON → 1.7.0 verified Fri May 01 auth: no python
Add a succinct table of contents to Sphinx auto-documented classes, making navigation easier. Version 1.7.0, stable and infrequently updated.
pip install autoclasstoc Common errors
error Extension error: Could not import extension autoclasstoc (exception: No module named 'autoclasstoc') ↓
cause `autoclasstoc` is not installed in the Python environment used by Sphinx.
fix
Run
pip install autoclasstoc in the same environment as Sphinx. error WARNING: unknown directive: autoclasstoc ↓
cause The extension is not enabled in conf.py or is listed after a broken extension.
fix
Add
'autoclasstoc' to the extensions list and ensure sphinx.ext.autodoc is also present. Warnings
gotcha `autoclasstoc` requires `sphinx.ext.autodoc` to be loaded first. If not, the extension silently fails. ↓
fix Ensure `extensions` list has `'sphinx.ext.autodoc'` before `'autoclasstoc'`.
gotcha The `:ignore:` directive does not work with parenthesized names like `__init__(self)`. Use just `:ignore: __init__` (no parentheses). ↓
fix List method names without arguments.
deprecated The `:members:` option on `autoclasstoc` is deprecated and may be removed. It is ignored in modern versions. ↓
fix Remove `:members:` from the `autoclasstoc` directive; it has no effect.
Imports
- autoclasstoc
from sphinx.ext.autodoc import cut_lines, between # The extension is loaded via conf.py extensions list, not direct import. - autoclasstoc directive wrong
.. automodule:: :members: :noindex:correct.. autoclasstoc::
Quickstart
extensions = ['sphinx.ext.autodoc', 'autoclasstoc']
# In your .rst file:
# .. autoclasstoc::
# :ignore: __init__
# :order: source
# :sections: Attributes, Methods
# Then use .. autoclass:: to document a class and the TOC appears.