Pentiment.Formatter.Renderer (pentiment v0.1.5)
Rich diagnostic formatter with source context and highlighting.
This formatter produces compiler-style error output with:
- Severity and error code header
- Source location with unicode box-drawing frame
- Highlighted source context with underlines and branching labels
- Notes and help suggestions
Example Output
error[E0001]: Type mismatch
╭─[lib/my_app.ex:15:10]
│
14 │ add = fn x :: integer, y :: integer ->
15 │ x + y + 1.5
• ─┬─
• ╰── expected `integer`, found `float`
│
╰─────
note: `+` with integer arguments returns integer
help: consider using `trunc(1.5)`
Summary
Types
@type format_options() :: [colors: boolean(), context_lines: non_neg_integer()]
Functions
@spec format(Pentiment.Diagnostic.t(), Pentiment.Source.t() | map(), format_options()) :: String.t()
Formats a single diagnostic for display.
Options
:colors- Whether to use ANSI colors (default: true, respects IO.ANSI.enabled?()):context_lines- Number of lines of context around labels (default: 2)
Sources
Sources can be provided as:
- A
Pentiment.Sourcestruct - A map of source names to content strings:
%{"file.ex" => "content..."} - A map of source names to
Pentiment.Sourcestructs
@spec format_all( [Pentiment.Diagnostic.t()], Pentiment.Source.t() | map(), format_options() ) :: String.t()
Formats multiple diagnostics for display.