Documenting Praxes¶
Getting started¶
Praxes’ documentation is generated from ReStructured Text, using the Sphinx documentation generation tool. Sphinx-1.0.3 or later is required.
The documentation sources are found in the doc/
directory in the trunk.
The output produced by Sphinx can be configured by editing the conf.py
file located in the doc/
directory. To build the users guide in html
format, run from the doc directory:
make html
and the html will be produced in doc/_build/html/
.
ReSructuredText markup¶
The Sphinx website contains plenty of documentation concerning ReST markup and working with Sphinx in general. Here are a few additional things to keep in mind:
Please familiarize yourself with the Sphinx directives for inline markup. Praxes’ documentation makes heavy use of cross-referencing and other semantic markup. For example, when referring to external files, use the
:file:
directive.Function arguments and keywords should be referred to using the emphasis role. This will keep Praxes’ documentation consistant with Python’s documentation:
Here is a description of *argument*
Please do not use the default role:
Please do not describe `argument` like this.
nor the
literal
role:Please do not describe ``argument`` like this.
Sphinx does not support tables with column- or row-spanning cells for latex output. Such tables can not be used when documenting Praxes.
Mathematical expressions can be rendered as png images in html, and in the usual way by latex. For example:
:math:`\sin(x_n^2)`
yields: , and:.. math:: \int_{-\infty}^{\infty}\frac{e^{i\phi}}{1+x^2\frac{e^{i\phi}}{1+x^2}}
yields:
Footnotes [1] can be added using
[#]_
, followed later by:.. rubric:: Footnotes .. [#]
Footnotes
[1] For example.
Use the note and warning directives, sparingly, to draw attention to important comments:
.. note:: Here is a note
yields:
Note
here is a note
also:
Warning
here is a warning
Use the deprecated directive when appropriate:
.. deprecated:: 0.98 This feature is obsolete, use something else.
yields:
Deprecated since version 0.98: This feature is obsolete, use something else.
Use the versionadded and versionchanged directives, which have similar syntax to the deprecated role:
.. versionadded:: 0.98 The transforms have been completely revamped.
New in version 0.98: The transforms have been completely revamped.
Use the seealso directive, for example:
.. seealso:: A bit about :ref:`referring-to-praxes-docs`: One example
yields:
See also
- A bit about Referring to Praxes documents:
One example
Please keep the Glossary in mind when writing documentation. You can create a references to a term in the glossary with the
:term:
role.The autodoc extension will handle index entries for the API, but additional entries in the index need to be explicitly added.
Docstrings¶
In addition to the aforementioned formatting suggestions:
Please limit the text width of docstrings to 70 characters.
Keyword arguments should be described using a definition list.
Note
Praxes makes extensive use of keyword arguments as pass-through arguments, there are a many cases where a table is used in place of a definition list for autogenerated sections of docstrings.
Figures¶
Dynamically generated figures¶
The top level doc
dir has a folder called pyplots
in which you
should include any pyplot plotting scripts that you want to generate figures
for the documentation. It is not necessary to explicitly save the figure in
the script, this will be done automatically at build time to insure that the
code that is included runs and produces the advertised figure. Several
figures will be saved with the same basnename as the filename when the
documentation is generated (low and high res PNGs, a PDF). Praxes includes a
Sphinx extension (sphinxext/plot_directive.py
) for generating the
images from the python script and including either a png copy for html or a
pdf for latex:
.. plot:: pyplot_simple.py
:include-source:
The :scale:
directive rescales the image to some percentage of the
original size, though we don’t recommend using this in most cases since it is
probably better to choose the correct figure size and dpi in mpl and let it
handle the scaling. :include-source:
will present the contents of the
file, marked up as source code.
Static figures¶
Any figures that rely on optional system configurations need to be handled a
little differently. These figures are not to be generated during the
documentation build, in order to keep the prerequisites to the documentation
effort as low as possible. Please run the doc/pyplots/make.py
script
when adding such figures, and commit the script and the images to svn.
Please also add a line to the README in doc/pyplots for any additional
requirements necessary to generate a new figure. Once these steps have been
taken, these figures can be included in the usual way:
.. plot:: tex_unicode_demo.py
:include-source
Referring to Praxes documents¶
In the documentation, you may want to include a document from the Praxes
source, like a license file or an example. When you include these files,
include them using the literalinclude
directive:
.. literalinclude:: ../examples/some_example.py
Internal section references¶
To maximize internal consistency in section labeling and references, use hyphen-separated, descriptive labels for section references, eg:
.. _howto-webapp:
and refer to it using the standard reference syntax:
See :ref:`howto-webapp`
Keep in mind that we may want to reorganize the contents later, so let’s avoid
top level names in references like user
or devel
or faq
unless
necesssary, because for example the FAQ “what is a backend?” could later
become part of the users guide, so the label:
.. _what-is-a-backend
is better than:
.. _faq-backend
In addition, since underscores are widely used by Sphinx itself, let’s prefer hyphens to separate words.
Section names, etc¶
For everything but top level chapters, please use Upper lower
for
section titles, eg Possible hangups
rather than Possible
Hangups