@groupby/ai-dev 0.5.10 → 0.5.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/teams/fhr-neowise/commands/address-pr.md +120 -0
- package/teams/fhr-neowise/commands/ready-pr.md +70 -0
- package/teams/fhr-neowise/commands/review-pr.md +111 -0
- package/teams/fhr-neowise/commands/tdd-implementation.md +86 -0
- package/teams/fhr-neowise/commands/write-plan.md +23 -0
- package/teams/fhr-neowise/commands/write-pr.md +21 -0
- package/teams/fhr-neowise/commands/write-spec.md +25 -0
- package/teams/fhr-neowise/skills/agent-routing/SKILL.md +72 -0
- package/teams/fhr-neowise/skills/code-review/SKILL.md +83 -0
- package/teams/fhr-neowise/skills/code-review/review-template.md +90 -0
- package/teams/fhr-neowise/skills/mermaid-diagram/SKILL.md +94 -0
- package/teams/fhr-neowise/skills/mermaid-diagram/references/BEST_PRACTICES.md +96 -0
- package/teams/fhr-neowise/skills/mermaid-diagram/references/architecture.md +434 -0
- package/teams/fhr-neowise/skills/mermaid-diagram/references/block.md +753 -0
- package/teams/fhr-neowise/skills/mermaid-diagram/references/c4.md +619 -0
- package/teams/fhr-neowise/skills/mermaid-diagram/references/classDiagram.md +1186 -0
- package/teams/fhr-neowise/skills/mermaid-diagram/references/config-configuration.md +72 -0
- package/teams/fhr-neowise/skills/mermaid-diagram/references/config-directives.md +342 -0
- package/teams/fhr-neowise/skills/mermaid-diagram/references/config-layouts.md +40 -0
- package/teams/fhr-neowise/skills/mermaid-diagram/references/config-math.md +96 -0
- package/teams/fhr-neowise/skills/mermaid-diagram/references/config-theming.md +246 -0
- package/teams/fhr-neowise/skills/mermaid-diagram/references/config-tidy-tree.md +89 -0
- package/teams/fhr-neowise/skills/mermaid-diagram/references/cynefin.md +279 -0
- package/teams/fhr-neowise/skills/mermaid-diagram/references/entityRelationshipDiagram.md +670 -0
- package/teams/fhr-neowise/skills/mermaid-diagram/references/eventmodeling.md +475 -0
- package/teams/fhr-neowise/skills/mermaid-diagram/references/examples.md +301 -0
- package/teams/fhr-neowise/skills/mermaid-diagram/references/flowchart.md +2116 -0
- package/teams/fhr-neowise/skills/mermaid-diagram/references/gantt.md +725 -0
- package/teams/fhr-neowise/skills/mermaid-diagram/references/gitgraph.md +2138 -0
- package/teams/fhr-neowise/skills/mermaid-diagram/references/ishikawa.md +66 -0
- package/teams/fhr-neowise/skills/mermaid-diagram/references/kanban.md +161 -0
- package/teams/fhr-neowise/skills/mermaid-diagram/references/mindmap.md +335 -0
- package/teams/fhr-neowise/skills/mermaid-diagram/references/packet.md +153 -0
- package/teams/fhr-neowise/skills/mermaid-diagram/references/pie.md +93 -0
- package/teams/fhr-neowise/skills/mermaid-diagram/references/quadrantChart.md +267 -0
- package/teams/fhr-neowise/skills/mermaid-diagram/references/radar.md +269 -0
- package/teams/fhr-neowise/skills/mermaid-diagram/references/railroad.md +337 -0
- package/teams/fhr-neowise/skills/mermaid-diagram/references/requirementDiagram.md +495 -0
- package/teams/fhr-neowise/skills/mermaid-diagram/references/sankey.md +415 -0
- package/teams/fhr-neowise/skills/mermaid-diagram/references/sequenceDiagram.md +1195 -0
- package/teams/fhr-neowise/skills/mermaid-diagram/references/stateDiagram.md +670 -0
- package/teams/fhr-neowise/skills/mermaid-diagram/references/timeline.md +571 -0
- package/teams/fhr-neowise/skills/mermaid-diagram/references/treeView.md +321 -0
- package/teams/fhr-neowise/skills/mermaid-diagram/references/treemap.md +353 -0
- package/teams/fhr-neowise/skills/mermaid-diagram/references/userJourney.md +42 -0
- package/teams/fhr-neowise/skills/mermaid-diagram/references/venn.md +134 -0
- package/teams/fhr-neowise/skills/mermaid-diagram/references/wardley.md +732 -0
- package/teams/fhr-neowise/skills/mermaid-diagram/references/xyChart.md +312 -0
- package/teams/fhr-neowise/skills/mermaid-diagram/references/zenuml.md +474 -0
- package/teams/fhr-neowise/skills/mermaid-diagram/scripts/sync_docs.py +138 -0
- package/teams/fhr-neowise/skills/pull-request-authoring/COMPLEX.template.md +52 -0
- package/teams/fhr-neowise/skills/pull-request-authoring/NON-CODE.template.md +15 -0
- package/teams/fhr-neowise/skills/pull-request-authoring/SIMPLE.template.md +20 -0
- package/teams/fhr-neowise/skills/pull-request-authoring/SKILL.md +102 -0
- package/teams/fhr-neowise/skills/spec-investigation/SKILL.md +139 -0
- package/teams/fhr-neowise/skills/spec-investigation/TEMPLATE.spec.md +74 -0
- package/teams/fhr-neowise/skills/tdd-workflow/SKILL.md +137 -0
- package/teams/fhr-neowise/skills/write-plan/SKILL.md +285 -0
- package/teams/fhr-neowise/skills/write-plan/assets/TEMPLATE.checklist.json +79 -0
- package/teams/fhr-neowise/skills/write-plan/assets/TEMPLATE.plan.md +158 -0
|
@@ -0,0 +1,670 @@
|
|
|
1
|
+
> **Warning**
|
|
2
|
+
>
|
|
3
|
+
> ## THIS IS AN AUTOGENERATED FILE. DO NOT EDIT.
|
|
4
|
+
>
|
|
5
|
+
> ## Please edit the corresponding file in [/packages/mermaid/src/docs/syntax/stateDiagram.md](../../packages/mermaid/src/docs/syntax/stateDiagram.md).
|
|
6
|
+
|
|
7
|
+
# State diagrams
|
|
8
|
+
|
|
9
|
+
> "A state diagram is a type of diagram used in computer science and related fields to describe the behavior of systems.
|
|
10
|
+
> State diagrams require that the system described is composed of a finite number of states; sometimes, this is indeed the
|
|
11
|
+
> case, while at other times this is a reasonable abstraction." Wikipedia
|
|
12
|
+
|
|
13
|
+
Mermaid can render state diagrams. The syntax tries to be compliant with the syntax used in plantUml as this will make
|
|
14
|
+
it easier for users to share diagrams between mermaid and plantUml.
|
|
15
|
+
|
|
16
|
+
```mermaid-example
|
|
17
|
+
---
|
|
18
|
+
title: Simple sample
|
|
19
|
+
---
|
|
20
|
+
stateDiagram-v2
|
|
21
|
+
[*] --> Still
|
|
22
|
+
Still --> [*]
|
|
23
|
+
|
|
24
|
+
Still --> Moving
|
|
25
|
+
Moving --> Still
|
|
26
|
+
Moving --> Crash
|
|
27
|
+
Crash --> [*]
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
```mermaid
|
|
31
|
+
---
|
|
32
|
+
title: Simple sample
|
|
33
|
+
---
|
|
34
|
+
stateDiagram-v2
|
|
35
|
+
[*] --> Still
|
|
36
|
+
Still --> [*]
|
|
37
|
+
|
|
38
|
+
Still --> Moving
|
|
39
|
+
Moving --> Still
|
|
40
|
+
Moving --> Crash
|
|
41
|
+
Crash --> [*]
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Older renderer:
|
|
45
|
+
|
|
46
|
+
```mermaid-example
|
|
47
|
+
stateDiagram
|
|
48
|
+
[*] --> Still
|
|
49
|
+
Still --> [*]
|
|
50
|
+
|
|
51
|
+
Still --> Moving
|
|
52
|
+
Moving --> Still
|
|
53
|
+
Moving --> Crash
|
|
54
|
+
Crash --> [*]
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
```mermaid
|
|
58
|
+
stateDiagram
|
|
59
|
+
[*] --> Still
|
|
60
|
+
Still --> [*]
|
|
61
|
+
|
|
62
|
+
Still --> Moving
|
|
63
|
+
Moving --> Still
|
|
64
|
+
Moving --> Crash
|
|
65
|
+
Crash --> [*]
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
In state diagrams systems are described in terms of _states_ and how one _state_ can change to another _state_ via
|
|
69
|
+
a _transition._ The example diagram above shows three states: **Still**, **Moving** and **Crash**. You start in the
|
|
70
|
+
**Still** state. From **Still** you can change to the **Moving** state. From **Moving** you can change either back to the **Still** state or to
|
|
71
|
+
the **Crash** state. There is no transition from **Still** to **Crash**. (You can't crash if you're still.)
|
|
72
|
+
|
|
73
|
+
## States
|
|
74
|
+
|
|
75
|
+
A state can be declared in multiple ways. The simplest way is to define a state with just an id:
|
|
76
|
+
|
|
77
|
+
```mermaid-example
|
|
78
|
+
stateDiagram-v2
|
|
79
|
+
stateId
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
```mermaid
|
|
83
|
+
stateDiagram-v2
|
|
84
|
+
stateId
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Another way is by using the state keyword with a description as per below:
|
|
88
|
+
|
|
89
|
+
```mermaid-example
|
|
90
|
+
stateDiagram-v2
|
|
91
|
+
state "This is a state description" as s2
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
```mermaid
|
|
95
|
+
stateDiagram-v2
|
|
96
|
+
state "This is a state description" as s2
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Another way to define a state with a description is to define the state id followed by a colon and the description:
|
|
100
|
+
|
|
101
|
+
```mermaid-example
|
|
102
|
+
stateDiagram-v2
|
|
103
|
+
s2 : This is a state description
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
```mermaid
|
|
107
|
+
stateDiagram-v2
|
|
108
|
+
s2 : This is a state description
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Transitions
|
|
112
|
+
|
|
113
|
+
Transitions are path/edges when one state passes into another. This is represented using text arrow, "-->".
|
|
114
|
+
|
|
115
|
+
When you define a transition between two states and the states are not already defined, the undefined states are defined
|
|
116
|
+
with the id from the transition. You can later add descriptions to states defined this way.
|
|
117
|
+
|
|
118
|
+
```mermaid-example
|
|
119
|
+
stateDiagram-v2
|
|
120
|
+
s1 --> s2
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
```mermaid
|
|
124
|
+
stateDiagram-v2
|
|
125
|
+
s1 --> s2
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
It is possible to add text to a transition to describe what it represents:
|
|
129
|
+
|
|
130
|
+
```mermaid-example
|
|
131
|
+
stateDiagram-v2
|
|
132
|
+
s1 --> s2: A transition
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
```mermaid
|
|
136
|
+
stateDiagram-v2
|
|
137
|
+
s1 --> s2: A transition
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## Start and End
|
|
141
|
+
|
|
142
|
+
There are two special states indicating the start and stop of the diagram. These are written with the \[\*] syntax and
|
|
143
|
+
the direction of the transition to it defines it either as a start or a stop state.
|
|
144
|
+
|
|
145
|
+
```mermaid-example
|
|
146
|
+
stateDiagram-v2
|
|
147
|
+
[*] --> s1
|
|
148
|
+
s1 --> [*]
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
```mermaid
|
|
152
|
+
stateDiagram-v2
|
|
153
|
+
[*] --> s1
|
|
154
|
+
s1 --> [*]
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## Composite states
|
|
158
|
+
|
|
159
|
+
In a real world use of state diagrams you often end up with diagrams that are multidimensional as one state can
|
|
160
|
+
have several internal states. These are called composite states in this terminology.
|
|
161
|
+
|
|
162
|
+
In order to define a composite state you need to use the state keyword followed by an id and the body of the composite
|
|
163
|
+
state between {}. You can name a composite state on a separate line just like a simple state. See the example below:
|
|
164
|
+
|
|
165
|
+
```mermaid-example
|
|
166
|
+
stateDiagram-v2
|
|
167
|
+
[*] --> First
|
|
168
|
+
state First {
|
|
169
|
+
[*] --> second
|
|
170
|
+
second --> [*]
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
[*] --> NamedComposite
|
|
174
|
+
NamedComposite: Another Composite
|
|
175
|
+
state NamedComposite {
|
|
176
|
+
[*] --> namedSimple
|
|
177
|
+
namedSimple --> [*]
|
|
178
|
+
namedSimple: Another simple
|
|
179
|
+
}
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
```mermaid
|
|
183
|
+
stateDiagram-v2
|
|
184
|
+
[*] --> First
|
|
185
|
+
state First {
|
|
186
|
+
[*] --> second
|
|
187
|
+
second --> [*]
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
[*] --> NamedComposite
|
|
191
|
+
NamedComposite: Another Composite
|
|
192
|
+
state NamedComposite {
|
|
193
|
+
[*] --> namedSimple
|
|
194
|
+
namedSimple --> [*]
|
|
195
|
+
namedSimple: Another simple
|
|
196
|
+
}
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
You can do this in several layers:
|
|
200
|
+
|
|
201
|
+
```mermaid-example
|
|
202
|
+
stateDiagram-v2
|
|
203
|
+
[*] --> First
|
|
204
|
+
|
|
205
|
+
state First {
|
|
206
|
+
[*] --> Second
|
|
207
|
+
|
|
208
|
+
state Second {
|
|
209
|
+
[*] --> second
|
|
210
|
+
second --> Third
|
|
211
|
+
|
|
212
|
+
state Third {
|
|
213
|
+
[*] --> third
|
|
214
|
+
third --> [*]
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
```mermaid
|
|
221
|
+
stateDiagram-v2
|
|
222
|
+
[*] --> First
|
|
223
|
+
|
|
224
|
+
state First {
|
|
225
|
+
[*] --> Second
|
|
226
|
+
|
|
227
|
+
state Second {
|
|
228
|
+
[*] --> second
|
|
229
|
+
second --> Third
|
|
230
|
+
|
|
231
|
+
state Third {
|
|
232
|
+
[*] --> third
|
|
233
|
+
third --> [*]
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
You can also define transitions also between composite states:
|
|
240
|
+
|
|
241
|
+
```mermaid-example
|
|
242
|
+
stateDiagram-v2
|
|
243
|
+
[*] --> First
|
|
244
|
+
First --> Second
|
|
245
|
+
First --> Third
|
|
246
|
+
|
|
247
|
+
state First {
|
|
248
|
+
[*] --> fir
|
|
249
|
+
fir --> [*]
|
|
250
|
+
}
|
|
251
|
+
state Second {
|
|
252
|
+
[*] --> sec
|
|
253
|
+
sec --> [*]
|
|
254
|
+
}
|
|
255
|
+
state Third {
|
|
256
|
+
[*] --> thi
|
|
257
|
+
thi --> [*]
|
|
258
|
+
}
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
```mermaid
|
|
262
|
+
stateDiagram-v2
|
|
263
|
+
[*] --> First
|
|
264
|
+
First --> Second
|
|
265
|
+
First --> Third
|
|
266
|
+
|
|
267
|
+
state First {
|
|
268
|
+
[*] --> fir
|
|
269
|
+
fir --> [*]
|
|
270
|
+
}
|
|
271
|
+
state Second {
|
|
272
|
+
[*] --> sec
|
|
273
|
+
sec --> [*]
|
|
274
|
+
}
|
|
275
|
+
state Third {
|
|
276
|
+
[*] --> thi
|
|
277
|
+
thi --> [*]
|
|
278
|
+
}
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
_You cannot define transitions between internal states belonging to different composite states_
|
|
282
|
+
|
|
283
|
+
## Choice
|
|
284
|
+
|
|
285
|
+
Sometimes you need to model a choice between two or more paths, you can do so using <\<choice>>.
|
|
286
|
+
|
|
287
|
+
```mermaid-example
|
|
288
|
+
stateDiagram-v2
|
|
289
|
+
state if_state <<choice>>
|
|
290
|
+
[*] --> IsPositive
|
|
291
|
+
IsPositive --> if_state
|
|
292
|
+
if_state --> False: if n < 0
|
|
293
|
+
if_state --> True : if n >= 0
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
```mermaid
|
|
297
|
+
stateDiagram-v2
|
|
298
|
+
state if_state <<choice>>
|
|
299
|
+
[*] --> IsPositive
|
|
300
|
+
IsPositive --> if_state
|
|
301
|
+
if_state --> False: if n < 0
|
|
302
|
+
if_state --> True : if n >= 0
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
## Forks
|
|
306
|
+
|
|
307
|
+
It is possible to specify a fork in the diagram using <\<fork>> <\<join>>.
|
|
308
|
+
|
|
309
|
+
```mermaid-example
|
|
310
|
+
stateDiagram-v2
|
|
311
|
+
state fork_state <<fork>>
|
|
312
|
+
[*] --> fork_state
|
|
313
|
+
fork_state --> State2
|
|
314
|
+
fork_state --> State3
|
|
315
|
+
|
|
316
|
+
state join_state <<join>>
|
|
317
|
+
State2 --> join_state
|
|
318
|
+
State3 --> join_state
|
|
319
|
+
join_state --> State4
|
|
320
|
+
State4 --> [*]
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
```mermaid
|
|
324
|
+
stateDiagram-v2
|
|
325
|
+
state fork_state <<fork>>
|
|
326
|
+
[*] --> fork_state
|
|
327
|
+
fork_state --> State2
|
|
328
|
+
fork_state --> State3
|
|
329
|
+
|
|
330
|
+
state join_state <<join>>
|
|
331
|
+
State2 --> join_state
|
|
332
|
+
State3 --> join_state
|
|
333
|
+
join_state --> State4
|
|
334
|
+
State4 --> [*]
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
## Notes
|
|
338
|
+
|
|
339
|
+
Sometimes nothing says it better than a Post-it note. That is also the case in state diagrams.
|
|
340
|
+
|
|
341
|
+
Here you can choose to put the note to the _right of_ or to the _left of_ a node.
|
|
342
|
+
|
|
343
|
+
```mermaid-example
|
|
344
|
+
stateDiagram-v2
|
|
345
|
+
State1: The state with a note
|
|
346
|
+
note right of State1
|
|
347
|
+
Important information! You can write
|
|
348
|
+
notes.
|
|
349
|
+
end note
|
|
350
|
+
State1 --> State2
|
|
351
|
+
note left of State2 : This is the note to the left.
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
```mermaid
|
|
355
|
+
stateDiagram-v2
|
|
356
|
+
State1: The state with a note
|
|
357
|
+
note right of State1
|
|
358
|
+
Important information! You can write
|
|
359
|
+
notes.
|
|
360
|
+
end note
|
|
361
|
+
State1 --> State2
|
|
362
|
+
note left of State2 : This is the note to the left.
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
## Concurrency
|
|
366
|
+
|
|
367
|
+
As in plantUml you can specify concurrency using the -- symbol.
|
|
368
|
+
|
|
369
|
+
```mermaid-example
|
|
370
|
+
stateDiagram-v2
|
|
371
|
+
[*] --> Active
|
|
372
|
+
|
|
373
|
+
state Active {
|
|
374
|
+
[*] --> NumLockOff
|
|
375
|
+
NumLockOff --> NumLockOn : EvNumLockPressed
|
|
376
|
+
NumLockOn --> NumLockOff : EvNumLockPressed
|
|
377
|
+
--
|
|
378
|
+
[*] --> CapsLockOff
|
|
379
|
+
CapsLockOff --> CapsLockOn : EvCapsLockPressed
|
|
380
|
+
CapsLockOn --> CapsLockOff : EvCapsLockPressed
|
|
381
|
+
--
|
|
382
|
+
[*] --> ScrollLockOff
|
|
383
|
+
ScrollLockOff --> ScrollLockOn : EvScrollLockPressed
|
|
384
|
+
ScrollLockOn --> ScrollLockOff : EvScrollLockPressed
|
|
385
|
+
}
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
```mermaid
|
|
389
|
+
stateDiagram-v2
|
|
390
|
+
[*] --> Active
|
|
391
|
+
|
|
392
|
+
state Active {
|
|
393
|
+
[*] --> NumLockOff
|
|
394
|
+
NumLockOff --> NumLockOn : EvNumLockPressed
|
|
395
|
+
NumLockOn --> NumLockOff : EvNumLockPressed
|
|
396
|
+
--
|
|
397
|
+
[*] --> CapsLockOff
|
|
398
|
+
CapsLockOff --> CapsLockOn : EvCapsLockPressed
|
|
399
|
+
CapsLockOn --> CapsLockOff : EvCapsLockPressed
|
|
400
|
+
--
|
|
401
|
+
[*] --> ScrollLockOff
|
|
402
|
+
ScrollLockOff --> ScrollLockOn : EvScrollLockPressed
|
|
403
|
+
ScrollLockOn --> ScrollLockOff : EvScrollLockPressed
|
|
404
|
+
}
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
## Setting the direction of the diagram
|
|
408
|
+
|
|
409
|
+
With state diagrams you can use the direction statement to set the direction which the diagram will render like in this
|
|
410
|
+
example.
|
|
411
|
+
|
|
412
|
+
```mermaid-example
|
|
413
|
+
stateDiagram
|
|
414
|
+
direction LR
|
|
415
|
+
[*] --> A
|
|
416
|
+
A --> B
|
|
417
|
+
B --> C
|
|
418
|
+
state B {
|
|
419
|
+
direction LR
|
|
420
|
+
a --> b
|
|
421
|
+
}
|
|
422
|
+
B --> D
|
|
423
|
+
```
|
|
424
|
+
|
|
425
|
+
```mermaid
|
|
426
|
+
stateDiagram
|
|
427
|
+
direction LR
|
|
428
|
+
[*] --> A
|
|
429
|
+
A --> B
|
|
430
|
+
B --> C
|
|
431
|
+
state B {
|
|
432
|
+
direction LR
|
|
433
|
+
a --> b
|
|
434
|
+
}
|
|
435
|
+
B --> D
|
|
436
|
+
```
|
|
437
|
+
|
|
438
|
+
## Comments
|
|
439
|
+
|
|
440
|
+
Comments can be entered within a state diagram chart, which will be ignored by the parser. Comments must be prefaced with `%%` (double percent signs) and any text after their start to the next newline will be treated as a comment, including any diagram syntax. They can be on their own line or at the end of a statement.
|
|
441
|
+
|
|
442
|
+
```mermaid-example
|
|
443
|
+
stateDiagram-v2
|
|
444
|
+
[*] --> Still
|
|
445
|
+
Still --> [*]
|
|
446
|
+
%% this is a comment
|
|
447
|
+
Still --> Moving
|
|
448
|
+
Moving --> Still %% another comment
|
|
449
|
+
Moving --> Crash
|
|
450
|
+
Crash --> [*]
|
|
451
|
+
```
|
|
452
|
+
|
|
453
|
+
```mermaid
|
|
454
|
+
stateDiagram-v2
|
|
455
|
+
[*] --> Still
|
|
456
|
+
Still --> [*]
|
|
457
|
+
%% this is a comment
|
|
458
|
+
Still --> Moving
|
|
459
|
+
Moving --> Still %% another comment
|
|
460
|
+
Moving --> Crash
|
|
461
|
+
Crash --> [*]
|
|
462
|
+
```
|
|
463
|
+
|
|
464
|
+
## Styling with classDefs
|
|
465
|
+
|
|
466
|
+
As with other diagrams (like flowcharts), you can define a style in the diagram itself and apply that named style to a
|
|
467
|
+
state or states in the diagram.
|
|
468
|
+
|
|
469
|
+
**These are the current limitations with state diagram classDefs:**
|
|
470
|
+
|
|
471
|
+
1. Cannot be applied to start or end states
|
|
472
|
+
2. Cannot be applied to or within composite states
|
|
473
|
+
|
|
474
|
+
_These are in development and will be available in a future version._
|
|
475
|
+
|
|
476
|
+
You define a style using the `classDef` keyword, which is short for "class definition" (where "class" means something
|
|
477
|
+
like a _CSS class_)
|
|
478
|
+
followed by _a name for the style,_
|
|
479
|
+
and then one or more _property-value pairs_. Each _property-value pair_ is
|
|
480
|
+
a _[valid CSS property name](https://www.w3.org/TR/CSS/#properties)_ followed by a colon (`:`) and then a _value._
|
|
481
|
+
|
|
482
|
+
Here is an example of a classDef with just one property-value pair:
|
|
483
|
+
|
|
484
|
+
```txt
|
|
485
|
+
classDef movement font-style:italic;
|
|
486
|
+
```
|
|
487
|
+
|
|
488
|
+
where
|
|
489
|
+
|
|
490
|
+
- the _name_ of the style is `movement`
|
|
491
|
+
- the only _property_ is `font-style` and its _value_ is `italic`
|
|
492
|
+
|
|
493
|
+
If you want to have more than one _property-value pair_ then you put a comma (`,`) between each _property-value pair._
|
|
494
|
+
|
|
495
|
+
Here is an example with three property-value pairs:
|
|
496
|
+
|
|
497
|
+
```txt
|
|
498
|
+
classDef badBadEvent fill:#f00,color:white,font-weight:bold,stroke-width:2px,stroke:yellow
|
|
499
|
+
```
|
|
500
|
+
|
|
501
|
+
where
|
|
502
|
+
|
|
503
|
+
- the _name_ of the style is `badBadEvent`
|
|
504
|
+
- the first _property_ is `fill` and its _value_ is `#f00`
|
|
505
|
+
- the second _property_ is `color` and its _value_ is `white`
|
|
506
|
+
- the third _property_ is `font-weight` and its _value_ is `bold`
|
|
507
|
+
- the fourth _property_ is `stroke-width` and its _value_ is `2px`
|
|
508
|
+
- the fifth _property_ is `stroke` and its _value_ is `yellow`
|
|
509
|
+
|
|
510
|
+
### Apply classDef styles to states
|
|
511
|
+
|
|
512
|
+
There are two ways to apply a `classDef` style to a state:
|
|
513
|
+
|
|
514
|
+
1. use the `class` keyword to apply a classDef style to one or more states in a single statement, or
|
|
515
|
+
2. use the `:::` operator to apply a classDef style to a state as it is being used in a transition statement (e.g. with an arrow
|
|
516
|
+
to/from another state)
|
|
517
|
+
|
|
518
|
+
#### 1. `class` statement
|
|
519
|
+
|
|
520
|
+
A `class` statement tells Mermaid to apply the named classDef to one or more classes. The form is:
|
|
521
|
+
|
|
522
|
+
```txt
|
|
523
|
+
class [one or more state names, separated by commas] [name of a style defined with classDef]
|
|
524
|
+
```
|
|
525
|
+
|
|
526
|
+
Here is an example applying the `badBadEvent` style to a state named `Crash`:
|
|
527
|
+
|
|
528
|
+
```txt
|
|
529
|
+
class Crash badBadEvent
|
|
530
|
+
```
|
|
531
|
+
|
|
532
|
+
Here is an example applying the `movement` style to the two states `Moving` and `Crash`:
|
|
533
|
+
|
|
534
|
+
```txt
|
|
535
|
+
class Moving, Crash movement
|
|
536
|
+
```
|
|
537
|
+
|
|
538
|
+
Here is a diagram that shows the examples in use. Note that the `Crash` state has two classDef styles applied: `movement`
|
|
539
|
+
and `badBadEvent`
|
|
540
|
+
|
|
541
|
+
```mermaid-example
|
|
542
|
+
stateDiagram
|
|
543
|
+
direction TB
|
|
544
|
+
|
|
545
|
+
accTitle: This is the accessible title
|
|
546
|
+
accDescr: This is an accessible description
|
|
547
|
+
|
|
548
|
+
classDef notMoving fill:white
|
|
549
|
+
classDef movement font-style:italic
|
|
550
|
+
classDef badBadEvent fill:#f00,color:white,font-weight:bold,stroke-width:2px,stroke:yellow
|
|
551
|
+
|
|
552
|
+
[*]--> Still
|
|
553
|
+
Still --> [*]
|
|
554
|
+
Still --> Moving
|
|
555
|
+
Moving --> Still
|
|
556
|
+
Moving --> Crash
|
|
557
|
+
Crash --> [*]
|
|
558
|
+
|
|
559
|
+
class Still notMoving
|
|
560
|
+
class Moving, Crash movement
|
|
561
|
+
class Crash badBadEvent
|
|
562
|
+
class end badBadEvent
|
|
563
|
+
```
|
|
564
|
+
|
|
565
|
+
```mermaid
|
|
566
|
+
stateDiagram
|
|
567
|
+
direction TB
|
|
568
|
+
|
|
569
|
+
accTitle: This is the accessible title
|
|
570
|
+
accDescr: This is an accessible description
|
|
571
|
+
|
|
572
|
+
classDef notMoving fill:white
|
|
573
|
+
classDef movement font-style:italic
|
|
574
|
+
classDef badBadEvent fill:#f00,color:white,font-weight:bold,stroke-width:2px,stroke:yellow
|
|
575
|
+
|
|
576
|
+
[*]--> Still
|
|
577
|
+
Still --> [*]
|
|
578
|
+
Still --> Moving
|
|
579
|
+
Moving --> Still
|
|
580
|
+
Moving --> Crash
|
|
581
|
+
Crash --> [*]
|
|
582
|
+
|
|
583
|
+
class Still notMoving
|
|
584
|
+
class Moving, Crash movement
|
|
585
|
+
class Crash badBadEvent
|
|
586
|
+
class end badBadEvent
|
|
587
|
+
```
|
|
588
|
+
|
|
589
|
+
#### 2. `:::` operator to apply a style to a state
|
|
590
|
+
|
|
591
|
+
You can apply a classDef style to a state using the `:::` (three colons) operator. The syntax is
|
|
592
|
+
|
|
593
|
+
```txt
|
|
594
|
+
[state]:::[style name]
|
|
595
|
+
```
|
|
596
|
+
|
|
597
|
+
You can use this in a diagram within a statement using a class. This includes the start and end states. For example:
|
|
598
|
+
|
|
599
|
+
```mermaid-example
|
|
600
|
+
stateDiagram
|
|
601
|
+
direction TB
|
|
602
|
+
|
|
603
|
+
accTitle: This is the accessible title
|
|
604
|
+
accDescr: This is an accessible description
|
|
605
|
+
|
|
606
|
+
classDef notMoving fill:white
|
|
607
|
+
classDef movement font-style:italic;
|
|
608
|
+
classDef badBadEvent fill:#f00,color:white,font-weight:bold,stroke-width:2px,stroke:yellow
|
|
609
|
+
|
|
610
|
+
[*] --> Still:::notMoving
|
|
611
|
+
Still --> [*]
|
|
612
|
+
Still --> Moving:::movement
|
|
613
|
+
Moving --> Still
|
|
614
|
+
Moving --> Crash:::movement
|
|
615
|
+
Crash:::badBadEvent --> [*]
|
|
616
|
+
```
|
|
617
|
+
|
|
618
|
+
```mermaid
|
|
619
|
+
stateDiagram
|
|
620
|
+
direction TB
|
|
621
|
+
|
|
622
|
+
accTitle: This is the accessible title
|
|
623
|
+
accDescr: This is an accessible description
|
|
624
|
+
|
|
625
|
+
classDef notMoving fill:white
|
|
626
|
+
classDef movement font-style:italic;
|
|
627
|
+
classDef badBadEvent fill:#f00,color:white,font-weight:bold,stroke-width:2px,stroke:yellow
|
|
628
|
+
|
|
629
|
+
[*] --> Still:::notMoving
|
|
630
|
+
Still --> [*]
|
|
631
|
+
Still --> Moving:::movement
|
|
632
|
+
Moving --> Still
|
|
633
|
+
Moving --> Crash:::movement
|
|
634
|
+
Crash:::badBadEvent --> [*]
|
|
635
|
+
```
|
|
636
|
+
|
|
637
|
+
## Spaces in state names
|
|
638
|
+
|
|
639
|
+
Spaces can be added to a state by first defining the state with an id and then referencing the id later.
|
|
640
|
+
|
|
641
|
+
In the following example there is a state with the id **yswsii** and description **Your state with spaces in it**.
|
|
642
|
+
After it has been defined, **yswsii** is used in the diagram in the first transition (`[*] --> yswsii`)
|
|
643
|
+
and also in the transition to **YetAnotherState** (`yswsii --> YetAnotherState`).
|
|
644
|
+
(**yswsii** has been styled so that it is different from the other states.)
|
|
645
|
+
|
|
646
|
+
```mermaid-example
|
|
647
|
+
stateDiagram
|
|
648
|
+
classDef yourState font-style:italic,font-weight:bold,fill:white
|
|
649
|
+
|
|
650
|
+
yswsii: Your state with spaces in it
|
|
651
|
+
[*] --> yswsii:::yourState
|
|
652
|
+
[*] --> SomeOtherState
|
|
653
|
+
SomeOtherState --> YetAnotherState
|
|
654
|
+
yswsii --> YetAnotherState
|
|
655
|
+
YetAnotherState --> [*]
|
|
656
|
+
```
|
|
657
|
+
|
|
658
|
+
```mermaid
|
|
659
|
+
stateDiagram
|
|
660
|
+
classDef yourState font-style:italic,font-weight:bold,fill:white
|
|
661
|
+
|
|
662
|
+
yswsii: Your state with spaces in it
|
|
663
|
+
[*] --> yswsii:::yourState
|
|
664
|
+
[*] --> SomeOtherState
|
|
665
|
+
SomeOtherState --> YetAnotherState
|
|
666
|
+
yswsii --> YetAnotherState
|
|
667
|
+
YetAnotherState --> [*]
|
|
668
|
+
```
|
|
669
|
+
|
|
670
|
+
<!--- cspell:ignore yswsii --->
|