Packages
reactor
0.15.0
1.0.2
1.0.1
1.0.0
0.17.0
0.16.0
0.15.6
0.15.5
0.15.4
0.15.3
0.15.2
0.15.1
0.15.0
0.14.0
0.13.3
0.13.2
0.13.1
0.13.0
0.12.1
0.12.0
0.11.0
0.10.3
0.10.2
0.10.1
0.10.0
0.9.1
0.9.0
0.8.5
0.8.4
0.8.3
0.8.2
0.8.1
0.8.0
0.7.0
0.6.0
0.5.2
0.5.1
0.5.0
0.4.1
0.4.0
0.3.5
0.3.4
0.3.3
0.3.2
0.3.1
0.3.0
0.2.4
0.2.3
0.2.2
0.2.1
0.2.0
0.1.0
An asynchronous, graph-based execution engine
Current section
Files
Jump to
Current section
Files
lib/reactor/step/around/mermaid.ex
defmodule Reactor.Step.Around.Mermaid do
@moduledoc """
Mermaid rendering for `around` steps.
"""
alias Reactor.Mermaid.{Node, Reactor, Utils}
import Utils
@doc false
def to_mermaid(step, reactor, options) do
with {:ok, sub_graph} <- Reactor.to_mermaid(reactor, options),
{:ok, node} <- describe_step(step, options) do
inner_return_id = mermaid_id(reactor.id, :return)
links =
reactor.inputs
|> Enum.map(fn input ->
[node.id, "-->", mermaid_id({reactor.id, input}, :input), "\n"]
end)
|> Enum.concat([inner_return_id, "-->", node.id, "\n"])
{:ok, %{node | post: [sub_graph, node.post, links]}}
end
end
defp describe_step(%{impl: {module, opts}} = step, options) do
id = mermaid_id({options[:reactor_id], step.name}, :step)
fun = Keyword.fetch!(opts, :fun)
content =
if options[:describe?] do
[
id,
"[\"`**",
md_escape(name(step.name)),
" \\(",
inspect(module),
"\\)**\n",
"_",
md_escape(inspect(fun)),
"_",
if(step.description, do: ["\n", md_escape(step.description)], else: []),
"`\"]\n"
]
else
[
id,
"[\"",
name(step.name),
"(",
inspect(module),
")\"]\n"
]
end
{:ok, %Node{id: id, pre: content}}
end
end