Sophie

Sophie

distrib > Mageia > 4 > i586 > media > core-release > by-pkgid > c95717a2237548a7bdaddf39c85b0f0f > files > 136

python-sphinx-doc-1.1.3-7.mga4.noarch.rpm



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>reStructuredText Primer &mdash; Sphinx 1.1.3 documentation</title>
    
    <link rel="stylesheet" href="_static/sphinxdoc.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '',
        VERSION:     '1.1.3',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="_static/jquery.js"></script>
    <script type="text/javascript" src="_static/underscore.js"></script>
    <script type="text/javascript" src="_static/doctools.js"></script>
    <link rel="search" type="application/opensearchdescription+xml"
          title="Search within Sphinx 1.1.3 documentation"
          href="_static/opensearch.xml"/>
    <link rel="top" title="Sphinx 1.1.3 documentation" href="index.html" />
    <link rel="next" title="Sphinx Markup Constructs" href="markup/index.html" />
    <link rel="prev" title="Invocation of sphinx-build" href="invocation.html" />
 
<style type="text/css">
  table.right { float: right; margin-left: 20px; }
  table.right td { border: 1px solid #ccc; }
</style>

  </head>
  <body>
<div style="background-color: white; text-align: left; padding: 10px 10px 15px 15px">
<img src="_static/sphinx.png" alt="Sphinx logo" />
</div>

    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="markup/index.html" title="Sphinx Markup Constructs"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="invocation.html" title="Invocation of sphinx-build"
             accesskey="P">previous</a> |</li>
        <li><a href="index.html">Sphinx home</a>&nbsp;|&nbsp;</li>
        <li><a href="contents.html">Documentation</a>
          &raquo;</li>
 
      </ul>
    </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
  <h3><a href="contents.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">reStructuredText Primer</a><ul>
<li><a class="reference internal" href="#paragraphs">Paragraphs</a></li>
<li><a class="reference internal" href="#inline-markup">Inline markup</a></li>
<li><a class="reference internal" href="#lists-and-quote-like-blocks">Lists and Quote-like blocks</a></li>
<li><a class="reference internal" href="#source-code">Source Code</a></li>
<li><a class="reference internal" href="#tables">Tables</a></li>
<li><a class="reference internal" href="#hyperlinks">Hyperlinks</a><ul>
<li><a class="reference internal" href="#external-links">External links</a></li>
<li><a class="reference internal" href="#internal-links">Internal links</a></li>
</ul>
</li>
<li><a class="reference internal" href="#sections">Sections</a></li>
<li><a class="reference internal" href="#explicit-markup">Explicit Markup</a></li>
<li><a class="reference internal" href="#directives">Directives</a></li>
<li><a class="reference internal" href="#images">Images</a></li>
<li><a class="reference internal" href="#footnotes">Footnotes</a></li>
<li><a class="reference internal" href="#citations">Citations</a></li>
<li><a class="reference internal" href="#substitutions">Substitutions</a></li>
<li><a class="reference internal" href="#comments">Comments</a></li>
<li><a class="reference internal" href="#source-encoding">Source encoding</a></li>
<li><a class="reference internal" href="#gotchas">Gotchas</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="invocation.html"
                        title="previous chapter">Invocation of sphinx-build</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="markup/index.html"
                        title="next chapter">Sphinx Markup Constructs</a></p>
  <h3>This Page</h3>
  <ul class="this-page-menu">
    <li><a href="_sources/rest.txt"
           rel="nofollow">Show Source</a></li>
  </ul>
<div id="searchbox" style="display: none">
  <h3>Quick search</h3>
    <form class="search" action="search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="restructuredtext-primer">
<span id="rst-primer"></span><h1>reStructuredText Primer<a class="headerlink" href="#restructuredtext-primer" title="Permalink to this headline">¶</a></h1>
<p>This section is a brief introduction to reStructuredText (reST) concepts and
syntax, intended to provide authors with enough information to author documents
productively.  Since reST was designed to be a simple, unobtrusive markup
language, this will not take too long.</p>
<div class="admonition-see-also admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last">The authoritative <a class="reference external" href="http://docutils.sourceforge.net/rst.html">reStructuredText User Documentation</a>.  The &#8220;ref&#8221; links in this
document link to the description of the individual constructs in the reST
reference.</p>
</div>
<div class="section" id="paragraphs">
<h2>Paragraphs<a class="headerlink" href="#paragraphs" title="Permalink to this headline">¶</a></h2>
<p>The paragraph (<a class="reference external" href="http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#paragraphs">ref</a>) is the most basic block in a reST
document.  Paragraphs are simply chunks of text separated by one or more blank
lines.  As in Python, indentation is significant in reST, so all lines of the
same paragraph must be left-aligned to the same level of indentation.</p>
</div>
<div class="section" id="inline-markup">
<span id="inlinemarkup"></span><h2>Inline markup<a class="headerlink" href="#inline-markup" title="Permalink to this headline">¶</a></h2>
<p>The standard reST inline markup is quite simple: use</p>
<ul class="simple">
<li>one asterisk: <tt class="docutils literal"><span class="pre">*text*</span></tt> for emphasis (italics),</li>
<li>two asterisks: <tt class="docutils literal"><span class="pre">**text**</span></tt> for strong emphasis (boldface), and</li>
<li>backquotes: <tt class="docutils literal"><span class="pre">``text``</span></tt> for code samples.</li>
</ul>
<p>If asterisks or backquotes appear in running text and could be confused with
inline markup delimiters, they have to be escaped with a backslash.</p>
<p>Be aware of some restrictions of this markup:</p>
<ul class="simple">
<li>it may not be nested,</li>
<li>content may not start or end with whitespace: <tt class="docutils literal"><span class="pre">*</span> <span class="pre">text*</span></tt> is wrong,</li>
<li>it must be separated from surrounding text by non-word characters.  Use a
backslash escaped space to work around that: <tt class="docutils literal"><span class="pre">thisis\</span> <span class="pre">*one*\</span> <span class="pre">word</span></tt>.</li>
</ul>
<p>These restrictions may be lifted in future versions of the docutils.</p>
<p>reST also allows for custom &#8220;interpreted text roles&#8221;&#8217;, which signify that the
enclosed text should be interpreted in a specific way.  Sphinx uses this to
provide semantic markup and cross-referencing of identifiers, as described in
the appropriate section.  The general syntax is <tt class="docutils literal"><span class="pre">:rolename:`content`</span></tt>.</p>
<p>Standard reST provides the following roles:</p>
<ul class="simple">
<li><a class="reference external" href="http://docutils.sourceforge.net/docs/ref/rst/roles.html#emphasis">emphasis</a> &#8211; alternate spelling for <tt class="docutils literal"><span class="pre">*emphasis*</span></tt></li>
<li><a class="reference external" href="http://docutils.sourceforge.net/docs/ref/rst/roles.html#strong">strong</a> &#8211; alternate spelling for <tt class="docutils literal"><span class="pre">**strong**</span></tt></li>
<li><a class="reference external" href="http://docutils.sourceforge.net/docs/ref/rst/roles.html#literal">literal</a> &#8211; alternate spelling for <tt class="docutils literal"><span class="pre">``literal``</span></tt></li>
<li><a class="reference external" href="http://docutils.sourceforge.net/docs/ref/rst/roles.html#subscript">subscript</a> &#8211; subscript text</li>
<li><a class="reference external" href="http://docutils.sourceforge.net/docs/ref/rst/roles.html#superscript">superscript</a> &#8211; superscript text</li>
<li><a class="reference external" href="http://docutils.sourceforge.net/docs/ref/rst/roles.html#title-reference">title-reference</a> &#8211; for titles of books, periodicals, and other
materials</li>
</ul>
<p>See <a class="reference internal" href="markup/inline.html#inline-markup"><em>Inline markup</em></a> for roles added by Sphinx.</p>
</div>
<div class="section" id="lists-and-quote-like-blocks">
<h2>Lists and Quote-like blocks<a class="headerlink" href="#lists-and-quote-like-blocks" title="Permalink to this headline">¶</a></h2>
<p>List markup (<a class="reference external" href="http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#bullet-lists">ref</a>) is natural: just place an asterisk at
the start of a paragraph and indent properly.  The same goes for numbered lists;
they can also be autonumbered using a <tt class="docutils literal"><span class="pre">#</span></tt> sign:</p>
<div class="highlight-rest"><pre>* This is a bulleted list.
* It has two items, the second
  item uses two lines.

1. This is a numbered list.
2. It has two items too.

#. This is a numbered list.
#. It has two items too.</pre>
</div>
<p>Nested lists are possible, but be aware that they must be separated from the
parent list items by blank lines:</p>
<div class="highlight-rest"><pre>* this is
* a list

  * with a nested list
  * and some subitems

* and here the parent list continues</pre>
</div>
<p>Definition lists (<a class="reference external" href="http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#definition-lists">ref</a>) are created as follows:</p>
<div class="highlight-rest"><pre>term (up to a line of text)
   Definition of the term, which must be indented

   and can even consist of multiple paragraphs

next term
   Description.</pre>
</div>
<p>Note that the term cannot have more than one line of text.</p>
<p>Quoted paragraphs (<a class="reference external" href="http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#block-quotes">ref</a>) are created by just indenting
them more than the surrounding paragraphs.</p>
<p>Line blocks (<a class="reference external" href="http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#line-blocks">ref</a>) are a way of preserving line breaks:</p>
<div class="highlight-rest"><pre>| These lines are
| broken exactly like in
| the source file.</pre>
</div>
<p>There are also several more special blocks available:</p>
<ul class="simple">
<li>field lists (<a class="reference external" href="http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#field-lists">ref</a>)</li>
<li>option lists (<a class="reference external" href="http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#option-lists">ref</a>)</li>
<li>quoted literal blocks (<a class="reference external" href="http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#quoted-literal-blocks">ref</a>)</li>
<li>doctest blocks (<a class="reference external" href="http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#doctest-blocks">ref</a>)</li>
</ul>
</div>
<div class="section" id="source-code">
<h2>Source Code<a class="headerlink" href="#source-code" title="Permalink to this headline">¶</a></h2>
<p>Literal code blocks (<a class="reference external" href="http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#literal-blocks">ref</a>) are introduced by ending a
paragraph with the special marker <tt class="docutils literal"><span class="pre">::</span></tt>.  The literal block must be indented
(and, like all paragraphs, separated from the surrounding ones by blank lines):</p>
<div class="highlight-rest"><pre>This is a normal text paragraph. The next paragraph is a code sample::

   It is not processed in any way, except
   that the indentation is removed.

   It can span multiple lines.

This is a normal text paragraph again.</pre>
</div>
<p>The handling of the <tt class="docutils literal"><span class="pre">::</span></tt> marker is smart:</p>
<ul class="simple">
<li>If it occurs as a paragraph of its own, that paragraph is completely left
out of the document.</li>
<li>If it is preceded by whitespace, the marker is removed.</li>
<li>If it is preceded by non-whitespace, the marker is replaced by a single
colon.</li>
</ul>
<p>That way, the second sentence in the above example&#8217;s first paragraph would be
rendered as &#8220;The next paragraph is a code sample:&#8221;.</p>
</div>
<div class="section" id="tables">
<span id="rst-tables"></span><h2>Tables<a class="headerlink" href="#tables" title="Permalink to this headline">¶</a></h2>
<p>Two forms of tables are supported.  For <em>grid tables</em> (<a class="reference external" href="http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#grid-tables">ref</a>), you have to &#8220;paint&#8221; the cell grid yourself.  They look like
this:</p>
<div class="highlight-rest"><pre>+------------------------+------------+----------+----------+
| Header row, column 1   | Header 2   | Header 3 | Header 4 |
| (header rows optional) |            |          |          |
+========================+============+==========+==========+
| body row 1, column 1   | column 2   | column 3 | column 4 |
+------------------------+------------+----------+----------+
| body row 2             | ...        | ...      |          |
+------------------------+------------+----------+----------+</pre>
</div>
<p><em>Simple tables</em> (<a class="reference external" href="http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#simple-tables">ref</a>) are easier to write, but
limited: they must contain more than one row, and the first column cannot
contain multiple lines.  They look like this:</p>
<div class="highlight-rest"><pre>=====  =====  =======
A      B      A and B
=====  =====  =======
False  False  False
True   False  False
False  True   False
True   True   True
=====  =====  =======</pre>
</div>
</div>
<div class="section" id="hyperlinks">
<h2>Hyperlinks<a class="headerlink" href="#hyperlinks" title="Permalink to this headline">¶</a></h2>
<div class="section" id="external-links">
<h3>External links<a class="headerlink" href="#external-links" title="Permalink to this headline">¶</a></h3>
<p>Use <tt class="docutils literal"><span class="pre">`Link</span> <span class="pre">text</span> <span class="pre">&lt;http://example.com/&gt;`_</span></tt> for inline web links.  If the link
text should be the web address, you don&#8217;t need special markup at all, the parser
finds links and mail addresses in ordinary text.</p>
<p>You can also separate the link and the target definition (<a class="reference external" href="http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#hyperlink-targets">ref</a>), like this:</p>
<div class="highlight-rest"><pre>This is a paragraph that contains `a link`_.

.. _a link: http://example.com/</pre>
</div>
</div>
<div class="section" id="internal-links">
<h3>Internal links<a class="headerlink" href="#internal-links" title="Permalink to this headline">¶</a></h3>
<p>Internal linking is done via a special reST role provided by Sphinx, see the
section on specific markup, <a class="reference internal" href="markup/inline.html#ref-role"><em>Cross-referencing arbitrary locations</em></a>.</p>
</div>
</div>
<div class="section" id="sections">
<h2>Sections<a class="headerlink" href="#sections" title="Permalink to this headline">¶</a></h2>
<p>Section headers (<a class="reference external" href="http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#sections">ref</a>) are created by underlining (and
optionally overlining) the section title with a punctuation character, at least
as long as the text:</p>
<div class="highlight-rest"><pre>=================
This is a heading
=================</pre>
</div>
<p>Normally, there are no heading levels assigned to certain characters as the
structure is determined from the succession of headings.  However, for the
Python documentation, this convention is used which you may follow:</p>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">#</span></tt> with overline, for parts</li>
<li><tt class="docutils literal"><span class="pre">*</span></tt> with overline, for chapters</li>
<li><tt class="docutils literal"><span class="pre">=</span></tt>, for sections</li>
<li><tt class="docutils literal"><span class="pre">-</span></tt>, for subsections</li>
<li><tt class="docutils literal"><span class="pre">^</span></tt>, for subsubsections</li>
<li><tt class="docutils literal"><span class="pre">&quot;</span></tt>, for paragraphs</li>
</ul>
<p>Of course, you are free to use your own marker characters (see the reST
documentation), and use a deeper nesting level, but keep in mind that most
target formats (HTML, LaTeX) have a limited supported nesting depth.</p>
</div>
<div class="section" id="explicit-markup">
<h2>Explicit Markup<a class="headerlink" href="#explicit-markup" title="Permalink to this headline">¶</a></h2>
<p>&#8220;Explicit markup&#8221; (<a class="reference external" href="http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#explicit-markup-blocks">ref</a>) is used in reST for
most constructs that need special handling, such as footnotes,
specially-highlighted paragraphs, comments, and generic directives.</p>
<p>An explicit markup block begins with a line starting with <tt class="docutils literal"><span class="pre">..</span></tt> followed by
whitespace and is terminated by the next paragraph at the same level of
indentation.  (There needs to be a blank line between explicit markup and normal
paragraphs.  This may all sound a bit complicated, but it is intuitive enough
when you write it.)</p>
</div>
<div class="section" id="directives">
<span id="id1"></span><h2>Directives<a class="headerlink" href="#directives" title="Permalink to this headline">¶</a></h2>
<p>A directive (<a class="reference external" href="http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#directives">ref</a>) is a generic block of explicit markup.
Besides roles, it is one of the extension mechanisms of reST, and Sphinx makes
heavy use of it.</p>
<p>Docutils supports the following directives:</p>
<ul>
<li><p class="first">Admonitions: <a class="reference external" href="http://docutils.sourceforge.net/docs/ref/rst/directives.html#attention">attention</a>, <a class="reference external" href="http://docutils.sourceforge.net/docs/ref/rst/directives.html#caution">caution</a>, <a class="reference external" href="http://docutils.sourceforge.net/docs/ref/rst/directives.html#danger">danger</a>,
<a class="reference external" href="http://docutils.sourceforge.net/docs/ref/rst/directives.html#error">error</a>, <a class="reference external" href="http://docutils.sourceforge.net/docs/ref/rst/directives.html#hint">hint</a>, <a class="reference external" href="http://docutils.sourceforge.net/docs/ref/rst/directives.html#important">important</a>, <a class="reference external" href="http://docutils.sourceforge.net/docs/ref/rst/directives.html#note">note</a>,
<a class="reference external" href="http://docutils.sourceforge.net/docs/ref/rst/directives.html#tip">tip</a>, <a class="reference external" href="http://docutils.sourceforge.net/docs/ref/rst/directives.html#warning">warning</a> and the generic <a class="reference external" href="http://docutils.sourceforge.net/docs/ref/rst/directives.html#admonition">admonition</a>.
(Most themes style only &#8220;note&#8221; and &#8220;warning&#8221; specially.)</p>
</li>
<li><p class="first">Images:</p>
<ul class="simple">
<li><a class="reference external" href="http://docutils.sourceforge.net/docs/ref/rst/directives.html#image">image</a> (see also <a class="reference internal" href="#images">Images</a> below)</li>
<li><a class="reference external" href="http://docutils.sourceforge.net/docs/ref/rst/directives.html#figure">figure</a> (an image with caption and optional legend)</li>
</ul>
</li>
<li><p class="first">Additional body elements:</p>
<ul class="simple">
<li><a class="reference external" href="http://docutils.sourceforge.net/docs/ref/rst/directives.html#table-of-contents">contents</a> (a local, i.e. for the current file
only, table of contents)</li>
<li><a class="reference external" href="http://docutils.sourceforge.net/docs/ref/rst/directives.html#container">container</a> (a container with a custom class, useful to generate an
outer <tt class="docutils literal"><span class="pre">&lt;div&gt;</span></tt> in HTML)</li>
<li><a class="reference external" href="http://docutils.sourceforge.net/docs/ref/rst/directives.html#rubric">rubric</a> (a heading without relation to the document sectioning)</li>
<li><a class="reference external" href="http://docutils.sourceforge.net/docs/ref/rst/directives.html#topic">topic</a>, <a class="reference external" href="http://docutils.sourceforge.net/docs/ref/rst/directives.html#sidebar">sidebar</a> (special highlighted body elements)</li>
<li><a class="reference external" href="http://docutils.sourceforge.net/docs/ref/rst/directives.html#parsed-literal">parsed-literal</a> (literal block that supports inline markup)</li>
<li><a class="reference external" href="http://docutils.sourceforge.net/docs/ref/rst/directives.html#epigraph">epigraph</a> (a block quote with optional attribution line)</li>
<li><a class="reference external" href="http://docutils.sourceforge.net/docs/ref/rst/directives.html#highlights">highlights</a>, <a class="reference external" href="http://docutils.sourceforge.net/docs/ref/rst/directives.html#pull-quote">pull-quote</a> (block quotes with their own
class attribute)</li>
<li><a class="reference external" href="http://docutils.sourceforge.net/docs/ref/rst/directives.html#compound">compound</a> (a compound paragraph)</li>
</ul>
</li>
<li><p class="first">Special tables:</p>
<ul class="simple">
<li><a class="reference external" href="http://docutils.sourceforge.net/docs/ref/rst/directives.html#table">table</a> (a table with title)</li>
<li><a class="reference external" href="http://docutils.sourceforge.net/docs/ref/rst/directives.html#csv-table">csv-table</a> (a table generated from comma-separated values)</li>
<li><a class="reference external" href="http://docutils.sourceforge.net/docs/ref/rst/directives.html#list-table">list-table</a> (a table generated from a list of lists)</li>
</ul>
</li>
<li><p class="first">Special directives:</p>
<ul class="simple">
<li><a class="reference external" href="http://docutils.sourceforge.net/docs/ref/rst/directives.html#raw">raw</a> (include raw target-format markup)</li>
<li><a class="reference external" href="http://docutils.sourceforge.net/docs/ref/rst/directives.html#include">include</a> (include reStructuredText from another file)
&#8211; in Sphinx, when given an absolute include file path, this directive takes
it as relative to the source directory</li>
<li><a class="reference external" href="http://docutils.sourceforge.net/docs/ref/rst/directives.html#class">class</a> (assign a class attribute to the next element) <a class="footnote-reference" href="#id3" id="id2">[1]</a></li>
</ul>
</li>
<li><p class="first">HTML specifics:</p>
<ul class="simple">
<li><a class="reference external" href="http://docutils.sourceforge.net/docs/ref/rst/directives.html#meta">meta</a> (generation of HTML <tt class="docutils literal"><span class="pre">&lt;meta&gt;</span></tt> tags)</li>
<li><a class="reference external" href="http://docutils.sourceforge.net/docs/ref/rst/directives.html#title">title</a> (override document title)</li>
</ul>
</li>
<li><p class="first">Influencing markup:</p>
<ul class="simple">
<li><a class="reference external" href="http://docutils.sourceforge.net/docs/ref/rst/directives.html#default-role">default-role</a> (set a new default role)</li>
<li><a class="reference external" href="http://docutils.sourceforge.net/docs/ref/rst/directives.html#role">role</a> (create a new role)</li>
</ul>
<p>Since these are only per-file, better use Sphinx&#8217; facilities for setting the
<a class="reference internal" href="config.html#confval-default_role"><tt class="xref std std-confval docutils literal"><span class="pre">default_role</span></tt></a>.</p>
</li>
</ul>
<p>Do <em>not</em> use the directives <a class="reference external" href="http://docutils.sourceforge.net/docs/ref/rst/directives.html#sectnum">sectnum</a>, <a class="reference external" href="http://docutils.sourceforge.net/docs/ref/rst/directives.html#header">header</a> and
<a class="reference external" href="http://docutils.sourceforge.net/docs/ref/rst/directives.html#footer">footer</a>.</p>
<p>Directives added by Sphinx are described in <a class="reference internal" href="markup/index.html#sphinxmarkup"><em>Sphinx Markup Constructs</em></a>.</p>
<p>Basically, a directive consists of a name, arguments, options and content. (Keep
this terminology in mind, it is used in the next chapter describing custom
directives.)  Looking at this example,</p>
<div class="highlight-rest"><pre>.. function:: foo(x)
              foo(y, z)
   :module: some.module.name

   Return a line of text input from the user.</pre>
</div>
<p><tt class="docutils literal"><span class="pre">function</span></tt> is the directive name.  It is given two arguments here, the
remainder of the first line and the second line, as well as one option
<tt class="docutils literal"><span class="pre">module</span></tt> (as you can see, options are given in the lines immediately following
the arguments and indicated by the colons).  Options must be indented to the
same level as the directive content.</p>
<p>The directive content follows after a blank line and is indented relative to the
directive start.</p>
</div>
<div class="section" id="images">
<h2>Images<a class="headerlink" href="#images" title="Permalink to this headline">¶</a></h2>
<p>reST supports an image directive (<a class="reference external" href="http://docutils.sourceforge.net/docs/ref/rst/directives.html#image">ref</a>), used like so:</p>
<div class="highlight-rest"><pre>.. image:: gnu.png
   (options)</pre>
</div>
<p>When used within Sphinx, the file name given (here <tt class="docutils literal"><span class="pre">gnu.png</span></tt>) must either be
relative to the source file, or absolute which means that they are relative to
the top source directory.  For example, the file <tt class="docutils literal"><span class="pre">sketch/spam.rst</span></tt> could refer
to the image <tt class="docutils literal"><span class="pre">images/spam.png</span></tt> as <tt class="docutils literal"><span class="pre">../images/spam.png</span></tt> or
<tt class="docutils literal"><span class="pre">/images/spam.png</span></tt>.</p>
<p>Sphinx will automatically copy image files over to a subdirectory of the output
directory on building (e.g. the <tt class="docutils literal"><span class="pre">_static</span></tt> directory for HTML output.)</p>
<p>Interpretation of image size options (<tt class="docutils literal"><span class="pre">width</span></tt> and <tt class="docutils literal"><span class="pre">height</span></tt>) is as follows:
if the size has no unit or the unit is pixels, the given size will only be
respected for output channels that support pixels (i.e. not in LaTeX output).
Other units (like <tt class="docutils literal"><span class="pre">pt</span></tt> for points) will be used for HTML and LaTeX output.</p>
<p>Sphinx extends the standard docutils behavior by allowing an asterisk for the
extension:</p>
<div class="highlight-rest"><pre>.. image:: gnu.*</pre>
</div>
<p>Sphinx then searches for all images matching the provided pattern and determines
their type.  Each builder then chooses the best image out of these candidates.
For instance, if the file name <tt class="docutils literal"><span class="pre">gnu.*</span></tt> was given and two files <tt class="file docutils literal"><span class="pre">gnu.pdf</span></tt>
and <tt class="file docutils literal"><span class="pre">gnu.png</span></tt> existed in the source tree, the LaTeX builder would choose
the former, while the HTML builder would prefer the latter.</p>
<p class="versionchanged">
<span class="versionmodified">Changed in version 0.4: </span>Added the support for file names ending in an asterisk.</p>
<p class="versionchanged">
<span class="versionmodified">Changed in version 0.6: </span>Image paths can now be absolute.</p>
</div>
<div class="section" id="footnotes">
<h2>Footnotes<a class="headerlink" href="#footnotes" title="Permalink to this headline">¶</a></h2>
<p>For footnotes (<a class="reference external" href="http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#footnotes">ref</a>), use <tt class="docutils literal"><span class="pre">[#name]_</span></tt> to mark the footnote
location, and add the footnote body at the bottom of the document after a
&#8220;Footnotes&#8221; rubric heading, like so:</p>
<div class="highlight-rest"><pre>Lorem ipsum [#f1]_ dolor sit amet ... [#f2]_

.. rubric:: Footnotes

.. [#f1] Text of the first footnote.
.. [#f2] Text of the second footnote.</pre>
</div>
<p>You can also explicitly number the footnotes (<tt class="docutils literal"><span class="pre">[1]_</span></tt>) or use auto-numbered
footnotes without names (<tt class="docutils literal"><span class="pre">[#]_</span></tt>).</p>
</div>
<div class="section" id="citations">
<h2>Citations<a class="headerlink" href="#citations" title="Permalink to this headline">¶</a></h2>
<p>Standard reST citations (<a class="reference external" href="http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#citations">ref</a>) are supported, with the
additional feature that they are &#8220;global&#8221;, i.e. all citations can be referenced
from all files.  Use them like so:</p>
<div class="highlight-rest"><pre>Lorem ipsum [Ref]_ dolor sit amet.

.. [Ref] Book or article reference, URL or whatever.</pre>
</div>
<p>Citation usage is similar to footnote usage, but with a label that is not
numeric or begins with <tt class="docutils literal"><span class="pre">#</span></tt>.</p>
</div>
<div class="section" id="substitutions">
<h2>Substitutions<a class="headerlink" href="#substitutions" title="Permalink to this headline">¶</a></h2>
<p>reST supports &#8220;substitutions&#8221; (<a class="reference external" href="http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#substitution-definitions">ref</a>), which
are pieces of text and/or markup referred to in the text by <tt class="docutils literal"><span class="pre">|name|</span></tt>.  They
are defined like footnotes with explicit markup blocks, like this:</p>
<div class="highlight-rest"><pre>.. |name| replace:: replacement *text*</pre>
</div>
<p>or this:</p>
<div class="highlight-rest"><pre>.. |caution| image:: warning.png
             :alt: Warning!</pre>
</div>
<p>See the <a class="reference external" href="http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#substitution-definitions">reST reference for substitutions</a>
for details.</p>
<p>If you want to use some substitutions for all documents, put them into
<a class="reference internal" href="config.html#confval-rst_prolog"><tt class="xref std std-confval docutils literal"><span class="pre">rst_prolog</span></tt></a> or put them into a separate file and include it into all
documents you want to use them in, using the <tt class="xref rst rst-dir docutils literal"><span class="pre">include</span></tt> directive.  (Be
sure to give the include file a file name extension differing from that of other
source files, to avoid Sphinx finding it as a standalone document.)</p>
<p>Sphinx defines some default substitutions, see <a class="reference internal" href="markup/inline.html#default-substitutions"><em>Substitutions</em></a>.</p>
</div>
<div class="section" id="comments">
<h2>Comments<a class="headerlink" href="#comments" title="Permalink to this headline">¶</a></h2>
<p>Every explicit markup block which isn&#8217;t a valid markup construct (like the
footnotes above) is regarded as a comment (<a class="reference external" href="http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#comments">ref</a>).  For
example:</p>
<div class="highlight-rest"><pre>.. This is a comment.</pre>
</div>
<p>You can indent text after a comment start to form multiline comments:</p>
<div class="highlight-rest"><pre>..
   This whole indented block
   is a comment.

   Still in the comment.</pre>
</div>
</div>
<div class="section" id="source-encoding">
<h2>Source encoding<a class="headerlink" href="#source-encoding" title="Permalink to this headline">¶</a></h2>
<p>Since the easiest way to include special characters like em dashes or copyright
signs in reST is to directly write them as Unicode characters, one has to
specify an encoding.  Sphinx assumes source files to be encoded in UTF-8 by
default; you can change this with the <a class="reference internal" href="config.html#confval-source_encoding"><tt class="xref std std-confval docutils literal"><span class="pre">source_encoding</span></tt></a> config value.</p>
</div>
<div class="section" id="gotchas">
<h2>Gotchas<a class="headerlink" href="#gotchas" title="Permalink to this headline">¶</a></h2>
<p>There are some problems one commonly runs into while authoring reST documents:</p>
<ul class="simple">
<li><strong>Separation of inline markup:</strong> As said above, inline markup spans must be
separated from the surrounding text by non-word characters, you have to use a
backslash-escaped space to get around that.  See <a class="reference external" href="http://docutils.sf.net/docs/ref/rst/restructuredtext.html#inline-markup">the reference</a>
for the details.</li>
<li><strong>No nested inline markup:</strong> Something like <tt class="docutils literal"><span class="pre">*see</span> <span class="pre">:func:`foo`*</span></tt> is not
possible.</li>
</ul>
<p class="rubric">Footnotes</p>
<table class="docutils footnote" frame="void" id="id3" rules="none">
<colgroup><col class="label" /><col /></colgroup>
<tbody valign="top">
<tr><td class="label"><a class="fn-backref" href="#id2">[1]</a></td><td>When the default domain contains a <tt class="xref rst rst-dir docutils literal"><span class="pre">class</span></tt> directive, this directive
will be shadowed.  Therefore, Sphinx re-exports it as <tt class="xref rst rst-dir docutils literal"><span class="pre">rst-class</span></tt>.</td></tr>
</tbody>
</table>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="markup/index.html" title="Sphinx Markup Constructs"
             >next</a> |</li>
        <li class="right" >
          <a href="invocation.html" title="Invocation of sphinx-build"
             >previous</a> |</li>
        <li><a href="index.html">Sphinx home</a>&nbsp;|&nbsp;</li>
        <li><a href="contents.html">Documentation</a>
          &raquo;</li>
 
      </ul>
    </div>
    <div class="footer">
        &copy; Copyright 2007-2011, Georg Brandl.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3.
    </div>
  </body>
</html>