Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Structuring Sphinx documentation

I have started documenting a Python project using Sphinx. It is the first time I use it - I am used to tools which work with a JavaDoc-like syntax, and I have some doubts.

Since I want the documentation to appear near the code, I make use of the .. automodule::, .. autoclass:: and .. automethod:: directives. So the structure of my documentation is as follows: index.rst contains the TOC and

.. automodule:: my_main_package

and then the top-level __init__.py contains directives like

.. automodule:: some_subpackage

for each subpackage and so on. Finally each module contains directives

.. autoclass:: some_class
    :members:

for each class in the module.

This mostly works, but what I get is a single page documentation, which is a little odd to work with.

How should I organize my documentation in order to obtain a tree of hyperlinked files? That is, the main package should contain its own documentation and links to each of its subpackages and so on, until each module has its own page.

like image 790
Andrea Avatar asked Mar 15 '11 23:03

Andrea


People also ask

What is Sphinx read the docs?

Sphinx is a powerful documentation generator that has many great features for writing technical documentation including: Generate web pages, printable PDFs, documents for e-readers (ePub), and more all from the same sources. You can use reStructuredText or Markdown to write documentation.


1 Answers

I found this autopackage script from a comment here. It generates the necessary .rst files according to the structure of your packages.

side note: I still feel I am missing something, as I cannot believe that a tool like Sphinx, which is renowned as the most advanced tool for documenting Python, misses the functionality to do basic API documentation. Hence I will leave the question open for a while before accepting my own answer.

like image 87
Andrea Avatar answered Oct 13 '22 06:10

Andrea