Skip to content

Commit

Permalink
Add handling of Mermaid diagrams in documentation
Browse files Browse the repository at this point in the history
GitHub: fix mxcube#908
  • Loading branch information
fabcor-maxiv committed Jul 2, 2024
1 parent 76f5ea4 commit 9df4064
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 1 deletion.
6 changes: 6 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@
myst_enable_extensions = ("fieldlist",)


# -- Options for sphinxcontrib.mermaid
# https://pypi.org/project/sphinxcontrib-mermaid/

extensions.append("sphinxcontrib.mermaid")


# -- Options for sphinx_last_updated_by_git
# https://pypi.org/project/sphinx-last-updated-by-git/

Expand Down
42 changes: 42 additions & 0 deletions docs/source/dev/docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ sphinx-build -M html docs/source docs/build -c docs

The theme used is [*furo*](https://pypi.org/project/furo/).

### Markup

The default markup language for Sphinx is
[*reStructuredText*](https://docutils.sourceforge.io/rst.html).
The [usage of *Markdown*](https://www.sphinx-doc.org/en/master/usage/markdown.html)
Expand All @@ -68,6 +70,8 @@ To learn how to use these features in Markdown documents,
one should refer to the MyST documentation.
The docstrings in Python code are still to be written with Restructuredtext syntax, though.

### Python code

The documentation system is configured to generate {doc}`API documentation </dev/api>`
based on the Python code.
The Sphinx extension used to do this is
Expand All @@ -79,3 +83,41 @@ The
extension is enabled to handle docstrings within the Python code
and it is configured for
[Google-style docstrings](https://google.github.io/styleguide/pyguide.html#s3.8-comments-and-docstrings).

### Diagrams

The
[*`sphinxcontrib-mermaid`*](https://pypi.org/project/sphinxcontrib-mermaid)
extension is enabled to allow embedding [*Mermaid* diagrams](https://mermaid.js.org/)
in the documentation.

For example the following code in a Markdown document:

~~~markdown
```{mermaid}
sequenceDiagram
participant Alice
participant Bob
Alice->John: Hello John, how are you?
```
~~~

or the following in a ReStructuredText document:

```restructuredtext
.. mermaid::
sequenceDiagram
participant Alice
participant Bob
Alice->John: Hello John, how are you?
```

produce the following diagram:

```{mermaid}
sequenceDiagram
participant Alice
participant Bob
Alice->John: Hello John, how are you?
```
13 changes: 12 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ furo = "^2023.9.10"
myst-parser = "^2.0.0"
sphinx = "<7.2"
sphinx-last-updated-by-git = "^0.3.7"
sphinxcontrib-mermaid = "^0.9.2"

[tool.poetry.extras]
tango = ["PyTango"]
Expand Down

0 comments on commit 9df4064

Please sign in to comment.