Sphinx: Make classes in TOC

I am starting to document several python classes using ext.autodoc. I have some * .rst files with content like

======== mymodule ======== .. automodule:: mymodule .. autoclass:: myclassA :members: .. autoclass:: myclassB :members: 

plus index.rst:

 .. toctree:: :maxdepth: 2 mymodule 

'mymodule' is shown in the table of contents, but I would also like to see classes in TOC:

  • Mymodule
    • myclassA
    • myclassB

How can I get sphinx to create something like a section for each class? Or is there a good reason not to?

thanks

+7
python-sphinx
source share
1 answer

Sphinx cannot create partitions. You must add them yourself to the .rst file. Something like that:

 myclassA -------- .. autoclass:: myclassA :members: myclassB -------- .. autoclass:: myclassB :members: 

For some alternative suggestions that may be interesting, see these questions (and answers):

  • Sphinx customizes autoclass output
  • Sort display by class using sphinx using 'autodoc'?
+3
source share

All Articles