I'm looking to increase the documentation in one of my libraries. I've been using sphinx to help build the documentation and recently started exploring the autodoc extension.
It seems like in most professional documentation, each class documentation page has a list of all the documented methods with links at the top. Or, in other words, a toctree at the top with hyperlinks to each of the more in depth method documentation.
Is there a way to automatically create this toctree for each of the classes being documented with autodoc?
The toctree directive is the central element. Note. Simple “inclusion” of one file in another can be done with the include directive. Note. To create table of contents for current document (.
In your conf.py
file for sphinx add
extensions = ['sphinx.ext.autosummary',]
# NOTE: Don't overwrite your old extension list! Just add to it!
autodoc_default_flags = ['members']
autosummary_generate = True
I put the toctree in my index.rst, and it looks like this:
.. autosummary::
:toctree: stubs
Class1
Class2
Class3
See this example for the conf.py settings
and this example for an example of the toctree.
Hope that helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With