Raxol.Debug.Inspector (Raxol v2.6.0)

View Source

Pure functions for rendering a map/struct as an expandable tree.

Flattens a nested map into displayable lines with indentation and expand/collapse markers. Used by the Debugger UI's model inspector panel.

Summary

Functions

Expands all paths in the model to the given depth.

Flattens a model (map) into a list of displayable lines.

Toggles a path in the expanded set. Returns the updated MapSet.

Types

line()

@type line() :: %{
  depth: non_neg_integer(),
  path: [term()],
  key: term(),
  value_preview: String.t(),
  expandable: boolean(),
  expanded: boolean()
}

Functions

expand_all(model, max_depth \\ 3)

@spec expand_all(term(), non_neg_integer()) :: MapSet.t()

Expands all paths in the model to the given depth.

flatten(model, expanded_paths \\ MapSet.new())

@spec flatten(term(), MapSet.t()) :: [line()]

Flattens a model (map) into a list of displayable lines.

Each line includes its depth, key path, a preview string, and whether it's expandable (has nested map children). The expanded_paths MapSet controls which nodes show their children.

Parameters

  • model - The map/struct to inspect
  • expanded_paths - MapSet of key paths that are expanded

Returns

List of line() maps suitable for rendering.

toggle(expanded_paths, path)

@spec toggle(MapSet.t(), [term()]) :: MapSet.t()

Toggles a path in the expanded set. Returns the updated MapSet.