Draws an AshWorkflow.Charts.Graph as a Mermaid stateDiagram-v2.
GitHub, Livebook and ExDoc (with the script this library's own docs use) show the result without other tools.
- Each step is declared as
state "review" as step_review. Thestep_prefix keeps a step name such as:noteor:endfrom being read as a Mermaid keyword. A character outsideA-Z,a-z,0-9and_becomes_and its code point in hex.render/2raisesArgumentErrorif two step names still map to one ID, such as:"re-open"and:re_2Dopen. - Each step that is not terminal has a description line with its kind:
⚙️ automatic,✋ manualor⏳ wait state. The gear carries U+FE0F, so it draws as a colour emoji, the same as the other two. - The initial step has an edge from
[*], and every terminal step has an edge to[*]. - An edge label starts with a symbol for its kind:
⚙foron_success,✖foron_error,⏱for a timeout and↶for undo. A transition has no symbol. A timeout edge gives the timeout's name and then its deadline, as in⏱ escalation after 7 days. A conditional route addswhenand its condition, and the fallback route of a conditionalon_successaddsotherwise. - A step's notes go in a
note right ofblock:policy:,retry:,⏱for a timeout that runs an action, and↻for anevery.
A state diagram cannot draw a dashed or dotted edge, which is why the edge
kind is in the label. The characters #, ;, <, >, " and \ are written
as Mermaid entity codes, such as #60; for <, so a condition such as
score < 3 cannot break the diagram. A : is written as #58; when another
: follows it or when it ends the text, because Mermaid's label lexer stops
at :: and at a final :. A single : inside text, as in :reviewer,
needs no code.
This backend takes no options.