AshWorkflow.Charts.Mermaid (AshWorkflow v0.10.0)

Copy Markdown View Source

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. The step_ prefix keeps a step name such as :note or :end from being read as a Mermaid keyword. A character outside A-Z, a-z, 0-9 and _ becomes _ and its code point in hex. render/2 raises ArgumentError if 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, ✋ manual or ⏳ 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: ⚙ for on_success, ✖ for on_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 adds when and its condition, and the fallback route of a conditional on_success adds otherwise.
  • A step's notes go in a note right of block: policy:, retry:, ⏱ for a timeout that runs an action, and ↻ for an every.

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.