reStructuredText

Created on Oct. 25, 2012, 2:46 p.m. by Hevok & updated by Hevok on May 2, 2013, 5:10 p.m.

reStructuredText

Abstract:reStructuredText (reST, ReST, rst) is the superior lightweight markup language designed to be both (a) processable by machines (Denigma) and (b) easy readable by humans. In its essence its just plain-text that uses simple and intuitive construct to indicate structure of a document.

Introduction

reStructuredText (reST) provides an easy-to-read, what-you-see-is-what-you-get plaintext markup syntax and parser system. There are some simple rules to follow:

  • rst is like python, sensitive to indentation
  • blank lines are separated by blank lines

Title/Headings/Sections

To create titles, headings and sections structure either underline or under and overline it:

#####
Title
#####

Header
======

Subsection
----------

The title is unique and is usually defined at the very beginning (that's why it is omitted here):

Lists

Lists are very simple an intuitive implemented and they come in different flavours.

Bullet & Enumerate

- A bullet list item
- Second item

  - A sub item

- Third item
  • A bullet list item
  • Second item
    • A sub item
  • Third item
1) An enumerated list item
2) Second item

   a) Sub item

      i) Sub-sub item

3) Third item which uses
   two lines (note indention).
  1. An enumerated list item
  2. Second item
    1. Sub item
      1. Sub-sub item
  3. Third item which uses two lines (note indention).

Auto-Numbered

#) Another enumerated list item
#) Second item
  1. Another enumerated list item
  2. Second item

Field

A field list allows to simply create some fields with following text being intended:

:Research: About understanding nature.
:Programming: Enables to automate information technologies.
:Design: Requires creativity and innovation.
Research:About understanding nature.
Programming:Enables to automate information technologies.
Design:Requires creativity and innovation.

Definition

An alternative is list definition:

Research
    About understanding nature.
Programming
    Enables to automate information technologies.
Design
    Requires creativity and innovation.
Research
About understanding nature.
Programming
Enables to automate information technologies.
Design
Requires creativity and innovation.

Images

.. image:: http://dgallery.s3.amazonaws.com/rst.png
http://dgallery.s3.amazonaws.com/rst.png
.. image:: http://dgallery.s3.amazonaws.com/denigma_pos.png
    :width: 200px
    :height: 100px
    :align: center
    :alt: Alternative text
Alternative text

Figures

.. figure:: http://dgallery.s3.amazonaws.com/denigma_pos.png
    :width: 200px
    :height: 100px
    :align: center
    :alt: Alternative text
    :figclass: align-center

    Figures are like images but with a caption

    and anything else can be added to it

    .. sourcecode:: python

        import image
Alternative text

Figures are like images but with a caption

and anything else can be added to it

import image

Comments

Comments are marked with simple two dots:

.. comments

Sourcecode

Code block can be marked with the sourcecode directive:

.. sourcecode:: python

    print("Ready to decipher")
print("Ready to decipher")

Tables

There are three different ways to generate a table:

Table can be create via CSV (comma separated synthax):

.. csv-table:: Aspects
    :header: "Facets", "Professions", "Achievment"
    :widths: 20, 20, 20

    "Research", "Scientist", "Ranks"
    "Programming", "Developer", "Grades"
    "Design", "Artist", "Titles"
Aspects
Facets Professions Achievments
Research Scientist Ranks
Programming Developer Grades
Design Artist Titles

Substitutions

Internal Links (alias Named links) are basically Substitutions.

Another more versatile method is

.. |DNA| replace:: Desoxy Ribonucleic Acid

Then insert |DNA| where it has to be spelled out (e.g. Desoxy Ribonucleic Acid is transcripted into RNA).

Aliases

A directive can be used within aliases:

.. |logo| image:: http://dgallery.s3.amazonaws.com/denigma_pos.png
    :width: 100pt
    :height: 50pt
+--------+----------------------+
| |logo| |Space for improvements|
+--------+----------------------+
logo Space for improvements

Boxes

Simple directives allow to define boxes for a variety of cases:

.. note:: Note this **note** box.

.. warning:: There must be space between the directive and the text.

Note

Note this note box.


Warning

There must be space between the directive and the text.


Such boxes appear more obviously when rendered as pdf. Sphinx nicely colours those and also defines additional boxes, like:

.. seealso:: This is a complicated **seealso** box.

.. todo:: Check that all boxes are correctly working and include the missing directives.

Footnotes

[/name]_ can be used to mark a footnote location referring to a footnote at the bottom of an entry in the "Footnotes" rubric section. Footnotes can be explicitly numbered ([1]_) or auto-numbered ([/]_)." style="color: #CC0000">[ name]_ can be used to mark a footnote location referring to a footnote at the bottom of an entry in the "Footnotes" rubric section. Footnotes can be explicitly numbered ([1]_) or auto-numbered ([ ]_).
Everything is possible [#f1]_.

.. rubric:: Footnotes

.. [#f1] If sufficient resources are available.

Everything is possible [1].

Footnotes

[1]If sufficient resources are available.

Citations

Citation references are usually defined at the very bottom of data entry:

.. [Hevok2013] An citation from the future.
      As often used to cite scientific information.

It is cited with the text like this:

[Hevok2013]_
[Hevok2013]An citation from the future. As often used to cite scientific information.

Tags: tutorial, documentation, rest
Categories: Tutorial
Parent: Markup
Children: Block Quotes, Doctext Blocks, Explicit Markup, Images, Inline Markup & Special Characters, Line Blocks, Lists, Literal Blocks, Paragraphs, Preformatting, Rendering, Section Structure, Sections, Tables, Text Styles, Title/Subtitle, Transitions

Update entry (Admin) | See changes

Comment on This Data Unit