- Notifications
You must be signed in to change notification settings - Fork47
Library for snippet annotations
License
Apache-2.0, MIT licenses found
Licenses found
Apache-2.0
LICENSE-APACHEMIT
LICENSE-MITNotificationsYou must be signed in to change notification settings
rust-lang/annotate-snippets-rs
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
annotate-snippets is a Rust library for annotation of programming code slices.
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 ()use annotate_snippets::{ display_list::{DisplayList,FormatOptions}, snippet::{Annotation,AnnotationType,Slice,Snippet,SourceAnnotation},};fnmain(){let snippet =Snippet{title:Some(Annotation{label:Some("expected type, found `22`"),id:None,annotation_type:AnnotationType::Error,}),footer:vec![],slices:vec![Slice{ source:r#" annotations: vec![SourceAnnotation { label: "expected struct `annotate_snippets::snippet::Slice`, found reference" , range: <22, 25>,"#, line_start:26, origin:Some("examples/footer.rs"), fold:true, annotations: vec![SourceAnnotation{ label:"", annotation_type:AnnotationType::Error, range:(187,189),},SourceAnnotation{ label:"while parsing this struct", annotation_type:AnnotationType::Info, range:(34,50),},],}],opt:FormatOptions{color:true, ..Default::default()},};let dl =DisplayList::from(snippet);println!("{}", dl);}
cargo buildcargo testWhen 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-APACHEMIT
LICENSE-MITSecurity policy
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
No packages published