tags:

views:

384

answers:

2

I'm trying to use Sphinx to document a 5,000+ line project in Python. It has about 7 base modules. As far as I know, In order to use autodoc I need to write code like this for each file in my project:

.. automodule:: mods.set.tests
    :members:
    :show-inheritance:

This is way too tedious because I have many files. It would be much easier if I could just specify that I wanted the 'mods' module to be documented. Sphinx could then recursively go through the module and make a page for each submodule.

Is there A feature like this? If not I could write a script to make all the .rst files, but that would take up a lot of time.

+1  A: 

In each package, the __init__.py file can have .. autodoc:: package.module components for each part of the package.

Then you can .. autodoc:: package and it mostly does what you want.

S.Lott
do I just put that string in triple quotes in __init__.py?
Cory Walker
@Cory Walker: It's not "a" string. You can -- and **should** -- be putting triple-quoted docstrings in every single file. Every one. That includes the `__init__.py` files in your packages. The docstring can include ANY Sphinx documentation directives, including `.. automodule::` for modules within the package.
S.Lott
+1  A: 

You can check this script that I've done. I think it can help you.

This script parse a directory tree looking for python modules and packages and create ReST files appropriately to create code documentation with Sphinx. It also create a modules index.

Etienne