Sphinx customizes autoclass output

I have a module with several classes. I am currently using ..automodule to document the module. I would like each class to have its own title with the class name. I could achieve this by replacing ..automodule foo with:

 Bar === ..autoclass foo.Bar Baz === ..autoclass foo.Baz ... 

However, this will require me to manually list each class in each module for which I do this. What is the best way to customize the content generated by the car module?

+4
python-sphinx
source share
1 answer

Sphinx is not as easy to use as Epydoc or Doxygen to generate API documentation from source code. This is a simple tool.

Sphinx works with .rst files (reStructuredText), and if you want each class to have its own title with the class name, you must add the headers yourself and use .. autoclass:: . This cannot be done only with .. automodule:: . Yes, this is inconvenient (similar moods are expressed here ). See Also this answer and this answer .

The problem can be reduced by using a script that goes through the Python code and generates .rst output. Sphinx already comes with such a script, sphinx-apidoc . However, it does not create any directives .. autoclass:: , only .. automodule:: .

Here is another script that can output .. autoclass:: https://github.com/PyMVPA/PyMVPA/blob/master/tools/apigen.py . Perhaps you can use this.

+2
source share

All Articles