Mermaid Example
There is a plugin for sphinx
called sphinxcontrib-mermaid
which adds support for embedding Mermaid
graphs
in your documents, including general flowcharts, sequence diagrams, gantt diagrams and more. One can achieve this by following these instructions:
Make sure you have the
sphinx
plugin formermaid
(installable viapip
)pip install sphinxcontrib-mermaid
Make sure that this plugin would be recognized in your
conf.py
by adding it to theextentions
listNote
In this project the
conf.py
is generated bycmake
from theconf.py.in
file and therefore this addition should be added toconf.py.in
since it’s the template file for the generatedconf.py
.extentions = [ ... "sphinxcontrib.mermaid", ... ]
After those instructions you should be able to add the following directives in your .rst
files
.. mermaid::
sequenceDiagram
participant Alice
participant Bob
Alice->John: Hello John, how are you?
loop Healthcheck
John->John: Fight against hypochondria
end
Note right of John: Rational thoughts <br/>prevail...
John-->Alice: Great!
John->Bob: How about you?
Bob-->John: Jolly good!
Here is how it looks (this is a very small sequence diagram)
sequenceDiagram participant Alice participant Bob Alice->John: Hello John, how are you? loop Healthcheck John->John: Fight against hypochondria end Note right of John: Rational thoughts <br/>prevail... John-->Alice: Great! John->Bob: How about you? Bob-->John: Jolly good!