Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
539 views
in Technique[技术] by (71.8m points)

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...