Experimental Livebook-friendly DSL for sketching UML class diagrams.
This Lab DSL compiles to the stable, pipe-first Choreo.UML builders and
returns an ordinary %Choreo.UML{}. Classes, structs, behaviors, protocols,
and interfaces can be declared with block-based fields and functions. Edges
expose UML relationship types as readable domain vocabulary.
Examples
iex> import Choreo.Lab.DSL.UML
...> diagram = uml do
...> user = struct("User") do
...> field :id, :integer
...> private field(:email, :string)
...> function :authenticate, 2, return: :boolean
...> end
...>
...> auth = behavior("AuthProvider") do
...> function :verify, 1, return: :ok_error
...> end
...>
...> realizes user ~> auth, "implements"
...> end
iex> diagram.graph.nodes[:user].type
:struct
iex> diagram.graph.nodes[:user].fields |> Enum.map(& &1[:name])
["id", "email"]
iex> [meta] = Map.values(diagram.edge_meta)
iex> {meta.type, meta.label}
{:realizes, "implements"}Relationship edges can use typed constructors, generic edge, or pipe
modifiers:
inherits child ~> parent, "extends"
realizes adapter ~> protocol, "implements"
associates user ~> profile, "has one"
depends controller ~> repo, "calls"
edge controller ~> repo, depends: "calls"
controller ~> repo |> depends("calls")The generic ~> form defaults to :depends, which matches a lightweight
dependency sketch.
Summary
Functions
Returns the vocabulary supported by the UML DSL.
Builds a %Choreo.UML{} from a compact Lab DSL block.
Compatibility alias for taxonomy/0.
Types
@type class_decl() :: %{id: Yog.node_id(), opts: keyword()}
@type relationship_decl() :: %{ from: Yog.node_id(), to: Yog.node_id(), opts: keyword() }
Functions
@spec taxonomy() :: %{ nodes: [atom()], members: [atom()], edges: [atom()], modifiers: [atom()], options: [atom()] }
Returns the vocabulary supported by the UML DSL.
This is meant as a lightweight Livebook discovery helper when autocomplete is not enough.
iex> taxonomy = Choreo.Lab.DSL.UML.taxonomy()
iex> :struct in taxonomy.nodes
true
iex> :function in taxonomy.members
true
iex> :implements in taxonomy.edges
true
Builds a %Choreo.UML{} from a compact Lab DSL block.
@spec verbs() :: %{ nodes: [atom()], members: [atom()], edges: [atom()], modifiers: [atom()], options: [atom()] }
Compatibility alias for taxonomy/0.