2009-08-26 09:30:23 -05:00
|
|
|
.. highlight:: rest
|
2008-03-15 04:06:04 -05:00
|
|
|
|
|
|
|
Paragraph-level markup
|
|
|
|
----------------------
|
|
|
|
|
2008-03-16 06:19:26 -05:00
|
|
|
.. index:: note, warning
|
|
|
|
pair: changes; in version
|
|
|
|
|
2008-03-15 04:06:04 -05:00
|
|
|
These directives create short paragraphs and can be used inside information
|
|
|
|
units as well as normal text:
|
|
|
|
|
2010-03-01 07:37:31 -06:00
|
|
|
.. directive:: .. note::
|
2008-03-15 04:06:04 -05:00
|
|
|
|
|
|
|
An especially important bit of information about an API that a user should be
|
|
|
|
aware of when using whatever bit of API the note pertains to. The content of
|
|
|
|
the directive should be written in complete sentences and include all
|
|
|
|
appropriate punctuation.
|
|
|
|
|
|
|
|
Example::
|
|
|
|
|
|
|
|
.. note::
|
|
|
|
|
|
|
|
This function is not suitable for sending spam e-mails.
|
|
|
|
|
2010-03-01 07:37:31 -06:00
|
|
|
.. directive:: .. warning::
|
2008-03-15 04:06:04 -05:00
|
|
|
|
|
|
|
An important bit of information about an API that a user should be very aware
|
|
|
|
of when using whatever bit of API the warning pertains to. The content of
|
|
|
|
the directive should be written in complete sentences and include all
|
2010-03-01 07:37:31 -06:00
|
|
|
appropriate punctuation. This differs from :dir:`note` in that it is
|
|
|
|
recommended over :dir:`note` for information regarding security.
|
2008-03-15 04:06:04 -05:00
|
|
|
|
2008-03-16 06:19:26 -05:00
|
|
|
.. directive:: .. versionadded:: version
|
2008-03-15 04:06:04 -05:00
|
|
|
|
|
|
|
This directive documents the version of the project which added the described
|
|
|
|
feature to the library or C API. When this applies to an entire module, it
|
|
|
|
should be placed at the top of the module section before any prose.
|
|
|
|
|
|
|
|
The first argument must be given and is the version in question; you can add
|
|
|
|
a second argument consisting of a *brief* explanation of the change.
|
|
|
|
|
|
|
|
Example::
|
|
|
|
|
|
|
|
.. versionadded:: 2.5
|
|
|
|
The `spam` parameter.
|
|
|
|
|
|
|
|
Note that there must be no blank line between the directive head and the
|
|
|
|
explanation; this is to make these blocks visually continuous in the markup.
|
|
|
|
|
2008-03-16 06:19:26 -05:00
|
|
|
.. directive:: .. versionchanged:: version
|
2008-03-15 04:06:04 -05:00
|
|
|
|
2010-03-01 07:37:31 -06:00
|
|
|
Similar to :dir:`versionadded`, but describes when and what changed in the named
|
2008-03-15 04:06:04 -05:00
|
|
|
feature in some way (new parameters, changed side effects, etc.).
|
|
|
|
|
|
|
|
--------------
|
|
|
|
|
|
|
|
.. directive:: seealso
|
|
|
|
|
|
|
|
Many sections include a list of references to module documentation or
|
2010-03-01 07:37:31 -06:00
|
|
|
external documents. These lists are created using the :dir:`seealso`
|
|
|
|
directive.
|
2008-03-15 04:06:04 -05:00
|
|
|
|
2010-03-01 07:37:31 -06:00
|
|
|
The :dir:`seealso` directive is typically placed in a section just before any
|
2008-03-15 04:06:04 -05:00
|
|
|
sub-sections. For the HTML output, it is shown boxed off from the main flow
|
|
|
|
of the text.
|
|
|
|
|
2010-03-01 07:37:31 -06:00
|
|
|
The content of the :dir:`seealso` directive should be a reST definition list.
|
2008-03-15 04:06:04 -05:00
|
|
|
Example::
|
|
|
|
|
|
|
|
.. seealso::
|
|
|
|
|
2010-03-01 07:37:31 -06:00
|
|
|
Module :py:mod:`zipfile`
|
|
|
|
Documentation of the :py:mod:`zipfile` standard module.
|
2008-03-15 04:06:04 -05:00
|
|
|
|
|
|
|
`GNU tar manual, Basic Tar Format <http://link>`_
|
|
|
|
Documentation for tar archive files, including GNU tar extensions.
|
|
|
|
|
2008-11-04 14:35:05 -06:00
|
|
|
There's also a "short form" allowed that looks like this::
|
|
|
|
|
2010-03-01 07:37:31 -06:00
|
|
|
.. seealso:: modules :py:mod:`zipfile`, :py:mod:`tarfile`
|
2008-11-04 14:35:05 -06:00
|
|
|
|
|
|
|
.. versionadded:: 0.5
|
|
|
|
The short form.
|
|
|
|
|
2008-03-16 06:19:26 -05:00
|
|
|
.. directive:: .. rubric:: title
|
2008-03-15 04:06:04 -05:00
|
|
|
|
|
|
|
This directive creates a paragraph heading that is not used to create a
|
Merged revisions 64703-64708,64710-64712 via svnmerge from
svn+ssh://pythondev@svn.python.org/doctools/branches/0.4.x
........
r64703 | georg.brandl | 2008-07-04 19:24:00 +0200 (Fri, 04 Jul 2008) | 2 lines
Fix linkcheck builder crash for malformed URLs.
........
r64704 | georg.brandl | 2008-07-04 19:32:40 +0200 (Fri, 04 Jul 2008) | 2 lines
Add 0.5 compatibility for more admonitions.
........
r64705 | georg.brandl | 2008-07-04 19:38:37 +0200 (Fri, 04 Jul 2008) | 2 lines
Remove silly "rubric" restriction in latex writer.
........
r64706 | georg.brandl | 2008-07-04 19:41:44 +0200 (Fri, 04 Jul 2008) | 2 lines
Document rubric:: Footnotes behavior.
........
r64707 | georg.brandl | 2008-07-04 19:45:28 +0200 (Fri, 04 Jul 2008) | 2 lines
Fix XHTML.
........
r64708 | georg.brandl | 2008-07-04 19:50:56 +0200 (Fri, 04 Jul 2008) | 2 lines
More XHTML fixes.
........
r64710 | georg.brandl | 2008-07-04 19:59:56 +0200 (Fri, 04 Jul 2008) | 2 lines
Copy the html_logo to the output static dir.
........
r64711 | georg.brandl | 2008-07-04 20:37:43 +0200 (Fri, 04 Jul 2008) | 2 lines
Fix latex code for module names with underscores that have platforms.
........
r64712 | georg.brandl | 2008-07-04 20:46:40 +0200 (Fri, 04 Jul 2008) | 2 lines
Fix a crash with nonlocal image URIs.
........
2008-07-04 13:49:39 -05:00
|
|
|
table of contents node.
|
2009-01-10 15:18:18 -06:00
|
|
|
|
Merged revisions 64703-64708,64710-64712 via svnmerge from
svn+ssh://pythondev@svn.python.org/doctools/branches/0.4.x
........
r64703 | georg.brandl | 2008-07-04 19:24:00 +0200 (Fri, 04 Jul 2008) | 2 lines
Fix linkcheck builder crash for malformed URLs.
........
r64704 | georg.brandl | 2008-07-04 19:32:40 +0200 (Fri, 04 Jul 2008) | 2 lines
Add 0.5 compatibility for more admonitions.
........
r64705 | georg.brandl | 2008-07-04 19:38:37 +0200 (Fri, 04 Jul 2008) | 2 lines
Remove silly "rubric" restriction in latex writer.
........
r64706 | georg.brandl | 2008-07-04 19:41:44 +0200 (Fri, 04 Jul 2008) | 2 lines
Document rubric:: Footnotes behavior.
........
r64707 | georg.brandl | 2008-07-04 19:45:28 +0200 (Fri, 04 Jul 2008) | 2 lines
Fix XHTML.
........
r64708 | georg.brandl | 2008-07-04 19:50:56 +0200 (Fri, 04 Jul 2008) | 2 lines
More XHTML fixes.
........
r64710 | georg.brandl | 2008-07-04 19:59:56 +0200 (Fri, 04 Jul 2008) | 2 lines
Copy the html_logo to the output static dir.
........
r64711 | georg.brandl | 2008-07-04 20:37:43 +0200 (Fri, 04 Jul 2008) | 2 lines
Fix latex code for module names with underscores that have platforms.
........
r64712 | georg.brandl | 2008-07-04 20:46:40 +0200 (Fri, 04 Jul 2008) | 2 lines
Fix a crash with nonlocal image URIs.
........
2008-07-04 13:49:39 -05:00
|
|
|
.. note::
|
2009-01-10 15:18:18 -06:00
|
|
|
|
2009-08-06 15:48:14 -05:00
|
|
|
If the *title* of the rubric is "Footnotes" (or the selected language's
|
|
|
|
equivalent), this rubric is ignored by the LaTeX writer, since it is
|
|
|
|
assumed to only contain footnote definitions and therefore would create an
|
|
|
|
empty heading.
|
Merged revisions 64703-64708,64710-64712 via svnmerge from
svn+ssh://pythondev@svn.python.org/doctools/branches/0.4.x
........
r64703 | georg.brandl | 2008-07-04 19:24:00 +0200 (Fri, 04 Jul 2008) | 2 lines
Fix linkcheck builder crash for malformed URLs.
........
r64704 | georg.brandl | 2008-07-04 19:32:40 +0200 (Fri, 04 Jul 2008) | 2 lines
Add 0.5 compatibility for more admonitions.
........
r64705 | georg.brandl | 2008-07-04 19:38:37 +0200 (Fri, 04 Jul 2008) | 2 lines
Remove silly "rubric" restriction in latex writer.
........
r64706 | georg.brandl | 2008-07-04 19:41:44 +0200 (Fri, 04 Jul 2008) | 2 lines
Document rubric:: Footnotes behavior.
........
r64707 | georg.brandl | 2008-07-04 19:45:28 +0200 (Fri, 04 Jul 2008) | 2 lines
Fix XHTML.
........
r64708 | georg.brandl | 2008-07-04 19:50:56 +0200 (Fri, 04 Jul 2008) | 2 lines
More XHTML fixes.
........
r64710 | georg.brandl | 2008-07-04 19:59:56 +0200 (Fri, 04 Jul 2008) | 2 lines
Copy the html_logo to the output static dir.
........
r64711 | georg.brandl | 2008-07-04 20:37:43 +0200 (Fri, 04 Jul 2008) | 2 lines
Fix latex code for module names with underscores that have platforms.
........
r64712 | georg.brandl | 2008-07-04 20:46:40 +0200 (Fri, 04 Jul 2008) | 2 lines
Fix a crash with nonlocal image URIs.
........
2008-07-04 13:49:39 -05:00
|
|
|
|
2008-03-15 04:06:04 -05:00
|
|
|
|
|
|
|
.. directive:: centered
|
|
|
|
|
2010-03-01 07:37:31 -06:00
|
|
|
This directive creates a centered boldfaced line of text. Use it as
|
|
|
|
follows::
|
2008-03-15 04:06:04 -05:00
|
|
|
|
2008-08-06 09:46:11 -05:00
|
|
|
.. centered:: LICENSE AGREEMENT
|
2008-03-15 04:06:04 -05:00
|
|
|
|
|
|
|
|
2009-01-04 15:00:40 -06:00
|
|
|
.. directive:: hlist
|
|
|
|
|
|
|
|
This directive must contain a bullet list. It will transform it into a more
|
|
|
|
compact list by either distributing more than one item horizontally, or
|
|
|
|
reducing spacing between items, depending on the builder.
|
|
|
|
|
|
|
|
For builders that support the horizontal distribution, there is a ``columns``
|
|
|
|
option that specifies the number of columns; it defaults to 2. Example::
|
|
|
|
|
|
|
|
.. hlist::
|
|
|
|
:columns: 3
|
|
|
|
|
|
|
|
* A list of
|
|
|
|
* short items
|
|
|
|
* that should be
|
|
|
|
* displayed
|
|
|
|
* horizontally
|
|
|
|
|
|
|
|
.. versionadded:: 0.6
|
|
|
|
|
|
|
|
|
2008-03-15 04:06:04 -05:00
|
|
|
Table-of-contents markup
|
|
|
|
------------------------
|
|
|
|
|
|
|
|
The :dir:`toctree` directive, which generates tables of contents of
|
2010-03-01 07:37:31 -06:00
|
|
|
subdocuments, is described in :ref:`toctree-directive`.
|
2008-03-15 04:06:04 -05:00
|
|
|
|
2010-03-01 07:37:31 -06:00
|
|
|
For local tables of contents, use the standard reST :rstdir:`contents directive
|
|
|
|
<contents>`.
|
2008-03-15 04:06:04 -05:00
|
|
|
|
|
|
|
|
|
|
|
Index-generating markup
|
|
|
|
-----------------------
|
|
|
|
|
2010-03-01 07:37:31 -06:00
|
|
|
Sphinx automatically creates index entries from all object descriptions (like
|
|
|
|
functions, classes or attributes) like discussed in :ref:`domains`.
|
2008-03-15 04:06:04 -05:00
|
|
|
|
|
|
|
However, there is also an explicit directive available, to make the index more
|
|
|
|
comprehensive and enable index entries in documents where information is not
|
|
|
|
mainly contained in information units, such as the language reference.
|
|
|
|
|
2008-03-16 06:19:26 -05:00
|
|
|
.. directive:: .. index:: <entries>
|
|
|
|
|
|
|
|
This directive contains one or more index entries. Each entry consists of a
|
|
|
|
type and a value, separated by a colon.
|
|
|
|
|
|
|
|
For example::
|
|
|
|
|
|
|
|
.. index::
|
|
|
|
single: execution; context
|
|
|
|
module: __main__
|
|
|
|
module: sys
|
|
|
|
triple: module; search; path
|
|
|
|
|
2008-04-06 12:41:51 -05:00
|
|
|
The execution context
|
|
|
|
---------------------
|
|
|
|
|
|
|
|
...
|
|
|
|
|
2010-03-01 07:37:31 -06:00
|
|
|
This directive contains five entries, which will be converted to entries in
|
|
|
|
the generated index which link to the exact location of the index statement
|
|
|
|
(or, in case of offline media, the corresponding page number).
|
2008-03-16 06:19:26 -05:00
|
|
|
|
2008-04-06 12:41:51 -05:00
|
|
|
Since index directives generate cross-reference targets at their location in
|
|
|
|
the source, it makes sense to put them *before* the thing they refer to --
|
|
|
|
e.g. a heading, as in the example above.
|
|
|
|
|
2008-03-16 06:19:26 -05:00
|
|
|
The possible entry types are:
|
2008-03-15 04:06:04 -05:00
|
|
|
|
2008-03-16 06:19:26 -05:00
|
|
|
single
|
|
|
|
Creates a single index entry. Can be made a subentry by separating the
|
2010-03-01 07:37:31 -06:00
|
|
|
subentry text with a semicolon (this notation is also used below to
|
|
|
|
describe what entries are created).
|
2008-03-16 06:19:26 -05:00
|
|
|
pair
|
|
|
|
``pair: loop; statement`` is a shortcut that creates two index entries,
|
|
|
|
namely ``loop; statement`` and ``statement; loop``.
|
|
|
|
triple
|
2010-03-01 07:37:31 -06:00
|
|
|
Likewise, ``triple: module; search; path`` is a shortcut that creates
|
|
|
|
three index entries, which are ``module; search path``, ``search; path,
|
|
|
|
module`` and ``path; module search``.
|
2008-03-16 06:19:26 -05:00
|
|
|
module, keyword, operator, object, exception, statement, builtin
|
2010-03-01 07:37:31 -06:00
|
|
|
These all create two index entries. For example, ``module: hashlib``
|
|
|
|
creates the entries ``module; hashlib`` and ``hashlib; module``. (These
|
|
|
|
are Python-specific and therefore deprecated.)
|
2008-03-15 04:06:04 -05:00
|
|
|
|
2008-03-16 06:19:26 -05:00
|
|
|
For index directives containing only "single" entries, there is a shorthand
|
|
|
|
notation::
|
2008-03-15 04:06:04 -05:00
|
|
|
|
2008-03-16 06:19:26 -05:00
|
|
|
.. index:: BNF, grammar, syntax, notation
|
2008-03-15 04:06:04 -05:00
|
|
|
|
2008-03-16 06:19:26 -05:00
|
|
|
This creates four index entries.
|
2008-03-15 04:06:04 -05:00
|
|
|
|
|
|
|
|
2008-03-16 06:19:26 -05:00
|
|
|
Glossary
|
|
|
|
--------
|
2008-03-15 04:06:04 -05:00
|
|
|
|
2010-03-01 07:37:31 -06:00
|
|
|
.. directive:: .. glossary::
|
2008-03-16 06:19:26 -05:00
|
|
|
|
|
|
|
This directive must contain a reST definition list with terms and
|
|
|
|
definitions. The definitions will then be referencable with the :role:`term`
|
|
|
|
role. Example::
|
|
|
|
|
|
|
|
.. glossary::
|
|
|
|
|
|
|
|
environment
|
2009-03-15 17:34:19 -05:00
|
|
|
A structure where information about all documents under the root is
|
|
|
|
saved, and used for cross-referencing. The environment is pickled
|
|
|
|
after the parsing stage, so that successive runs only need to read
|
|
|
|
and parse new and changed documents.
|
2008-03-15 04:06:04 -05:00
|
|
|
|
2008-05-02 05:32:08 -05:00
|
|
|
source directory
|
2009-03-15 17:34:19 -05:00
|
|
|
The directory which, including its subdirectories, contains all
|
|
|
|
source files for one Sphinx project.
|
|
|
|
|
|
|
|
.. versionadded:: 0.6
|
|
|
|
You can now give the glossary directive a ``:sorted:`` flag that will
|
|
|
|
automatically sort the entries alphabetically.
|
2008-03-15 04:06:04 -05:00
|
|
|
|
|
|
|
|
|
|
|
Grammar production displays
|
|
|
|
---------------------------
|
|
|
|
|
|
|
|
Special markup is available for displaying the productions of a formal grammar.
|
|
|
|
The markup is simple and does not attempt to model all aspects of BNF (or any
|
|
|
|
derived forms), but provides enough to allow context-free grammars to be
|
|
|
|
displayed in a way that causes uses of a symbol to be rendered as hyperlinks to
|
|
|
|
the definition of the symbol. There is this directive:
|
|
|
|
|
2010-03-01 07:53:30 -06:00
|
|
|
.. directive:: .. productionlist:: [name]
|
2008-03-15 04:06:04 -05:00
|
|
|
|
|
|
|
This directive is used to enclose a group of productions. Each production is
|
|
|
|
given on a single line and consists of a name, separated by a colon from the
|
|
|
|
following definition. If the definition spans multiple lines, each
|
|
|
|
continuation line must begin with a colon placed at the same column as in the
|
|
|
|
first line.
|
|
|
|
|
2010-03-01 07:53:30 -06:00
|
|
|
The argument to :dir:`productionlist` serves to distinguish different sets of
|
|
|
|
production lists that belong to different grammars.
|
|
|
|
|
2008-03-15 04:06:04 -05:00
|
|
|
Blank lines are not allowed within ``productionlist`` directive arguments.
|
|
|
|
|
|
|
|
The definition can contain token names which are marked as interpreted text
|
|
|
|
(e.g. ``sum ::= `integer` "+" `integer```) -- this generates cross-references
|
2010-03-01 07:53:30 -06:00
|
|
|
to the productions of these tokens. Outside of the production list, you can
|
|
|
|
reference to token productions using :role:`token`.
|
2008-03-15 04:06:04 -05:00
|
|
|
|
|
|
|
Note that no further reST parsing is done in the production, so that you
|
|
|
|
don't have to escape ``*`` or ``|`` characters.
|
|
|
|
|
|
|
|
The following is an example taken from the Python Reference Manual::
|
|
|
|
|
|
|
|
.. productionlist::
|
|
|
|
try_stmt: try1_stmt | try2_stmt
|
|
|
|
try1_stmt: "try" ":" `suite`
|
|
|
|
: ("except" [`expression` ["," `target`]] ":" `suite`)+
|
|
|
|
: ["else" ":" `suite`]
|
|
|
|
: ["finally" ":" `suite`]
|
|
|
|
try2_stmt: "try" ":" `suite`
|
|
|
|
: "finally" ":" `suite`
|