Pentiment

CI Hex.pm Docs

Beautiful, compiler-style diagnostic messages for Elixir.

State machine error example

Features

Installation

def deps do
[{:pentiment, "~> 0.2"}]
end

Quick Example

alias Pentiment.{Report, Label, Span, Source}
report =
Report.error("Undefined variable")
|> Report.with_code("E001")
|> Report.with_source("lib/app.ex")
|> Report.with_label(Label.primary(Span.position(10, 5), "not found in scope"))
|> Report.with_help("did you mean `user`?")
source = Source.from_file("lib/app.ex")
IO.puts(Pentiment.format(report, source))

Syntax Highlighting

Pentiment has no hard runtime dependencies. To syntax-highlight the source excerpts in rendered diagnostics, add the makeup lexers for the languages you report on:

def deps do
[
{:pentiment, "~> 0.2"},
{:makeup_elixir, "~> 1.0"},
{:makeup_erlang, "~> 1.0"}
]
end

Highlighting activates automatically (syntax: :auto) when ANSI colors are active, a lexer is available, and the source's language is known — inferred from the source name's extension (.ex/.exs, .erl/.hrl), or set explicitly with Pentiment.Source.from_string("gen.ex", code, language: :elixir). Pass syntax: false to disable it, or colors: false for fully plain output (for example, when rendering into editor diagnostics). A custom highlighter module implementing Pentiment.Highlighter can be supplied via the :highlighter option.

Use Cases

Pentiment is designed for:

Documentation

Full API documentation available on HexDocs.