reStructuredText & Sphinx
Basics (docutils)
Quick reStructuredText: Short reference for most the basic syntax
reStructuredText Markup Specification: Comprehensive syntax guide
reStructuredText Directives: Guide on directives (special sections)
Extensions by Sphinx
reStructuredTest Primer: Short reference for most the basic syntax (similar to docutils description)
Directives: Guide on directives (special sections)
Roles: Special inline text markups
Third-party extensions
Autodoc
sphinx-autodoc-typehints: Use type annotations for documenting acceptable argument types and return value types of function
sphinx-click: Automatically extract documentation from a Click-based application and include it in your docs
Code blocks & prompts
sphinx-copybutton: Adds a copy button to all code and command line blocks
sphinx-prompt: Directive for unselectable prompts (nice for bash sections)
Design Elements
sphinx-datatables: Add data tables, which allow sorting entries
sphinx-design: Designing beautiful, screen-size responsive web-components
sphinx-tabs: Directive to add tabbed content for output HTML
sphinxcontrib-images: Directive for thumbnail images which can be magnified (as of early 2024, apply this change to remove deprecation warning during building HTML)
sphinxemoji: Roles for adding emojis
Jupyter Notebooks
nbsphinx: Extension that provides a source parser for *.ipynb files
jupyter_sphinx: Directive to define Jupyter-like code cells, embedding its output
Git
sphinx-git: Directive for adding latest git commits information to docs
sphinx-gitstamp: Directive for inserting a git datestamp into the context
Graphs
sphinxcontrib-mermaid: Directive for mermaid graphs (as of early 2024, conflicts with nbsphinx and jupyter_sphinx; if used together with either of these, apply this workaround to load
mermaid.min.jsafter the Jupyter notebook JavaScript)
Publish
sphinxcontrib-confluencebuilder: Sphinx extension to build Atlassian Confluence Storage Markup
sphinx-sitemap: Generate multi-version and multi-language sitemaps.org compliant sitemaps for the HTML version of your Sphinx documentation
Quoting
sphinxcontrib-bibtex: Allows BibTeX citations into the documentation
Search
sphinx-docsearch: Replaces built-in search engine with Algolia DocSearch. Check out the setup manual for v2 or v3 of the crawler.
Substitution
sphinx-issues: Create links to project’s issue tracker (useful if doc only covers single repo)
sphinx-substitution-extensions: Allow substitutions within code blocks, prompts and inline
Themes
furo: A clean customisable Sphinx documentation theme.
sphinx-book-theme: A clean book theme for scientific explanations and documentation with Sphinx
sphinx-rtd-theme: Theme used for the web page of this documentation (provided by ReadTheDocs.com)
Additional themes can be browsed in the Sphinx Themes Gallery.
Tweaks
sphinxnotes-comboroles: Sphinx extension for composing multiple roles
sphinxnotes-strike: An extension that adds strikethrough text support to Sphinx
Videos
sphinxcontrib-video: Embed
.mp4,.webmand.oggvideos into RST documentssphinxcontrib-youtube: Insert videos from YouTube and Vimeo (by reference)
Custom extensions
Plug-ins
unicode-guilabel: Support single unicode character (e.g. emoji) inside guilabel role.
Usage Example:
You can click the :unicode-guilabel:`ᐊ` and :unicode-guilabel:`ᐅ` buttons to navigate.
renders into
You can click the ᐊ and ᐅ buttons to navigate.
Hint
You can get Unicode HTML Codes at https://symbl.cc/en/.
Directives
The following custom directives are available in this documentation:
Admonitions
.. admonition:: Design Principle
:class: design_principle
Functions should either be **queries** or **commands**. Queries are for getting
data, but must not change the state. Commands are supposed to change the state,
but must not return any data. Functions must not do both.
.. admonition:: Pattern Definition
:class: pattern_definition
The **Abstract Factory Pattern** provides an interface for creating families
of related or dependent objects without specifying their concrete classes.
.. admonition:: Problem
:class: problem
Some content for the custom problem admonition which is not important here.
renders into
Design Principle
Functions should either be queries or commands. Queries are for getting data, but must not change the state. Commands are supposed to change the state, but must not return any data. Functions must not do both.
Pattern Definition
The Abstract Factory Pattern provides an interface for creating families of related or dependent objects without specifying their concrete classes.
Problem
Some content for the custom problem admonition which is not important here.
Roles
The following custom roles are available in this documentation:
Inline Code Highlighting
Syntax highlighting for inline code for various languages:
* **Python**: Use the command :python:`print "Hello World"` to say hi.
* **Java**: Use the command :java:`System.out.println("Hello World");` to say hi.
* **JavaScript**: Use command :javascript:`console.log("Hello World");` to say hi.
* **HTML**: Use line :html:`<p>Hello World</p>` to say hi.
* **RST**: Use line :rst:`**Hello World**` to boldly say hi.
* **Bash**: Use line :bash:`echo "Hello World"` to say hi.
renders into
Python: Use the command
print "Hello World"to say hi.Java: Use the command
System.out.println("Hello World");to say hi.JavaScript: Use command
console.log("Hello World");to say hi.HTML: Use line
<p>Hello World</p>to say hi.RST: Use line
**Hello World**to boldly say hi.Bash: Use line
echo "Hello World"to say hi.
Raw HTML
Sometimes reStructureText does not offer a proper symbol or styling capabilities for a desired HTML output, in which case a raw HTML string can be used:
This is my phone number: :raw-html:`☎` 0170-123456789.
This is called a :raw-html:`<span style="font-family: Courier">description</span>`.
renders into
This is my phone number: ☎ 0170-123456789.This is called a description.
Colors
Background colors in :rbg:`red` and :gbg:`green`, as well as foreground color in
:rfg:`red` and :gfg:`green`.
renders into
Background colors in red and green, as well as foreground color in red and green.
Other formatting
:ulined:`Underlined` text parts
renders into
Underlined text parts
:strike:`Struck through` text parts
renders into
Struck through text parts