Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Library for snippet annotations

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
NotificationsYou must be signed in to change notification settings

rust-lang/annotate-snippets-rs

Repository files navigation

annotate-snippets is a Rust library for annotation of programming code slices.

crates.ioBuild StatusCoverage Status

The library helps visualize meta information annotating source code slices.It takes a data structure calledSnippet on the input and produces aStringwhich may look like this:

error[E0308]: mismatched types  --> src/format.rs:52:1   |51 |   ) -> Option<String> {   |        -------------- expected `Option<String>` because of return type52 | /     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 ()

Documentation

Usage

use annotate_snippets::{    display_list::DisplayList,    formatter::DisplayListFormatter,    snippet::{Annotation,AnnotationType,Slice,Snippet,SourceAnnotation},};fnmain(){let snippet =Snippet{title:Some(Annotation{label:Some("expected type, found `22`".to_string()),id:None,annotation_type:AnnotationType::Error,}),footer:vec![],slices:vec![Slice{                source:r#"This is an examplecontent of the slicewhich will be annotatedwith the list of annotations below.                "#.to_string(),                line_start:26,                origin:Some("examples/example.txt".to_string()),                fold:false,                annotations: vec![SourceAnnotation{                        label:"Example error annotation".to_string(),                        annotation_type:AnnotationType::Error,                        range:(13,18),},SourceAnnotation{                        label:"and here's a warning".to_string(),                        annotation_type:AnnotationType::Warning,                        range:(34,50),},],},],};let dl =DisplayList::from(snippet);let dlf =DisplayListFormatter::new(true,false);println!("{}", dlf.format(&dl));}

Local Development

cargo buildcargo test

When submitting a PR please usecargo fmt (nightly).

About

Library for snippet annotations

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp