Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sorting display by class using sphinx with 'autodoc'?

Is there a way to display a "Classes" list / tab using Sphinx, or to organize the html pages generated to show members by class, classes being visually well separated?

I use Sphinx 1.1.3, an try to document a Python extension (a custom one created with Cython). My problem is that the whole extension is displayed in one single block if I enter the modules tab (which is quite unreadable) and, by the other hand, the "Index" tab merges everything together (which is normal). I would like a per class display (something closer to what Doxygen would do).

Does something like:

Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

* :ref:`classindex`  ???

exists?

Thanks a lot.

like image 489
Gauthier Boaglio Avatar asked Jan 30 '13 14:01

Gauthier Boaglio


People also ask

What does Sphinx Autodoc do?

This extension can import the modules you are documenting, and pull in documentation from docstrings in a semi-automatic way.

What is Sphinx-Apidoc?

sphinx-apidoc is a tool for automatic generation of Sphinx sources that, using the autodoc extension, document a whole package in the style of other automatic API documentation tools. MODULE_PATH is the path to a Python package to document, and OUTPUT_PATH is the directory where the generated sources are placed.


1 Answers

The autosummary extension, with the autosummary_generate configuration variable set to True, can be used to 1) generate compact summary listings and 2) generate class documentation with one page per class.

You have to explicitly specify each class to be included, but once this is done you have a setup for generating clear documentation where the classes are visually well separated.

The following markup will output one "stub" .rst page for each class (Class1, Class2, Class3). Each page is based on a template and includes an .. autoclass:: directive that extracts the full documentation. In the final HTML output, each class page is linked from the corresponding entry in the main autosummary table.

:mod:`mymodule` --- Some module
===============================

This module contains several classes. 

.. currentmodule:: mymodule

Class overview
--------------

.. autosummary::
   :toctree: stubs
   :template: class.rst

   Class1
   Class2
   Class3

Details here: https://www.sphinx-doc.org/en/master/usage/extensions/autosummary.html

like image 54
mzjn Avatar answered Sep 18 '22 02:09

mzjn