PhoenixGenApiTui.Views.FormatHelpers (phoenix_gen_api_tui v0.1.0)

Copy Markdown View Source

Shared formatting helpers for rendering nested data structures in text-based views.

Used by ClusterTab, HealthTab, StatsTab, and RateLimitsTab to consistently format maps, lists, and primitive values with indentation.

Summary

Functions

Formats a nested data structure into a list of indented string lines.

Formats a primitive value for display, with number abbreviations.

Functions

format_nested(data, indent \\ 1)

@spec format_nested(term(), non_neg_integer()) :: [String.t()]

Formats a nested data structure into a list of indented string lines.

Examples

iex> PhoenixGenApiTui.Views.FormatHelpers.format_nested(%{a: 1, b: [2, 3]})
["  :a:", "    1", "  :b:", "    - 2", "    - 3"]

format_primitive(value)

@spec format_primitive(term()) :: String.t()

Formats a primitive value for display, with number abbreviations.