Added some overview content at the top. Created some sections below.
|Deletions are marked like this.||Additions are marked like this.|
|Line 1:||Line 1:|
|Documentation of Python modules is most-often done by adding docstrings to your code. You can read a module's docstrings from the Python interactive prompt (the "REPL") by using the `help()` function. For example:||Python modules are usually documented using docstrings. You can read a module's docstrings from the Python interactive prompt with the `help()` function. For example:|
|Line 44:||Line 44:|
Python modules are usually documented using docstrings. You can read a module's docstrings from the Python interactive prompt with the help() function. For example:
import distutils help(distutils)
The help() function uses Python's standard pydoc module, as does the pydoc command that comes with Python.
The various documentation tools available generally do one of two things:
- they either process docstrings in some way to make finding/reading documentation on a given module easier (so-called "API documentation tools"), or
- they have nothing to do with docstrings and instead focus on processing documentation in some way (such as converting your plain text docs into html)
Currently, the Python docs consist of 2 parts:
the API docs that you can read using the help() command (pydoc can also provide these as html and even serve them from your local machine), and
the manuals/guides/howtos at http://python.org/doc/ which are written in reStructuredText (a plain text format) and processed into various output formats by the Sphinx tool.
When writing documentation for your own modules (either as manuals or docstrings (preferably both)), I suggest you use a plain text markup such as reST or Markdown.
Automatic Python API documentation generation tools
PythonDoc - uses StructuredText input format (not reST), and can produce HTML and XML output. It uses XML as an intermediate representation, to simplify the addition of new output formats. http://starship.python.net/crew/danilo/pythondoc/
Another PythonDoc - uses JavaDoc-style comments, and produces HTML and XML output. Can also be used as a library, producing ElementTree descriptions of your source code. http://effbot.org/zone/pythondoc.htm
Doxygen < http://www.doxygen.org > can create documentation in various formats (HTML, LaTeX, PDF, ...) and you can include formulas in your documentation (great for technical/mathematical software). Together with Graphviz < http://www.research.att.com/sw/tools/graphviz/ > it can create diagrams of your code (inhertance diagram, call graph, ...). Another benefit is that it handles not only Python, but also several other programming languages like C, C++, Java, etc.
Endo, part of the Enthought Tool Suite (http://code.enthought.com/ets/), is aware of Traits-based attributes (Traits is also part of ETS); uses ReStructuredText or plain text in docstrings and in plain comments that immediately precede variable assignments; and generates HTML output.
Other projects that can be used to produce API documentation
XIST - an XML based extensible HTML generator written in Python.
HtmlGen - a Python library for generating HTML documents.
Other documentation processing tools
Pandoc -- written in Haskell, this tool can read and write a number of formats (including reST).