🌐
Python Developer's Guide
devguide.python.org › documentation › markup
reStructuredText markup
July 28, 2026 - The authoritative reStructuredText User Documentation. All reST files use an indentation of 3 spaces; no tabs are allowed. The maximum line length is 80 characters for normal text, but tables, deeply indented code samples and long links may extend beyond that. Code example bodies should use normal Python ...
🌐
Sphinx
sphinx-doc.org › en › master › usage › restructuredtext › basics.html
reStructuredText Primer — Sphinx documentation
That way, the second sentence in the above example’s first paragraph would be rendered as “The next paragraph is a code sample:”. Code highlighting can be enabled for these literal blocks on a document-wide basis using the highlight directive and on a project-wide basis using the highlight_language configuration option. The code-block directive can be used to set highlighting on a block-by-block basis. These directives are discussed later. Doctest blocks (ref) are interactive Python sessions cut-and-pasted into docstrings.
🌐
Readthedocs
pydoctor.readthedocs.io › en › latest › docformat › restructuredtext_demo › index.html
restructuredtext_demo
If the Python prompt gets in your way when you try to copy and paste and you are not interested in self-testing docstrings, the · This will let you obtain a simple block of colorized text: def fib(n): '''Print a Fibonacci series.''' a, b = 0, 1 while b < n: print b, a, b = b, a+b · reStructuredText defines a lot of inline markup, here's a few of the most common:
🌐
Write the Docs
writethedocs.org › guide › writing › reStructuredText
Introduction to reStructuredText — Write the Docs
What is reStructuredText?: reStructuredText is a lightweight markup language that is used in static site generators like Sphinx. It contains robust tools for semantic markup, reusing content, and c...
🌐
Reddit
reddit.com › r/python › i built an interactive restructuredtext tutorial that runs entirely in your browser
r/Python on Reddit: I built an Interactive reStructuredText Tutorial that runs entirely in your browser
May 15, 2025 -

Hey r/Python!

I wanted to share a project I've been working on: an Interactive reStructuredText Tutorial.

What My Project Does

It's a web-based, hands-on tutorial designed to teach reStructuredText (reST), the markup language used extensively in Python documentation (like Sphinx, docstrings, etc.). The entire tutorial, including the reST rendering, runs directly in your browser using PyScript and Pyodide.

You get a lesson description on one side and an interactive editor on the other. As you type reST in the editor, you see the rendered HTML output update instantly. It covers topics from basic syntax and inline markup to more complex features like directives, roles, tables, and figures.

There's also a separate Playground page for free-form experimentation.

Why I Made It

While the official reStructuredText documentation is comprehensive, I find that learning markup languages is often easier with immediate, interactive feedback. I wanted to create a tool where users could experiment with reST syntax and see the results without needing any local setup. Building it with PyScript was also a fun challenge to see how much could be done directly in the browser with Python.

Target Audience

This is for anyone who needs to learn or brush up on reStructuredText:

  • Python developers writing documentation or docstrings.

  • Users of Sphinx or other Docutils-based tools.

  • Technical writers.

  • Anyone interested in reStructuredText

Key Features

  • Interactive Editor

  • Structured Lessons

  • Instant Feedback

  • Playground with "Share" button (like pastebin)

  • Dark Mode 😉

Comparison to Other Tools

I didn't find any other interactive reST tutorials, or even reST playgrounds.

You still better read the official documentation, but my project will help you get started and understand the basics.

Links

  • Project Website

  • Playground

  • GitHub Repo

I'd love to hear your feedback!

Thanks!

🌐
Python
wiki.python.org › moin › reStructuredText
reStructuredText (reST) - Python Wiki
1 from docutils import core 2 from docutils.writers.html4css1 import Writer,HTMLTranslator 3 4 class HTMLFragmentTranslator( HTMLTranslator ): 5 def __init__( self, document ): 6 HTMLTranslator.__init__( self, document ) 7 self.head_prefix = ['','','','',''] 8 self.body_prefix = [] 9 self.body_suffix = [] 10 self.stylesheet = [] 11 def astext(self): 12 return ''.join(self.body) 13 14 html_fragment_writer = Writer() 15 html_fragment_writer.translator_class = HTMLFragmentTranslator 16 17 def reST_to_html( s ): 18 return core.publish_string( s, writer = html_fragment_writer ) 19 20 if __name__ ==
🌐
GitHub
intel.github.io › project-example-for-python › rst.html
Restructured Text Examples — project-example-for-python 0.1.dev1+g30df769 documentation
Here’s some info on :something: rsT for sphinx https://www.sphinx-doc.org/en/master/usage/restructuredtext/roles.html · I’m a link to the Autogenerated Docs docs page. I’m a link to the Hi I’m a subheader section. ... def im(some): python = "code" when_in.vim("I'm auto highlighted as Python code within the rst file")
🌐
Wikipedia
en.wikipedia.org › wiki › ReStructuredText
reStructuredText - Wikipedia
May 10, 2026 - The reference implementation of ... in the Python programming language, but other parsers are available. The Docutils project has not registered any MIME type for reStructuredText nor designated any unregistered MIME type as official, but documents the MIME type text/x-rst as in de facto use by, for example, the build ...
🌐
GitHub
gist.github.com › jesugmz › d83b5e9de7ccc16f71c02adf7d2f3f44
Python docstring reStructuredText style · GitHub
Default values for optional arguments can be given (but if they contain commas, they will confuse the signature parser). Python 3-style argument annotations can also be given as well as return type annotations:
Find elsewhere
🌐
Python
peps.python.org › pep-0012
PEP 12 – Sample reStructuredText PEP Template | peps.python.org
.. code-block:: rst An example of the ``rst`` lexer (i.e. *reStructuredText*).
🌐
Docutils
docutils.sourceforge.io › rst.html
reStructuredText
The primary goal of reStructuredText is to define and implement a markup syntax for use in Python docstrings and other documentation domains, that is readable and simple, yet powerful enough for non-trivial use. The intended purpose of the markup is the conversion of reStructuredText documents into useful structured data formats. See statemachine.py for an example of a Python module fully documented using reStructuredText.
🌐
Cheat Sheets
cheat.readthedocs.io › en › latest › rst.html
reStructuredText — Dan's Cheat Sheets 1 documentation
REST reStructuredText notes (see also Sphinx notes) SEE CHEATSHEET AT END · rst tutorial · rst primer · rst markup · autodoc · Example: file1.rst --------- Contents: .. toctree:: :maxdepth: 2 keys api Go read :ref:`morestuff` for more. Read about python package :py:mod:`package.name` and python function :py:func:`package.name.function`. The python class :py:class:`package.name.ClassName` might also be useful, and its method :py:meth:`package.name.ClassName.method`. Not to mention the attribute :py:attr:`package.name.ClassName.attrname`. The code might throw the exception :py:exc:`package.name.MyException`. file2.rst --------- ..
🌐
Docutils
docutils.sourceforge.io › docs › user › rst › demo.html
reStructuredText Demonstration - Docutils - SourceForge
This document is a demonstration of the reStructuredText markup language, containing examples of all basic reStructuredText constructs and many advanced constructs. That's it, the text just above this line. Here's a transition: It divides the section. A paragraph. Paragraphs contain text and may contain inline markup: emphasis, strong emphasis, inline literals, standalone hyperlinks (https://www.python.org), external hyperlinks (Python [5]), internal cross-references (example), external hyperlinks with embedded URIs (Python web site), footnote references (manually numbered [1], anonymous auto-numbered [3], labeled auto-numbered [2], or symbolic [*]), citation references ([CIT2002]), substitution references (), and inline hyperlink targets (see Targets below for a reference back to here).
🌐
GitHub
gist.github.com › SMotaal › 24006b13b354e6edad0c486749171a70
ReStructuredText Examples · GitHub
For example, this lone asterisk * is handled just fine, as is the asterisk in this equation: 5*6=30. If you actually want text *surrounded by asterisks* to not be italicised, then you need to indicate that the asterisk is not special.
🌐
Readthedocs
pydoctor.readthedocs.io › en › latest › docformat › restructuredtext.html
reStructuredText - pydoctor documentation - Read the Docs
.. python:: def fib(n): """Print a Fibonacci series.""" a, b = 0, 1 while b < n: print b, a, b = b, a+b ... In any case, plaintext docstring format will be used if docstrings can’t be parsed with restructuredtext parser.
Top answer
1 of 4
43

I'd like to extend upon the answer from Gareth Latty. "What you probably want is the parser at docutils.parsers.rst" is a good starting point of the answer, but what's next? Namely:

How to parse restructuredtext in python?

Below is the exact answer for Python 3.6 and docutils 0.14:

import docutils.nodes
import docutils.parsers.rst
import docutils.utils
import docutils.frontend

def parse_rst(text: str) -> docutils.nodes.document:
    parser = docutils.parsers.rst.Parser()
    components = (docutils.parsers.rst.Parser,)
    settings = docutils.frontend.OptionParser(components=components).get_default_values()
    document = docutils.utils.new_document('<rst-doc>', settings=settings)
    parser.parse(text, document)
    return document

And the resulting document can be processed using, for example, below, which will print all references in the document:

class MyVisitor(docutils.nodes.NodeVisitor):

    def visit_reference(self, node: docutils.nodes.reference) -> None:
        """Called for "reference" nodes."""
        print(node)

    def unknown_visit(self, node: docutils.nodes.Node) -> None:
        """Called for all other node types."""
        pass

Here's how to run it:

doc = parse_rst('spam spam lovely spam')
visitor = MyVisitor(doc)
doc.walk(visitor)
2 of 4
18

Docutils does indeed contain the tools to do this.

What you probably want is the parser at docutils.parsers.rst

See this page for details on what is involved. There are also some examples at docutils/examples.py - particularly check out the internals() function, which is probably of interest.

🌐
Beagleboard
docs.beagleboard.org › intro › contribution › rst-cheat-sheet.html
ReStructuredText Cheat Sheet — BeagleBoard Documentation
Make sure the length of your heading symbol is at least (or more) the at least of the heading text, for example: incorrect H1 ##### ① correct H1 ############ ② · ① Length of heading symbol # is smaller than the content above. ② Shows the correct way of setting the document title (H1) with #. For adding a code snippet you can use tab indentation to start. For more refined code snippet display we have the code-block and literalinclude directives as shown below. This the simplest way of adding code snippet in ReStructuredText. This is python code:: ① ② import numpy as np ③ import math