Crate ariadne[][src]

Expand description

A fancy compiler diagnostics crate.

Example

Multi-line spans

Features

  • Inline and multi-line labels capable of handling arbitrary configurations of spans
  • Multi-file errors
  • Generic across custom spans and file caches
  • A choice of character sets to ensure compatibility
  • Coloured labels & highlighting with 256-color support (thanks to yansi)
  • Label priority and ordering
  • Compact mode for smaller diagnostics
  • Correct handling of variable-width characters such as tabs
  • A plethora of other options (tab width, label attach points, underlines, etc.)
use ariadne::{Report, ReportKind, Label, Source};

Report::build(ReportKind::Error, (), 34)
    .with_message("Incompatible types")
    .with_label(Label::new(32..33).with_message("This is of type Nat"))
    .with_label(Label::new(42..45).with_message("This is of type Str"))
    .finish()
    .print(Source::from(include_str!("../examples/sample.tao")))
    .unwrap();

Structs

A type that can generate distinct 8-bit colors.

A type used to configure a report

A Cache that fetches Sources from the filesystem.

A Cache that fetches Sources using the provided function.

A type that represents a labelled section of source code.

A type representing a single line of a Source.

A type representing a diagnostic that is ready to be written to output.

A type used to build a Report.

A type representing a single source that may be referred to by Spans.

Enums

Possible character sets to use when rendering diagnostics.

An enum representing an ANSI color code.

The attachment point of inline label arrows

A type that defines the kind of report being produced.

Traits

A trait implemented by Source caches.

A trait used to add formatting attributes to displayable items.

A trait implemented by spans within a character-based source.

Functions

Create a Cache from a collection of ID/strings, where each corresponds to a Source.