@@ -28,7 +28,7 @@ markdown_extensions:
28
28
- pymdownx.superfences :
29
29
custom_fences :
30
30
- name : mermaid
31
- class : mermaid-experimental
31
+ class : mermaid
32
32
format : !!python/name:pymdownx.superfences.fence_code_format
33
33
` ` `
34
34
@@ -47,9 +47,8 @@ ensures interoperability with all Material for MkDocs features._
47
47
48
48
[^1] :
49
49
While all [Mermaid.js][1] features should work out-of-the-box, Material for
50
- MkDocs will currently only adjust the fonts and colors for flow charts,
51
- class and state diagrams. Support for further diagram types will be added
52
- gradually.
50
+ MkDocs will currently adjust the fonts and colors for flow charts, sequence
51
+ diagrams, class diagams, state diagrams and entity relationship diagrams.
53
52
54
53
[^2] :
55
54
If you don't want to use the native integration, [mkdocs-mermaid2-plugin][8]
@@ -68,11 +67,18 @@ ensures interoperability with all Material for MkDocs features._
68
67
69
68
# # Usage
70
69
71
- # ## Using diagrams
72
-
73
70
Mermaid diagrams are written as [code blocks][10] with the help of the
74
71
[SuperFences][11] extension. They must be enclosed with two separate lines
75
- containing three backticks :
72
+ containing three backticks.
73
+
74
+ [10] : code-blocks.md
75
+ [11] : # superfences
76
+
77
+ # ## Using flowcharts
78
+
79
+ [Flowcharts][12] are diagrams that represent workflows or processes. The steps
80
+ are rendered as nodes of various kinds and are connected by edges, describing
81
+ the necessary order of steps.
76
82
77
83
_Example_ :
78
84
@@ -98,8 +104,194 @@ graph LR
98
104
B ---->|No| E[Yay!];
99
105
` ` `
100
106
101
- _See the [official documentation][1] to learn about all available diagram
102
- types._
107
+ [12] : https://mermaid-js.github.io/mermaid/#/flowchart
103
108
104
- [10] : code-blocks.md
105
- [11] : # superfences
109
+ # ## Using sequence diagrams
110
+
111
+ [Sequence diagrams][13] describe a specific scenario as sequential interactions
112
+ between multiple objects or actors, including the messages that are exchanged
113
+ between those actors.
114
+
115
+ _Example_ :
116
+
117
+ ` ` ` ` markdown
118
+ ` ` ` mermaid
119
+ sequenceDiagram
120
+ Alice->>John: Hello John, how are you?
121
+ loop Healthcheck
122
+ John->>John: Fight against hypochondria
123
+ end
124
+ Note right of John: Rational thoughts!
125
+ John-->>Alice: Great!
126
+ John->>Bob: How about you?
127
+ Bob-->>John: Jolly good!
128
+ ` ` `
129
+ ````
130
+
131
+ _Result_ :
132
+
133
+ ` ` ` mermaid
134
+ sequenceDiagram
135
+ Alice->>John: Hello John, how are you?
136
+ loop Healthcheck
137
+ John->>John: Fight against hypochondria
138
+ end
139
+ Note right of John: Rational thoughts!
140
+ John-->>Alice: Great!
141
+ John->>Bob: How about you?
142
+ Bob-->>John: Jolly good!
143
+ ` ` `
144
+
145
+ [13] : https://mermaid-js.github.io/mermaid/#/sequenceDiagram
146
+
147
+ # ## Using state diagrams
148
+
149
+ [State diagrams][14] are a great tool to describe the behavior of a system,
150
+ decomposing it into a finite number of states, and transitions between those
151
+ states.
152
+
153
+ _Example_ :
154
+
155
+ ` ` ` ` markdown
156
+ ` ` ` mermaid
157
+ stateDiagram-v2
158
+ [*] --> Active
159
+
160
+ state Active {
161
+ [*] --> NumLockOff
162
+ NumLockOff --> NumLockOn : EvNumLockPressed
163
+ NumLockOn --> NumLockOff : EvNumLockPressed
164
+ --
165
+ [*] --> CapsLockOff
166
+ CapsLockOff --> CapsLockOn : EvCapsLockPressed
167
+ CapsLockOn --> CapsLockOff : EvCapsLockPressed
168
+ --
169
+ [*] --> ScrollLockOff
170
+ ScrollLockOff --> ScrollLockOn : EvScrollLockPressed
171
+ ScrollLockOn --> ScrollLockOff : EvScrollLockPressed
172
+ }
173
+ ` ` `
174
+ ````
175
+
176
+ _Result_ :
177
+
178
+ ` ` ` mermaid
179
+ stateDiagram-v2
180
+ [*] --> Active
181
+
182
+ state Active {
183
+ [*] --> NumLockOff
184
+ NumLockOff --> NumLockOn : EvNumLockPressed
185
+ NumLockOn --> NumLockOff : EvNumLockPressed
186
+ --
187
+ [*] --> CapsLockOff
188
+ CapsLockOff --> CapsLockOn : EvCapsLockPressed
189
+ CapsLockOn --> CapsLockOff : EvCapsLockPressed
190
+ --
191
+ [*] --> ScrollLockOff
192
+ ScrollLockOff --> ScrollLockOn : EvScrollLockPressed
193
+ ScrollLockOn --> ScrollLockOff : EvScrollLockPressed
194
+ }
195
+ ` ` `
196
+
197
+ [14] : https://mermaid-js.github.io/mermaid/#/stateDiagram
198
+
199
+ # ## Using class diagrams
200
+
201
+ [Class diagrams][15] are central to object oriented programing, describing the
202
+ structure of a system by modelling entities as classes and relationships between
203
+ them.
204
+
205
+ _Example_ :
206
+
207
+ ` ` ` ` markdown
208
+ ` ` ` mermaid
209
+ classDiagram
210
+ Person <|-- Student
211
+ Person <|-- Professor
212
+ Person : +String name
213
+ Person : +String phoneNumber
214
+ Person : +String emailAddress
215
+ Person: +purchaseParkingPass()
216
+ Address "1" <-- "0..1" Person:lives at
217
+ class Student{
218
+ +int studentNumber
219
+ +int averageMark
220
+ +isEligibleToEnrol()
221
+ +getSeminarsTaken()
222
+ }
223
+ class Professor{
224
+ +int salary
225
+ }
226
+ class Address{
227
+ +String street
228
+ +String city
229
+ +String state
230
+ +int postalCode
231
+ +String country
232
+ -validate()
233
+ +outputAsLabel()
234
+ }
235
+ ` ` `
236
+ ````
237
+
238
+ _Result_ :
239
+
240
+ ` ` ` mermaid
241
+ classDiagram
242
+ Person <|-- Student
243
+ Person <|-- Professor
244
+ Person : +String name
245
+ Person : +String phoneNumber
246
+ Person : +String emailAddress
247
+ Person: +purchaseParkingPass()
248
+ Address "1" <-- "0..1" Person:lives at
249
+ class Student{
250
+ +int studentNumber
251
+ +int averageMark
252
+ +isEligibleToEnrol()
253
+ +getSeminarsTaken()
254
+ }
255
+ class Professor{
256
+ +int salary
257
+ }
258
+ class Address{
259
+ +String street
260
+ +String city
261
+ +String state
262
+ +int postalCode
263
+ +String country
264
+ -validate()
265
+ +outputAsLabel()
266
+ }
267
+ ` ` `
268
+
269
+ [15] : https://mermaid-js.github.io/mermaid/#/classDiagram
270
+
271
+ # ## Using entity-relationship diagrams
272
+
273
+ An [entity-relationship diagram][16] is composed of entity types and specifies
274
+ relationships that exist between entities. It describes inter-related things in
275
+ a specific domain of knowledge.
276
+
277
+ _Example_ :
278
+
279
+ ` ` ` ` markdown
280
+ ` ` ` mermaid
281
+ erDiagram
282
+ CUSTOMER ||--o{ ORDER : places
283
+ ORDER ||--|{ LINE-ITEM : contains
284
+ CUSTOMER }|..|{ DELIVERY-ADDRESS : uses
285
+ ` ` `
286
+ ````
287
+
288
+ _Result_ :
289
+
290
+ ` ` ` mermaid
291
+ erDiagram
292
+ CUSTOMER ||--o{ ORDER : places
293
+ ORDER ||--|{ LINE-ITEM : contains
294
+ CUSTOMER }|..|{ DELIVERY-ADDRESS : uses
295
+ ` ` `
296
+
297
+ [16] : https://mermaid-js.github.io/mermaid/#/entityRelationshipDiagram
0 commit comments