Autodocumenting Python using Sphinx

Adam Matan picture Adam Matan · Aug 25, 2009 · Viewed 18.1k times · Source

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.

Answer

S.Lott picture S.Lott · Aug 25, 2009

We use

.. automodule:: module
   :members: