Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fix example, bench and leftover doc
  • Loading branch information
zzau13 committed Mar 25, 2020
commit bdf43be1ec4a5cfd9384698ebd6058a80d24a291
4 changes: 2 additions & 2 deletions benches/simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ fn create_snippet() {
SourceAnnotation {
label: "expected enum `std::option::Option`".to_string(),
annotation_type: AnnotationType::Error,
range: (23, 745),
range: (26, 724),
},
],
}],
Expand All @@ -59,7 +59,7 @@ fn create_snippet() {
footer: vec![],
opt: FormatOptions {
color: true,
anonymized_line_numbers: false,
..Default::default()
},
};

Expand Down
9 changes: 6 additions & 3 deletions examples/expected_type.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use annotate_snippets::{
display_list::DisplayList,
display_list::{DisplayList, FormatOptions},
snippet::{Annotation, AnnotationType, Slice, Snippet, SourceAnnotation},
};

Expand All @@ -24,7 +24,7 @@ fn main() {
SourceAnnotation {
label: "".to_string(),
annotation_type: AnnotationType::Error,
range: (208, 210),
range: (205, 207),
},
SourceAnnotation {
label: "while parsing this struct".to_string(),
Expand All @@ -33,7 +33,10 @@ fn main() {
},
],
}],
opt: Default::default(),
opt: FormatOptions {
color: true,
..Default::default()
},
};

let dl = DisplayList::from(snippet);
Expand Down
7 changes: 5 additions & 2 deletions examples/footer.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use annotate_snippets::{
display_list::DisplayList,
display_list::{DisplayList, FormatOptions},
snippet::{Annotation, AnnotationType, Slice, Snippet, SourceAnnotation},
};

Expand Down Expand Up @@ -30,7 +30,10 @@ fn main() {
annotation_type: AnnotationType::Error,
}],
}],
opt: Default::default(),
opt: FormatOptions {
color: true,
..Default::default()
},
};

let dl = DisplayList::from(snippet);
Expand Down
9 changes: 6 additions & 3 deletions examples/format.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use annotate_snippets::{
display_list::DisplayList,
display_list::{DisplayList, FormatOptions},
snippet::{Annotation, AnnotationType, Slice, Snippet, SourceAnnotation},
};

Expand Down Expand Up @@ -41,7 +41,7 @@ fn main() {
SourceAnnotation {
label: "expected enum `std::option::Option`".to_string(),
annotation_type: AnnotationType::Error,
range: (23, 745),
range: (26, 724),
},
],
}],
Expand All @@ -51,7 +51,10 @@ fn main() {
annotation_type: AnnotationType::Error,
}),
footer: vec![],
opt: Default::default(),
opt: FormatOptions {
color: true,
..Default::default()
},
};

let dl = DisplayList::from(snippet);
Expand Down
7 changes: 5 additions & 2 deletions examples/multislice.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use annotate_snippets::{
display_list::DisplayList,
display_list::{DisplayList, FormatOptions},
snippet::{Annotation, AnnotationType, Slice, Snippet},
};

Expand Down Expand Up @@ -27,7 +27,10 @@ fn main() {
annotations: vec![],
},
],
opt: Default::default(),
opt: FormatOptions {
color: true,
..Default::default()
},
};

let dl = DisplayList::from(snippet);
Expand Down
89 changes: 1 addition & 88 deletions src/display_list/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,97 +27,10 @@
//! are `Source` lines.
//!
//! `DisplayList` does not store column alignment information, and those are
//! only calculated by the `DisplayListFormatter` using information such as
//! only calculated by the implementation of `std::fmt::Display` using information such as
//! styling.
//!
//! The above snippet has been built out of the following structure:
//!
//! ```rust,ignore
//! use annotate_snippets::display_list::*;
//!
//! let dl = DisplayList {
//! body: vec![
//! DisplayLine::Raw(DisplayRawLine::Annotation {
//! annotation: Annotation {
//! annotation_type: DisplayAnnotationType::Error,
//! id: Some("E0308".to_string()),
//! label: vec![
//! DisplayTextFragment {
//! content: "mismatched types".to_string(),
//! style: DisplayTextStyle::Regular,
//! }
//! ]
//! },
//! source_aligned: false,
//! continuation: false,
//! }),
//! DisplayLine::Raw(DisplayRawLine::Origin {
//! path: "src/format.rs".to_string(),
//! pos: Some((51, 5)),
//! header_type: DisplayHeaderType::Initial,
//! }),
//! DisplayLine::Source {
//! lineno: Some(151),
//! inline_marks: vec![
//! DisplayMark {
//! mark_type: DisplayMarkType::AnnotationStart,
//! annotation_type: DisplayAnnotationType::Error,
//! }
//! ],
//! line: DisplaySourceLine::Content {
//! text: " fn test() -> String {".to_string(),
//! range: (0, 24)
//! }
//! },
//! DisplayLine::Source {
//! lineno: Some(152),
//! inline_marks: vec![
//! DisplayMark {
//! mark_type: DisplayMarkType::AnnotationThrough,
//! annotation_type: DisplayAnnotationType::Error,
//! }
//! ],
//! line: DisplaySourceLine::Content {
//! text: " return \"test\";".to_string(),
//! range: (25, 46)
//! }
//! },
//! DisplayLine::Source {
//! lineno: Some(153),
//! inline_marks: vec![
//! DisplayMark {
//! mark_type: DisplayMarkType::AnnotationThrough,
//! annotation_type: DisplayAnnotationType::Error,
//! }
//! ],
//! line: DisplaySourceLine::Content {
//! text: " }".to_string(),
//! range: (47, 51)
//! }
//! },
//! DisplayLine::Source {
//! lineno: None,
//! inline_marks: vec![],
//! line: DisplaySourceLine::Annotation {
//! annotation: Annotation {
//! annotation_type: DisplayAnnotationType::Error,
//! id: None,
//! label: vec![
//! DisplayTextFragment {
//! content: "expected `String`, for `&str`.".to_string(),
//! style: DisplayTextStyle::Regular,
//! }
//! ]
//! },
//! range: (3, 4),
//! annotation_type: DisplayAnnotationType::Error,
//! annotation_part: DisplayAnnotationPart::MultilineEnd,
//! }
//!
//! }
//! ]
//! };
//! ```
mod from_snippet;
mod structs;

Expand Down