2.4. reStructuredText Coding Guidelines
These coding guidelines MUST be applied to all reStructuredText source
files.
The following rules generally apply and follow the naming schema
RST:<ongoing-number>.
2.4.1. Filenames (RST:001)
In addition to the general file naming rules, the following MUST be applied.
File name rules
reStructuredTextsource files MUST use.rstas file extension.
For example, valid file names for reStructuredText sources are:
macros.txtsoftware-installation.rst
2.4.2. Line length (RST:002)
Each line of text in your code SHOULD be at most 80 characters long. A line MAY exceed 80 characters if it is
a comment line which is not feasible to split without harming readability, ease of cut and paste or auto-linking, e.g., if a line contains an example command or a literal URL longer than 120 characters or
a raw-string literal with content that exceeds 120 characters. Except for test code, such literals should appear near the top of a file.
2.4.3. Include (RST:003)
Include macros to have consistent style for repetitive words.
Include rules
Macros SHOULD be used wherever possible within the build toolchain.
macros.txtMUST be included wherever possibleFile local macros MAY be used. However, if a term is used in more than one file, the macro MUST be transferred to
macros.txt.
2.4.4. Links (RST:004)
Links MUST be checked for availability.
This is ensured by running sphinx in linkcheck mode.
Links rules
All links MUST be reachable.
Separated link and target definition SHOULD be used. If link and target definition are separated the target MUST be defined at the end of the file after two blank lines.
Examples:
1|foxbms| is developed by the `Battery Systems Group`_ at `Fraunhofer IISB`_.
2
3more documentation
4even more documentation
5
6.. Battery Systems Group: https://www.iisb.fraunhofer.de/en/research_areas/intelligent_energy_systems/stationary_battery_systems.html
7.. Fraunhofer IISB: https://www.iisb.fraunhofer.de
2.4.5. Headings (RST:005)
We follow the convention of the Python Developer’s Guide for reStructuredText Markup. Use the following rules to create headings:
# with overline, for parts
* with overline, for chapters
=, for sections
-, for subsections
^, for sub-subsections
“, for paragraphs
heading
all
reStructuredTextfiles MUST have a headingthe heading MUST be two lines after the file label
the heading MUST be underlined with =
1.. include:: ./../../macros.txt
2
3.. _RESTRUCTUREDTEXT_CODING_GUIDELINES:
4
5reStructuredText Coding Guidelines
6==================================
2.4.6. Orphan (RST:006)
orphan
reStructuredTextfiles which are not included in other.rstfiles MUST start with :orphan:
2.4.7. Sentence (RST:007)
Sentence
Every new sentence MUST start on a new line.
This rule applies to prose text in paragraphs, list items and admonitions.
This rule does not apply to literal blocks, code blocks, table rows, link target definitions and long URLs.
2.4.8. File Templates
The file template below shows how these rules are correctly applied. It SHOULD be used as basis for new files.
reStructuredText file
rst.rst