Dala.Designer.Codegen (dala v0.8.1)

Copy Markdown View Source

Generates Elixir screen module source code from Dala UI trees.

Outputs Spark DSL style with snake_case entities.

UI trees use the map format: %{type: :atom, props: %{...}, children: [...]}.

Summary

Functions

Build a map of handler => [component_types] by walking the UI tree. Used by generate_dsl_with_docs/3 to annotate handlers with their sources.

Extract event handler names from a UI tree.

Generate DSL-style screen module source.

Generate DSL-style screen module source with @doc annotations on handle_event/3 stubs.

Functions

build_component_map(ui_tree)

Build a map of handler => [component_types] by walking the UI tree. Used by generate_dsl_with_docs/3 to annotate handlers with their sources.

extract_handlers(ui_tree)

Extract event handler names from a UI tree.

generate_dsl(module_name, ui_tree, opts \\ [])

Generate DSL-style screen module source.

generate_dsl_with_docs(module_name, ui_tree, opts \\ [])

Generate DSL-style screen module source with @doc annotations on handle_event/3 stubs.

Each handler's @doc references the component types that can trigger it, making it easier to understand the event flow at a glance.

Options

  • :attributes — list of {name, type, default} tuples for DSL attributes
  • :component_map — optional pre-computed map of handler => [component_types] (useful for avoiding re-traversal when caller already has this info)

Example output

def handle_event(:increment, _params, socket) do
  @doc "Triggered by: text, button"
  {:noreply, socket}
end