mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
186 lines
6.4 KiB
ReStructuredText
186 lines
6.4 KiB
ReStructuredText
.. highlight:: rest
|
|
|
|
Paragraph-level markup
|
|
----------------------
|
|
|
|
These directives create short paragraphs and can be used inside information
|
|
units as well as normal text:
|
|
|
|
.. directive:: note
|
|
|
|
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.
|
|
|
|
.. directive:: warning
|
|
|
|
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
|
|
appropriate punctuation. This differs from ``note`` in that it is recommended
|
|
over ``note`` for information regarding security.
|
|
|
|
.. directive:: versionadded
|
|
|
|
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.
|
|
|
|
.. directive:: versionchanged
|
|
|
|
Similar to ``versionadded``, but describes when and what changed in the named
|
|
feature in some way (new parameters, changed side effects, etc.).
|
|
|
|
--------------
|
|
|
|
.. directive:: seealso
|
|
|
|
Many sections include a list of references to module documentation or
|
|
external documents. These lists are created using the ``seealso`` directive.
|
|
|
|
The ``seealso`` directive is typically placed in a section just before any
|
|
sub-sections. For the HTML output, it is shown boxed off from the main flow
|
|
of the text.
|
|
|
|
The content of the ``seealso`` directive should be a reST definition list.
|
|
Example::
|
|
|
|
.. seealso::
|
|
|
|
Module :mod:`zipfile`
|
|
Documentation of the :mod:`zipfile` standard module.
|
|
|
|
`GNU tar manual, Basic Tar Format <http://link>`_
|
|
Documentation for tar archive files, including GNU tar extensions.
|
|
|
|
.. directive:: rubric
|
|
|
|
This directive creates a paragraph heading that is not used to create a
|
|
table of contents node. It is currently used for the "Footnotes" caption.
|
|
|
|
.. directive:: centered
|
|
|
|
This directive creates a centered boldfaced paragraph. Use it as follows::
|
|
|
|
.. centered::
|
|
|
|
Paragraph contents.
|
|
|
|
|
|
Table-of-contents markup
|
|
------------------------
|
|
|
|
The :dir:`toctree` directive, which generates tables of contents of
|
|
subdocuments, is described in "Sphinx concepts".
|
|
|
|
For local tables of contents, use the standard reST :dir:`contents` directive.
|
|
|
|
|
|
Index-generating markup
|
|
-----------------------
|
|
|
|
Sphinx automatically creates index entries from all information units (like
|
|
functions, classes or attributes) like discussed before.
|
|
|
|
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.
|
|
|
|
The directive is ``index`` and 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
|
|
|
|
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).
|
|
|
|
The possible entry types are:
|
|
|
|
single
|
|
Creates a single index entry. Can be made a subentry by separating the
|
|
subentry text with a semicolon (this notation is also used below to describe
|
|
what entries are created).
|
|
pair
|
|
``pair: loop; statement`` is a shortcut that creates two index entries,
|
|
namely ``loop; statement`` and ``statement; loop``.
|
|
triple
|
|
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``.
|
|
module, keyword, operator, object, exception, statement, builtin
|
|
These all create two index entries. For example, ``module: hashlib`` creates
|
|
the entries ``module; hashlib`` and ``hashlib; module``.
|
|
|
|
For index directives containing only "single" entries, there is a shorthand
|
|
notation::
|
|
|
|
.. index:: BNF, grammar, syntax, notation
|
|
|
|
This creates four index entries.
|
|
|
|
|
|
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:
|
|
|
|
.. directive:: productionlist
|
|
|
|
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.
|
|
|
|
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
|
|
to the productions of these tokens.
|
|
|
|
Note that no further reST parsing is done in the production, so that you
|
|
don't have to escape ``*`` or ``|`` characters.
|
|
|
|
|
|
.. XXX describe optional first parameter
|
|
|
|
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`
|