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

Functions

Formats a single diagnostic for display.

Formats multiple diagnostics for display.

Types

format_options()

@type format_options() :: [colors: boolean(), context_lines: non_neg_integer()]

Functions

format(diagnostic, sources, opts \\ [])

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:

format_all(diagnostics, sources, opts \\ [])

@spec format_all(
  [Pentiment.Diagnostic.t()],
  Pentiment.Source.t() | map(),
  format_options()
) ::
  String.t()

Formats multiple diagnostics for display.