Raxol.Debug.DiffFormatter (Raxol v2.6.0)

View Source

Pure functions for formatting Snapshot changes into styled display lines.

Converts the {:changed, path, old, new}, {:added, path, val}, and {:removed, path, val} tuples from Snapshot.diff/2 into text lines with color indicators suitable for the debugger UI.

Summary

Functions

Formats a list of Snapshot changes into displayable lines.

Formats a key path list into a readable dot-separated string.

Formats a snapshot's internal diff (model_before vs model_after).

Renders a formatted line into a display string with prefix indicator.

Types

formatted_line()

@type formatted_line() :: %{
  type: :changed | :added | :removed,
  path_str: String.t(),
  detail: String.t()
}

Functions

format_changes(changes)

@spec format_changes([Raxol.Debug.Snapshot.change()]) :: [formatted_line()]

Formats a list of Snapshot changes into displayable lines.

Parameters

  • changes - List of Snapshot.change() tuples

Returns

List of formatted_line() maps.

format_path(path)

@spec format_path([term()]) :: String.t()

Formats a key path list into a readable dot-separated string.

format_snapshot_diff(snap)

@spec format_snapshot_diff(Raxol.Debug.Snapshot.t()) :: [formatted_line()]

Formats a snapshot's internal diff (model_before vs model_after).

render_line(line)

@spec render_line(formatted_line()) :: {String.t(), String.t()}

Renders a formatted line into a display string with prefix indicator.

Returns {prefix, text} where prefix is "+", "-", or "~".