|
| 1 | +:description: Embed Mermaid flowcharts, sequence diagrams, gantt diagrams and more in your documents with Shibuya theme. |
| 2 | + |
| 3 | +.. _sphinxcontrib-mermaid: |
| 4 | + |
| 5 | +sphinxcontrib-mermaid |
| 6 | +===================== |
| 7 | + |
| 8 | +This extension allows you to embed Mermaid graphs in your documents, |
| 9 | +including general flowcharts, sequence diagrams, gantt diagrams and more. |
| 10 | + |
| 11 | +**Documentation**: https://sphinxcontrib-mermaid-demo.readthedocs.io/ |
| 12 | + |
| 13 | +Install |
| 14 | +------- |
| 15 | + |
| 16 | +.. code-block:: bash |
| 17 | +
|
| 18 | + pip install sphinxcontrib-mermaid |
| 19 | +
|
| 20 | +Then, add the extension to your ``conf.py``: |
| 21 | + |
| 22 | +.. code-block:: python |
| 23 | + :caption: conf.py |
| 24 | +
|
| 25 | + extensions = [ |
| 26 | + # ... |
| 27 | + "sphinxcontrib.mermaid", |
| 28 | + ] |
| 29 | +
|
| 30 | +Usage |
| 31 | +----- |
| 32 | + |
| 33 | +It adds a ``mermaid`` directive to embed mermaid markup. For example: |
| 34 | + |
| 35 | +.. code-block:: none |
| 36 | +
|
| 37 | + .. mermaid:: |
| 38 | +
|
| 39 | + sequenceDiagram |
| 40 | + participant Alice |
| 41 | + participant Bob |
| 42 | + Alice->John: Hello John, how are you? |
| 43 | + loop Healthcheck |
| 44 | + John->John: Fight against hypochondria |
| 45 | + end |
| 46 | + Note right of John: Rational thoughts <br/>prevail... |
| 47 | + John-->Alice: Great! |
| 48 | + John->Bob: How about you? |
| 49 | + Bob-->John: Jolly good! |
| 50 | +
|
| 51 | +.. mermaid:: |
| 52 | + |
| 53 | + sequenceDiagram |
| 54 | + participant Alice |
| 55 | + participant Bob |
| 56 | + Alice->John: Hello John, how are you? |
| 57 | + loop Healthcheck |
| 58 | + John->John: Fight against hypochondria |
| 59 | + end |
| 60 | + Note right of John: Rational thoughts <br/>prevail... |
| 61 | + John-->Alice: Great! |
| 62 | + John->Bob: How about you? |
| 63 | + Bob-->John: Jolly good! |
| 64 | + |
| 65 | +Mermaid not working |
| 66 | +------------------- |
| 67 | + |
| 68 | +You may encounter an error of:: |
| 69 | + |
| 70 | + Uncaught ReferenceError: mermaid is not defined |
| 71 | + |
| 72 | +Here are some possible fixes: |
| 73 | + |
| 74 | +1. There will be a ``requirejs`` conflict with :ref:`nbsphinx` extension, |
| 75 | + you can use ``nbsphinx_requirejs_path`` setting to resolve the issue: |
| 76 | + |
| 77 | + .. code-block:: python |
| 78 | + :caption: conf.py |
| 79 | +
|
| 80 | + nbsphinx_requirejs_path = '' |
| 81 | +
|
| 82 | +2. Mermaid extension is conflict with :ref:`sphinx-jupyter` too, you can |
| 83 | + resolve the issue with ``jupyter_sphinx_require_url`` setting: |
| 84 | + |
| 85 | + .. code-block:: python |
| 86 | + :caption: conf.py |
| 87 | +
|
| 88 | + jupyter_sphinx_require_url = '' |
0 commit comments