Macaw.Frame.TextForms.Flowchart (macaw_frame v0.1.0)

Copy Markdown View Source

The flowchart text form (spec/02 §11.3, spec/13 §7.3): a flowchart written as mermaid writes one, read into a layered diagram's design (Macaw.Frame.TextForms).

flowchart LR
  A([Start]) --> B{Ready?}
  B -->|yes| C[Ship]
  B -.->|no| D[(Backlog)]
  subgraph ops [Operations]
    C --> E((Done))
  end
  • The header is flowchart and its direction, TB (or TD), BT, LR or RL, TB by default: the layered step's direction.
  • A statement is a chain of nodes joined by links. A node is an id (letters, digits, _) and its shape and label: A[rect], A(round), A([stadium]), A((circle)), A{diamond}, A{{hexagon}}, A[/parallelogram/], A[(cylinder)], A>note]; a label may be quoted (A["a [b]"]) and <br> breaks it. A node named alone is a rect labeled by its id until a statement gives it a shape.
  • A link is a line, -- (solid), -.- (dotted) or == (thick), with a head and a tail of >/< (arrow), o (circle) or x (cross): -->, ---, -.->, ==>, <-->, --o, x--x; a label follows it as |text|.
  • A subgraph subgraph id [title] … end groups the nodes first named inside it: a row of the groups slot (id, label, parent) and each node's group.

Rows: nodes (id, label, shape, group) in order of first appearance, edges (source, target, label, head, tail, line) in order. Faults, every one at once, at its line and column: {:expected, :node}, {:expected, :link}, {:direction, word}, {:unclosed, :label}, {:unclosed, "subgraph"} at the subgraph, {:unexpected, "end"}. print/1 writes nodes first, each in its subgraph, then one link a line.