reStructuredtext basics
Describes basics of reStructuredtext
reStructuredtext
Covering most common stuff
Sphinx documentation contents — Sphinx documentation (sphinx-doc.org)
To introduce different sections in the left navigation bar of the index.html
, change the toctree in index.rst
as below. Here we have 2 different folders Options
and Guidelines
.
1 | .. pyradnotes documentation master file, created by |
Syntax
Here is a reference cheat sheet https://github.com/ralsina/rst-cheatsheet/blob/master/rst-cheatsheet.rst
Text formatting
1 | .. emphasis, and include multiple words |
Lists Bulleted, Numbered, and Multi-level
1 | .. list without numbers |
Admonitions (警告)
4 callouts: Green, blue, yellow and red
1 | .. caution callout (yellow). Note you have to indent each line in this callout |
Images
1 | .. Insert a picture from a folder |
Code blocks
If the code in your file are all belong to a same programming language, you could set this in conf.py
to indicate this as below.
1 | # in conf.py |
2 ways to specify code blocks
1 | .. Insert a code block, note that all |
Tables
4 ways to render
- equal signs, single space to separate different columns
1 | ================ =============== ===== =========== |
- Use table block, you can specify a table name. Note that a new empty line is needed before starting the table
1 | .. table:: MyOptions |
- Draw all table cells… (en.. interesting… while I’d prefer not to do so)
1 | +----------------+---------------+-----+-----------+ |
Use
list-table
block1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16.. list-table:: Comparison
:widths: 20 10 10 15
:header-rows: 1
* - Platform
- Self-Contained?
- Cost
- Flexibility
* - Raspberry Pi
- No
- $30
- Limitless
* - Lego Mindstorms
- Yes
- $350
- MediumUse
csv-table
block1
2
3
4
5
6.. csv-table:: Comparison
:header: Platform, Self-Contained?, Cost, Flexibility
:widths: 15 10 30 30
Raspberry, No, $30, Limitless
Lego Mindstorms, Yes, $350, Medium
Links
External links
Directly add to the file
1
https://pyrad.github.io/
Use bracket with underscore
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15.. Syntax is ` LinkName <linkAddress>`_
`Pyrad note <https://pyrad.github.io/>`_
- Internal Links to files
- Link to a file, this syntax will show the name of the file
```rst
.. Use syntax :doc:`/abs/path/to/file`
and this shows the name of file
Note that backtick should follow :doc:
immediately
:doc:`/Options/justlogic`Link to a file by showing some different text
1
2
3
4
5.. Use syntax :doc:`ShowText </abs/path/to/file>`
and this shows specified text
Note that backtick should follow :doc:
immediately
:doc:`best starting point </Options/justlogic>`
Internal Links to paragraphs
Set up an anchor for the paragraph to link to, then use same in other place
1
2
3
4
5.. Setup an anchor somewhere in a paragraph in a file
.. _myRefAnchor:
.. Set a link in other places to link to it
:ref:`SomeTextToShow <myRefAnchor>`
reStructuredtext basics
install_url
to use ShareThis. Please set it in _config.yml
.