Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In the Sphinx doc generator, can I add an entire package (recursivly) to the Index?

I want to generate documentation for my package. Every file in the project contains extensive documentation. Is there a way to quickly add my entire project to the documetation index?

I'd like to automatically generate some documentation for the entire project with as little as possible work. I started by adding the following to index.rst:

.. automodule:: mymodulename
    :members:

All that seems to have done is document elenments in the __init__.py file (just a docstring) - is there any way I can make it document everything else? I'm looking to add absolutely everything defined in my package and have every single class, constant, function (etc) in the package be added to the appropriate index.

Can this be done?

like image 677
Salim Fadhley Avatar asked Jan 09 '12 17:01

Salim Fadhley


People also ask

How does Sphinx Autodoc work?

autodoc provides several directives that are versions of the usual py:module , py:class and so forth. On parsing time, they import the corresponding module and extract the docstring of the given objects, inserting them into the page source under a suitable py:module , py:class etc. directive.

What is Toctree Sphinx?

The toctree directive is the central element. Note. Simple “inclusion” of one file in another can be done with the include directive. Note.


1 Answers

You can use sphinx-apidoc.
From the official documentation: sphinx-apidoc is a tool for automatic generation of Sphinx sources that, using the autodoc extension, document a whole package in the style of other automatic API documentation tools.

An usage example could be (from your project root directory):

$ sphinx-apidoc . --full -o doc -H 'MyProject' -A 'MyName' -V '1.0'

A doc directory would be created with everything ready inside.
You can also adjust the settings of your documentation editing the auto-generated conf.py file.

Other useful information can be found in similar question posted here.

like image 66
Rik Poggi Avatar answered Oct 17 '22 03:10

Rik Poggi