Yarnspinnex.Mermaid (yarnspinnex v0.3.0)

Copy Markdown View Source

Renders a compiled script as Mermaid flowchart source: node_graph/1 draws one box per node with an edge per <<jump>>, and flowchart/2 draws every line, choice, and branch inside each node with edges following control flow between them.

Summary

Functions

Renders an expression AST back to Yarn source text.

Every statement drawn inside a subgraph per node. Consecutive lines, sets, and commands share one box; options and <<if>> fan out on labeled edges; <<stop>> and the end of a node lead to a shared terminal. Pass nodes: [titles] to draw only those nodes, with jumps out of the set landing on a plain box for the target.

One box per node, one edge per jump, the start node drawn as a stadium.

Functions

expression_text(ast)

@spec expression_text(Yarnspinnex.Parser.Expression.ast()) :: String.t()

Renders an expression AST back to Yarn source text.

flowchart(script, opts \\ [])

@spec flowchart(Yarnspinnex.Script.t(), [{:nodes, [String.t()]}]) :: String.t()

Every statement drawn inside a subgraph per node. Consecutive lines, sets, and commands share one box; options and <<if>> fan out on labeled edges; <<stop>> and the end of a node lead to a shared terminal. Pass nodes: [titles] to draw only those nodes, with jumps out of the set landing on a plain box for the target.

node_graph(script)

@spec node_graph(Yarnspinnex.Script.t()) :: String.t()

One box per node, one edge per jump, the start node drawn as a stadium.