Create Documentation
This documentation is created using Sphinx.
Edit the Documentation
It is recommended to use Visual Studio Code to edit the documentation.
Use the EditInVsCode.bat
batch file to setup the environment and launch Visual Studio Code.
Build the Documentation
Build manually
To build the Sphinx documentation run the Documentation/Developer/MakeHtml.bat
script.
Note
Note that the code documentation is build separately.
The code_doc_index.xhtml
file, which is the landing page of the code documentation, will be overwritten by the build with a placeholder file.
To build the whole documentation (Sphinx and Code Documentation) use the Scripts/BuildAndTest/BuildDocumentation.bat
script.
Build in VS Code
To build the documentation while editing in Visual Studio Code use the Ctrl+Shift+B
keybind.
The keybind is defined in the Documentation/Developer/.vscode/keybindings.json
file.
The task that is performed when using the keybind is defined in the Documentation/Developer/.vscode/tasks.json
file.
Sphinx Syntax
Documents
Every page of the documentation is generated from a separate *.rst
file.
The main page of the documentation is the index.rst
file.
In the OpenTwin documentation every root category of the documentation has its own folder.
The folder contains the main page file of the category which has the same name as the category.
For example the category how_to
has a folder with the same name and the file how_to.rst
in it.
To now add the how_to
page to the documentation add it to the toctree
in the index.rst
file.
1In the index.rst file the how_to category is added:
2
3.. toctree::
4
5 how_to/how_to
Any other file that belongs to a certain category should be placed in the categories folder.
The files of the category should then be added to the categories toctree
in the same way the catery file was added to the index.rst
file.
Further nesting of the documentation is also possible.
General
General documentation syntax:
1This is a regular text.
2
3When writing multiple lines.
4They will result in a single line.
5If there is no empty line between them.
6
7To add a line break use..
8
9..a empty line between them.
10
11Also adding |br| at the end of a line will result in a line break:
12This is the first line. |br|
13This is the second line. |br|
14Note that there is a space before the "|br|".
Inline Markup
The following example
1This text **is bold**.
2
3This text *is italic*.
4
5This is ``something very important``.
will result in:
This text is bold.
This text is italic.
This is something very important
.
Headings
The level of a heading is indicated by a series of symbols below the heading text.
The following symbols may be used for the different heading levels:
H1: Pound symbol
#
H2: Asterisk
*
H3: Equals symbol
=
H4: Hyphen
-
H5: Caret
^
H6: Quotation mark
"
1Heading 1
2#########
3
4Some text...
5
6Heading 2
7*********
8
9Other text...
10
11Another Heading 2
12*****************
13
14...
Note
The number of symbols below the heading text must have the exact same length as the heading text itself.
Lists
The following example
1- Bulleted list item 1
2- Bulleted list item 2
3
41. Numbered list item 1
52. Numbered list item 2
will result in:
Bulleted list item 1
Bulleted list item 2
Numbered list item 1
Numbered list item 2
Tables
Each table has the number of columns and their associated relative widths indicated in a width tag. The width tag is optional. A title can be specified.
For proper formatting, the asterisk indicating each row must align vertically, and the hyphens indicating each column must also align. Empty cells must be accounted for, so that each column in a row is always marked, even if there is no content in the table cell. An example of an empty cell is the second column in the first row of the following example.
1.. list-table:: Title
2 :widths: 25 25 50
3 :header-rows: 1
4
5 * - Heading row 1, column 1
6 - Heading row 1, column 2
7 - Heading row 1, column 3
8 * - Row 1, column 1
9 -
10 - Row 1, column 3
11 * - Row 2, column 1
12 - Row 2, column 2
13 - Row 2, column 3
Heading row 1, column 1 |
Heading row 1, column 2 |
Heading row 1, column 3 |
---|---|---|
Row 1, column 1 |
Row 1, column 3 |
|
Row 2, column 1 |
Row 2, column 2 |
Row 2, column 3 |
Formulas
Formulas can be embedded into the documentation:
1Inline formula :math:`E = mc^2`
Inline formula
Centered:
1.. math::
2 E = mc^2
Notes
Note
Notes can be written like this
1.. note::
2 Note text
Warnings
Warning
Warnings can be written like this
1.. warning::
2 Warning text
Code Blocks
This example shows how to embed code snippets.
The following RST code:
1.. code-block:: C++
2 :linenos:
3 :emphasize-lines: 2, 5
4
5 void my_function() {
6 printf("Stay healthy! <3");
7 my_other_function();
8 int i = 6;
9 printf("Yes, YOU :*");
10 }
reults in:
1void my_function() {
2 printf("Stay healthy! <3");
3 my_other_function();
4 int i = 6;
5 printf("Yes, YOU :*");
6}
The linenos
will add line numbers to the code block.
Using emphasize-lines
will emphasize the specified lines.
Note
Note that there is a blank line after the code block arguments and the actual code.
The following languages are supported by the Pygments lexer:
Language |
Code-Block Identifier(s) |
---|---|
Assembly |
|
Bash / Shell |
|
C |
|
C# |
|
C++ |
|
CSS |
|
Dockerfile |
|
Go |
|
Haskell |
|
HTML |
|
INI |
|
Java |
|
JavaScript |
|
JSON |
|
Kotlin |
|
Lua |
|
Makefile |
|
Markdown |
|
Matlab |
|
Perl |
|
PHP |
|
Plain Text |
|
Python |
|
R |
|
Ruby |
|
Rust |
|
SQL |
|
Swift |
|
TOML |
|
TypeScript |
|
XML |
|
YAML |
|
Nested Blocks
Code blocks, notes, warnings, etc. can be nested.
Therefore the following RST code
.. note::
In this ``note block`` we add the following ``code block`` :
.. code-block:: RST
:linenos:
Some fancy example
will result in:
Note
In this note block
we add the following code block
:
1Some fancy example
Images
Images can be added by using:
.. image:: <relative path tho THIS file>
e.g.
.. image:: images/logo.png
Some image parameters:
.. image:: images/logo.png
:scale: 50%
or
.. image:: images/logo.png
:width: 400
:alt: Alternative text
References
Documents
Other documents in the documentation can be referenced the following way:
:doc:`Custom Text </path relative to documentation root>`
Internal References
References to any other point in the documentation must be defined explicitly.
.. _name_of_the_reference:
These references can then be referenced via:
:ref:`Display text <name_of_the_reference>`
Note
Note that the underscore prefix in the reference declaration is mandatory and must not be specified when using the reference.
External Links
External web pages like https://opentwin.net/ will automaticall result in a hyperlink.
To add a custom text that will result in a hyperlink use:
`OpenTwin <https://opentwin.net/>`_
Note
Note that the underscore suffix is mandatory.