Draws a workflow as a diagram.
A chart reads the workflow DSL, so it shows which steps are automatic,
manual, wait states or terminal. It labels timeouts with their deadlines,
shows the condition of each route, and draws the moves the generated undo
action can make. For a chart of the generated state machine itself, use
AshStateMachine.Charts.
AshWorkflow.Charts.mermaid_state_diagram(MyApp.Candidate)
AshWorkflow.Charts.render(MyApp.Candidate, :json, pretty: true)Each format is a module that implements AshWorkflow.Charts.Backend, and all
of them draw from the same AshWorkflow.Charts.Graph. The formats this
library ships are:
:mermaid—AshWorkflow.Charts.Mermaid, a MermaidstateDiagram-v2.:json—AshWorkflow.Charts.Json, plain data for a client that draws the workflow itself.:dot—AshWorkflow.Charts.Dot, a Graphviz DOT chart with colour and line styles.svg: truedraws it as SVG withdot.
mix ash_workflow.diagram writes the same output from the command line.
Summary
Functions
The backend module for a format name, or the module itself when it
implements AshWorkflow.Charts.Backend. Raises ArgumentError otherwise.
The diagram model for a resource. See AshWorkflow.Charts.Graph.build/2.
Draws a resource's workflow as a Mermaid stateDiagram-v2. The same as
render(resource, :mermaid, opts).
Draws a resource's workflow in a format, and returns the diagram as a string.
Functions
The backend module for a format name, or the module itself when it
implements AshWorkflow.Charts.Backend. Raises ArgumentError otherwise.
@spec formats() :: [atom()]
The format names render/3 accepts in place of a backend module.
@spec graph(Ash.Resource.t(), keyword()) :: AshWorkflow.Charts.Graph.t()
The diagram model for a resource. See AshWorkflow.Charts.Graph.build/2.
@spec mermaid_state_diagram(Ash.Resource.t(), keyword()) :: String.t()
Draws a resource's workflow as a Mermaid stateDiagram-v2. The same as
render(resource, :mermaid, opts).
@spec render(Ash.Resource.t(), atom(), keyword()) :: String.t()
Draws a resource's workflow in a format, and returns the diagram as a string.
Options
:undo and :notes go to AshWorkflow.Charts.Graph.build/2. Every other
option goes to the backend, for example :pretty for :json.