Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Autodocumenting Python using Sphinx

This is a generalized version of a previous question regarding Sphinx.

Is there a way to recursively autodocument modules or packages which contain classes and functions within them?

I think it is silly to add the autofunction or automodule directive for each function; There must be a way to automate the process, otherwise I don't see the point of using Sphinx at all.

Clarification: Instead of :

.. automodule:: segments.segments

    .. autoclass:: segments.segments.Seg

        .. automethod:: Seg.method_1

        .. automethod:: Seg.method_2

        .. automethod:: Seg.method_3

        .......

        .. automethod:: Seg.method_n

Which requires me to manually cut-and-paste all method names and update the documentation correspondingly, I want to have a command like:

.. automodule:: segments.segments

    .. autoclass:: segments.segments.Seg

        .. MAGIC COMMAND: Automatically print the docstrings and signatures 
           of all Seg() methods.
like image 931
Adam Matan Avatar asked Aug 25 '09 12:08

Adam Matan


People also ask

Does Sphinx support Markdown?

To support Markdown-based documentation, Sphinx can use MyST-Parser. MyST-Parser is a Docutils bridge to markdown-it-py, a Python package for parsing the CommonMark Markdown flavor.


1 Answers

We use

.. automodule:: module
   :members:
like image 105
S.Lott Avatar answered Oct 01 '22 08:10

S.Lott