Mermaid¶
What this is¶
Mermaid is a markdown-like script language for generating charts from text via javascript.
It is open source and the repository can be found here.
The official documentation site can be found here.
The repository of the documentation site can be found here.
To write and preview side-by-side without a locally installed editor, an online live editor can be found here.
Visual Studio Code is a highly recommended editor for Markdown and Mermaid, and Admonition.
Usage examples and sample output are provided below.
The officially supported MkDocs Material diagrams are listed [here][mermaid_mkdocs_material.
Usage¶
Flowchart¶
More information on usage can be found here.
Source Code
Output
graph TD
a --> b{To be or <br />not to be?}
a -.-> e[int32]
b -. not to be .-> c((null))
b -- to be --> d(zero)
Sequence diagram¶
More information on usage can be found here.
Source Code
Output
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!
Class diagram¶
Source Code
```mermaid
classDiagram
Class01 <|-- AveryLongClass : Cool
Class03 *-- Class04
Class05 o-- Class06
Class07 .. Class08
Class09 --> C2 : Where am i?
Class09 --* C3
Class09 --|> Class07
Class07 : equals()
Class07 : Object[] elementData
Class01 : size()
Class01 : int chimp
Class01 : int gorilla
Class08 <--> C2: Cool label
```
Output
classDiagram
Class01 <|-- AveryLongClass : Cool
Class03 *-- Class04
Class05 o-- Class06
Class07 .. Class08
Class09 --> C2 : Where am i?
Class09 --* C3
Class09 --|> Class07
Class07 : equals()
Class07 : Object[] elementData
Class01 : size()
Class01 : int chimp
Class01 : int gorilla
Class08 <--> C2: Cool label
Entity-relationship diagrams¶
Simple usage:
Source Code
Output
erDiagram
CUSTOMER ||--o{ ORDER : places
ORDER ||--|{ LINE-ITEM : contains
CUSTOMER }|..|{ DELIVERY-ADDRESS : uses
Advanced usage (limited support in MkDocs Material dark themes):
Source Code
Output
erDiagram
CUSTOMER ||--o{ ORDER : places
CUSTOMER {
string name
string custNumber
string sector
}
ORDER ||--|{ LINE-ITEM : contains
ORDER {
int orderNumber
string deliveryAddress
}
LINE-ITEM {
string productCode
int quantity
float pricePerUnit
}
State diagram¶
Source Code
Output
stateDiagram-v2
state fork_state <<fork>>
[*] --> fork_state
fork_state --> State2
fork_state --> State3
state join_state <<join>>
State2 --> join_state
State3 --> join_state
join_state --> State4
State4 --> [*]
Gantt chart¶
Warning
Not officially supported by MkDocs Material.
More information on usage can be found here.
Source Code
Output
gantt
dateFormat YYYY-MM-DD
title Adding GANTT diagram to mermaid
section A section
Completed task :done, des1, 2014-01-06,2014-01-08
Active task :active, des2, 2014-01-09, 3d
Future task : des3, after des2, 5d
Future task2 : des4, after des3, 5d
Git graph¶
Warning
Not officially supported by MkDocs Material. Not supported by the currently used mermaid plugin.
The syntax allows the simulation of a sequence of Git commands.
Non-functional content
Source Code
Output
gitGraph:
options
{
"nodeSpacing": 85,
"nodeRadius": 5
}
end
commit
branch newbranch
checkout newbranch
commit
commit
checkout master
commit
commit
merge newbranch
commit