TLX.Emitter.D2 (TLX v0.5.2)

Copy Markdown

Emits a D2 (Terrastruct) state diagram from a compiled TLX.Spec module.

Renders with the D2 CLI, Terrastruct, or any tool that supports D2 diagram-as-code syntax.

Usage

TLX.Emitter.D2.emit(MySpec)
TLX.Emitter.D2.emit(MySpec, state_var: :status)

Output:

direction: right
red.style.fill: "#f4f4f4"
red -> green: to_green
green -> yellow: to_yellow
yellow -> red: to_red

Summary

Functions

Generate a D2 state diagram string from a compiled spec module.

Functions

emit(module, opts \\ [])

Generate a D2 state diagram string from a compiled spec module.

Options:

  • :state_var — name of the state variable (auto-detected if omitted)