duck-diag 0.8.1

Generic diagnostic engine for building rich error reporting into any tool
Documentation

Renamed from duck-diagnostic (0.7.x). New publishing line: duck-diag 0.8+. Old crate stays on crates.io for compatibility.


Install

cargo add duck-diag

Optional json feature (default on):

[dependencies]
duck-diag = { version = "0.8", features = ["json"] }

Quick start

use duck_diag::{Diagnostic, Label, Severity, diag};

let d = diag!(Severity::Error, "type mismatch")
  .with_label(Label::primary(span, Some("expected i32, found String".into())))
  .with_help("convert with `as i32` or change the binding type");

d.print();      // pretty terminal output
let json = d.to_json();   // stable JSON shape (with `json` feature)

Module matrix

path role
src/diagnostic.rs Diagnostic, Label, Span, Severity, Suggestion, Applicability
src/formatter.rs terminal formatter with caret rendering, color, tab/Unicode-width handling
src/smart.rs multi-file smart printer
src/compact.rs source-less compact rendering + style helpers
src/json.rs stable JSON schema (feature json)
src/style.rs RenderOptions, color toggles, line width clamps
src/macros.rs diag! macro

Why a generic engine

Most Rust tools (compilers, linters, schema validators, SQL parsers) want the same diagnostic shape: severity + message + labels + spans + hints. duck-diag gives you that surface without pulling in miette, ariadne, or syn. Useful when you want a tiny dep that ships color + caret rendering without the rest of the world.

Build

cargo build --release
cargo test  --workspace

Used by

crate how
@gentleduck/md (dmc) every layer's diagnostic engine
your tool here open a PR against this README

Contributing

PR checklist + style notes in CONTRIBUTING.md. Security: SECURITY.md. Behaviour: CODE_OF_CONDUCT.md.

License

MIT. See LICENSE.