ReStructuredText

Last updated
reStructuredText
ReStructuredText Logo.svg
Filename extension
.rst
Internet media type text/x-rst
Developed byDavid Goodger
Initial releaseJune 1, 2001;22 years ago (2001-06-01) [1]
Latest release
Revision 8407
October 29, 2019;4 years ago (2019-10-29)
Open format? Public domain
Website docutils.sourceforge.io/rst.html

reStructuredText (RST, ReST, or reST) is a file format for textual data used primarily in the Python programming language community for technical documentation.

Contents

It is part of the Docutils project of the Python Doc-SIG (Documentation Special Interest Group), aimed at creating a set of tools for Python similar to Javadoc for Java or Plain Old Documentation (POD) for Perl. Docutils can extract comments and information from Python programs, and format them into various forms of program documentation. [2]

In this sense, reStructuredText is a lightweight markup language designed to be both processable by documentation-processing software such as Docutils, and be easily readable by human programmers who are reading and writing Python source code.

History

reStructuredText evolved from an earlier lightweight markup language called StructuredText [3] (developed by Zope). There were a number of problems with StructuredText, and reST was developed to address them. [4] The name reStructuredText was chosen to indicate that reST is a "revised, reworked, and reinterpreted StructuredText." [5]

Parts of the reST syntax were inspired by the Setext language from the early 1990s. Elements of the common RFC822 Internet Message Format and Javadoc formats were also considered for inclusion in the design. [6]

reStructuredText was first released in June 2001. [1] It began to see significant use in the Python community in 2002. [7]

Reference implementation

The reference implementation of the reST parser is a component of the Docutils text processing framework in the Python programming language, but other parsers are available.

There is no official MIME type registered for reStructuredText, but the unofficial one is text/x-rst. [8]

Applications

reStructuredText is commonly used for technical documentation, for example, in documentation of Python libraries. [9] However, it is suitable for a wide range of texts.

Since 2008, reST has been a core component of Python's Sphinx document generation system.

Trac also supports reStructuredText, [10] as do GitHub and Bitbucket.

In 2011, Distributed Proofreaders, which prepared texts for Project Gutenberg, was considering adoption of reST as a basic format from which other ebook formats could be generated. [11] [ needs update ]

In July 2016 the Linux kernel project decided to transition from DocBook based documentation to reStructuredText and the Sphinx toolchain. [12] [13]

The software build tool CMake switched from a custom markup language to reStructuredText in version 3.0 for its documentation. [14]

Examples

Text using rST syntaxCorresponding HTML produced by an rST processorText viewed in a browser
================Document Heading================Heading=======Sub-heading-----------  Paragraphs are separated  by a blank line. 
<h1>Document Heading</h1><h2>Heading</h2><h3>Sub-heading</h3><p>Paragraphs are separated by a blank line.</p>
Document Heading
Heading
Sub-heading

Paragraphs are separated by a blank line.

Text attributes *emphasis*, **strong emphasis**, ``monospace``.  Horizontal rule:  ---- 
<p>Text attributes <em>emphasis</em>, <strong>strong emphasis</strong>, <code>monospace</code>.</p><p>Horizontal rule:</p><hr/>
Text attributes emphasis, strong emphasis, monospace.

Horizontal rule:


Bullet list:  * apples * oranges * pears  Numbered list:  1. lather 2. rinse 3. repeat  Nested lists:  1. fruits     * apple    * banana  2. vegetables     * carrot    * broccoli 
<p>Bullet list:</p><ul><li>apples</li><li>oranges</li><li>pears</li></ul><p>Numbered list:</p><ol><li>lather</li><li>rinse</li><li>repeat</li></ol><p>Nested lists:</p><ol><li>fruits     <ul><li>apple</li><li>banana</li></ul></li><li>vegetables     <ul><li>carrot</li><li>broccoli</li></ul></li></ol>
Bullet list:
  • apples
  • oranges
  • pears

Numbered list:

  1. lather
  2. rinse
  3. repeat

Nested lists:

  1. fruits
    • apple
    • banana
  2. vegetables
    • carrot
    • broccoli
An `example <http://example.com>`_.  ..image:: Icon-pictures.png     :alt: Image  If text is indented, it is treated as a block quotation:      Should array indices start at 0 or 1?     My suggested compromise of 0.5 was rejected without, I thought, proper consideration.     -- Stan Kelly-Bootle  reST uses :: prior to a pre-formatted code block::    Y = lambda f: (lambda x: f(x(x)))(lambda x: f(x(x)))| Multi-line text can | span in tables | with a pipe character. 
<p>An <ahref="http://example.com">example</a>.</p><p><imgalt="Image"src="Icon-pictures.png"/></p><p>If text is indented, it is treated as a block quotation, and the final attribution line is handled automatically:</p><blockquote> Should array indices start at 0 or 1? My suggested compromise of 0.5 was rejected without, I thought, proper consideration. -- Stan Kelly-Bootle</blockquote><p>reST uses :: prior to a pre-formatted code block:</p><preclass="literal-block"> Y = lambda f: (lambda x: f(x(x)))(lambda x: f(x(x))) </pre><p>Multi-line text can<br/>span in tables<br/>with a pipe character.</p>
An example.

Icon-pictures.png

If text is indented, it is treated as a block quotation, and the final attribution line is handled automatically:

Should array indices start at 0 or 1? My suggested compromise of 0.5 was rejected without, I thought, proper consideration.

-- Stan Kelly-Bootle

reST uses :: prior to a pre-formatted code block:

Y = lambda f: (lambda x: f(x(x)))(lambda x: f(x(x))) 

Multi-line text can
span in tables
with a pipe character.

See also

Related Research Articles

<span class="mw-page-title-main">Markup language</span> Modern system for annotating a document

A markuplanguage is a text-encoding system which specifies the structure and formatting of a document and potentially the relationship between its parts. Markup can control the display of a document or enrich its content to facilitate automated processing.

Zope is a family of free and open-source web application servers written in Python, and their associated online community. Zope stands for "Z Object Publishing Environment", and was the first system using the now common object publishing methodology for the Web. Zope has been called a Python killer app, an application that helped put Python in the spotlight.

DocBook is a semantic markup language for technical documentation. It was originally intended for writing technical documents related to computer hardware and software, but it can be used for any other sort of documentation.

<span class="mw-page-title-main">KDevelop</span> Integrated development environment

KDevelop is a free and open-source integrated development environment (IDE) for Unix-like computer operating systems and Windows. It provides editing, navigation and debugging features for several programming languages, and integration with build automation and version-control systems, using a plugin-based architecture.

<span class="mw-page-title-main">Doxygen</span> Free software for generating software documentation from source code

Doxygen is a documentation generator and static analysis tool for software source trees. When used as a documentation generator, Doxygen extracts information from specially-formatted comments within the code. When used for analysis, Doxygen uses its parse tree to generate diagrams and charts of the code structure. Doxygen can cross reference documentation and code, so that the reader of a document can easily refer to the actual code.

<span class="mw-page-title-main">Graphviz</span> Software package for graph visualization

Graphviz is a package of open-source tools initiated by AT&T Labs Research for drawing graphs specified in DOT language scripts having the file name extension "gv". It also provides libraries for software applications to use the tools. Graphviz is free software licensed under the Eclipse Public License.

A lightweight markup language (LML), also termed a simple or humane markup language, is a markup language with simple, unobtrusive syntax. It is designed to be easy to write using any generic text editor and easy to read in its raw form. Lightweight markup languages are used in applications where it may be necessary to read the raw document as well as the final rendered output.

<span class="mw-page-title-main">SCons</span>

SCons is a computer software build tool that automatically analyzes source code file dependencies and operating system adaptation requirements from a software project description and generates final binary executables for installation on the target operating system platform. Its function is analogous to the traditional GNU build system based on the make utility and the autoconf tools.

Single-source publishing, also known as single-sourcing publishing, is a content management method which allows the same source content to be used across different forms of media and more than one time. The labor-intensive and expensive work of editing need only be carried out once, on only one document; that source document can then be stored in one place and reused. This reduces the potential for error, as corrections are only made one time in the source document.

Javadoc is a documentation generator created by Sun Microsystems for the Java language for generating API documentation in HTML format from Java source code. The HTML format is used for adding the convenience of being able to hyperlink related documents together.

<span class="mw-page-title-main">Markdown</span> Plain text markup language

Markdown is a lightweight markup language for creating formatted text using a plain-text editor. John Gruber and Aaron Swartz created Markdown in 2004 as a markup language that is intended to be easy to read in its source code form. Markdown is widely used for blogging and instant messaging, and also used elsewhere in online forums, collaborative software, documentation pages, and readme files.

<span class="mw-page-title-main">CMake</span> Cross-platform, compiler-independent build system generator

In software development, CMake is cross-platform free and open-source software for build automation, testing, packaging and installation of software by using a compiler-independent method. CMake is not a build system itself; it generates another system's build files. It supports directory hierarchies and applications that depend on multiple libraries. It can invoke native build environments such as Make, Qt Creator, Ninja, Android Studio, Apple's Xcode, and Microsoft Visual Studio. It has minimal dependencies, requiring only a C++ compiler on its own build system.

AsciiDoc is a human-readable document format, semantically equivalent to DocBook XML, but using plain-text mark-up conventions. AsciiDoc documents can be created using any text editor and read “as-is”, or rendered to HTML or any other format supported by a DocBook tool-chain, i.e. PDF, TeX, Unix manpages, e-books, slide presentations, etc. Common file extensions for AsciiDoc files are txt and adoc.

<span class="mw-page-title-main">Comment (computer programming)</span> Explanatory note in the source code of a computer program

In computer programming, a comment is a programmer-readable explanation or annotation in the source code of a computer program. They are added with the purpose of making the source code easier for humans to understand, and are generally ignored by compilers and interpreters. The syntax of comments in various programming languages varies considerably.

<span class="mw-page-title-main">Pdoc</span>

Pdoc is a software package for generating API documentation for Python programming language. Built as a successor to Epydoc, Pdoc uses introspection to extract documentation from source code docstrings and allows programmers to generate HTML documentation for chosen Python modules. It is thus functionally similar to Pydoc, Perldoc and Javadoc. It supports identifier cross-linking and Markdown for its doc string format.

Sphinx is a documentation generator written and used by the Python community. It is written in Python, and also used in other environments.

Pydoc is the standard documentation module for the programming language Python. Similar to the functionality of Perldoc within Perl and Javadoc within Java, Pydoc allows Python programmers to access Python's documentation help files, generate text and HTML pages with documentation specifics, and find the appropriate module for a particular job.

Gollum is a wiki software using git as the back end storage mechanism, and written mostly in Ruby. It started life as the wiki system used by the GitHub web hosting system. Although the open source Gollum project and the software currently used to run GitHub wikis have diverged from one another, Gollum strives to maintain compatibility with the latter. Currently it is used by GitLab server to store and interconnect wiki-pages with wiki-links, but the plan is to move complete away from Gollum in the future.

References

  1. 1 2 "Project: reStructuredText - File List". SourceForge. Archived from the original on 19 October 2001. Retrieved 5 February 2023.
  2. Mertz, David (2003-02-01). "XML Matters: reStructuredText". IBM developerWorks . Retrieved 2016-10-05.
  3. "zope.structuredtext Documentation". Read the Docs. Retrieved 2022-08-16.
  4. Goodger, David (2016-05-24). "Problems With StructuredText". Docutils Project. Retrieved 2022-08-16.
  5. Goodger, David (2016-02-26). "Docutils FAQ (Frequently Asked Questions)". Docutils Project. Retrieved 2016-10-05.
  6. Goodger, David (2022-04-02). "A Record of reStructuredText Syntax Alternatives". docutils.sourceforge.io. Docutils Project. Retrieved 2022-08-16.
  7. "Introduction to reStructuredText". Write The Docs. Retrieved 2022-06-25.
  8. "What's the official MIME type for reStructuredText data? in Docutils FAQ". Docutils Project. Retrieved 2017-12-20.
  9. Goodger, David (2002-04-02). "PEP 287 -- reStructuredText Docstring Format". Python Software Foundation . Retrieved 2016-10-05.
  10. "reStructuredText Support in Trac". Trac. 2016-09-13. Retrieved 2016-10-05.
  11. Newby, Greg (2011-01-08). "Minutes of 2010 December 11 meeting" . Distributed Proofreaders. Retrieved 2011-01-08.
  12. "Kernel documentation with Sphinx, part 1: how we got here". LWN.net. 2016-07-06. Retrieved 2016-10-27.
  13. "Sphinx. Linux kernel". Wikipedia. 2024-04-02. Retrieved 2024-04-02.
  14. "CMake 3.0.0 Release Notes". Kitware, Inc. 2014-06-10. Retrieved 2016-10-05.