Mermaid 集成

Mermaid 是一种工具,允许您从简单的标记语言生成流程图、序列图、甘特图、类图和 vcs 图。这允许将图表直接嵌入和编辑到文档源文件中,而不是使用某些外部工具将它们创建为图像并将其检入树中。

要添加图表,只需将类似以下内容放入您的页面中

.. mermaid::

    graph TD;
        A-->B;
        A-->C;
        B-->D;
        C-->D;
```{mermaid}
graph TD;
    A-->B;
    A-->C;
    B-->D;
    C-->D;
```

结果将是

graph TD; A-->B; A-->C; B-->D; C-->D;

或者

.rst
.. 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!
.md
```{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!
```

将显示

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!

有关语法的更多详细信息,请参阅 Mermaid 的官方 文档,并使用 Mermaid 实时编辑器 来尝试创建您自己的图表。