Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sphinx: list of functions in a module

I have some python modules containing mostly functions and a few classes. Each one is documented using sphinx-autodoc in a separate rst. What I want to do is to create a table or list of the module's contents at the top of each page, so for example, of mymodule.py is

def first():
    'First function'

def second():
    'Second function'

And mymodule.rst is

Page Contents
-------------

:create_page_contents_list:

Members
-------

.. automodule:: mymodule
    :members:

Then the output should look something like this:

Page Contents
-------------

first
second

Members
-------

first()
    First function

second()
    Second function

The question how to do :create_page_contents_list:. I've have a look at using a TOC, but it seems that I would need to manually create an entry for each item. I've also looked at autosummary, but I still need to list the members. Any suggestions for automating this? I'd rather avoid third-party extensions.

like image 727
aquavitae Avatar asked Mar 19 '12 13:03

aquavitae


1 Answers

You probably want something like the autosummary extension. The actual autosummary extension will not quite do what you want, though.

An example of how you might extend autosummary to auto-detect the contents of the module is given in this answer

like image 167
Kevin Horn Avatar answered Sep 20 '22 13:09

Kevin Horn