Docs.rs
  • annotate-snippets-0.10.2
    • annotate-snippets 0.10.2
    • Docs.rs crate page
    • Apache-2.0/MIT
    • Links
    • Repository
    • crates.io
    • Source
    • Owners
    • zbraniecki
    • Muscraft
    • Dependencies
      • anstyle ^1.0.4 normal
      • unicode-width ^0.1.11 normal
      • criterion ^0.5.1 dev
      • difference ^2.0.0 dev
      • glob ^0.3.1 dev
      • serde ^1.0.196 dev
      • toml ^0.5.11 dev
    • Versions
    • 100% of the crate is documented
  • Go to latest version
  • Platform
    • i686-pc-windows-msvc
    • i686-unknown-linux-gnu
    • x86_64-apple-darwin
    • x86_64-pc-windows-msvc
    • x86_64-unknown-linux-gnu
  • Feature flags
  • docs.rs
    • About docs.rs
    • Privacy policy
  • Rust
    • Rust website
    • The Book
    • Standard Library API Reference
    • Rust by Example
    • The Cargo Guide
    • Clippy Documentation

Crate annotate_snippets

annotate_snippets0.10.2

  • All Items
  • Modules
  • Structs
  • Enums

Crates

  • annotate_snippets
?
Change settings

Crate annotate_snippets

source ·
Expand description

A library for formatting of text or programming code snippets.

It’s primary purpose is to build an ASCII-graphical representation of the snippet with annotations.

§Example

error[E0308]: mismatched types
  --> src/format.rs:52:1
   |
51 |   ) -> Option<String> {
   |        -------------- expected `Option<String>` because of return type
52 | /     for ann in annotations {
53 | |         match (ann.range.0, ann.range.1) {
54 | |             (None, None) => continue,
55 | |             (Some(start), Some(end)) if start > end_index => continue,
...  |
71 | |         }
72 | |     }
   | |_____^ expected enum `std::option::Option`, found ()

The crate uses a three stage process with two conversions between states:

Snippet --> Renderer --> impl Display

The input type - Snippet is a structure designed to align with likely output from any parser whose code snippet is to be annotated.

The middle structure - Renderer is a structure designed to convert a snippet into an internal structure that is designed to store the snippet data in a way that is easy to format. Renderer also handles the user-configurable formatting options, such as color, or margins.

Finally, impl Display into a final String output.

§features

  • testing-colors - Makes Renderer::styled colors OS independent, which allows for easier testing when testing colored output. It should be added as a feature in [dev-dependencies], which can be done with the following command:
cargo add annotate-snippets --dev --feature testing-colors

Modules§

  • renderer
    The renderer for Snippets

Structs§

  • Annotation
    An annotation for a Snippet.
  • Renderer
    A renderer for Snippets
  • Slice
    Structure containing the slice of text to be annotated and basic information about the location of the slice.
  • Snippet
    Primary structure provided for formatting
  • SourceAnnotation
    An annotation for a Slice.

Enums§

  • AnnotationType
    Types of annotations.

Results

Query parser error: "Unexpected - (did you mean ->?)".