AshWorkflow.Charts (AshWorkflow v0.10.0)

Copy Markdown View Source

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:

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 format names render/3 accepts in place of a backend module.

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

backend!(format)

@spec backend!(term()) :: module()

The backend module for a format name, or the module itself when it implements AshWorkflow.Charts.Backend. Raises ArgumentError otherwise.

formats()

@spec formats() :: [atom()]

The format names render/3 accepts in place of a backend module.

graph(resource, opts \\ [])

The diagram model for a resource. See AshWorkflow.Charts.Graph.build/2.

mermaid_state_diagram(resource, opts \\ [])

@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).

render(resource, format, 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.