|
27 | 27 | //! are `Source` lines.
|
28 | 28 | //!
|
29 | 29 | //! `DisplayList` does not store column alignment information, and those are
|
30 | | -//! only calculated by the `DisplayListFormatter` using information such as |
| 30 | +//! only calculated by the implementation of `std::fmt::Display` using information such as |
31 | 31 | //! styling.
|
32 | 32 | //!
|
33 | 33 | //! The above snippet has been built out of the following structure:
|
34 | | -//! |
35 | | -//! ```rust,ignore |
36 | | -//! use annotate_snippets::display_list::*; |
37 | | -//! |
38 | | -//! let dl = DisplayList { |
39 | | -//! body: vec![ |
40 | | -//! DisplayLine::Raw(DisplayRawLine::Annotation { |
41 | | -//! annotation: Annotation { |
42 | | -//! annotation_type: DisplayAnnotationType::Error, |
43 | | -//! id: Some("E0308".to_string()), |
44 | | -//! label: vec![ |
45 | | -//! DisplayTextFragment { |
46 | | -//! content: "mismatched types".to_string(), |
47 | | -//! style: DisplayTextStyle::Regular, |
48 | | -//! } |
49 | | -//! ] |
50 | | -//! }, |
51 | | -//! source_aligned: false, |
52 | | -//! continuation: false, |
53 | | -//! }), |
54 | | -//! DisplayLine::Raw(DisplayRawLine::Origin { |
55 | | -//! path: "src/format.rs".to_string(), |
56 | | -//! pos: Some((51, 5)), |
57 | | -//! header_type: DisplayHeaderType::Initial, |
58 | | -//! }), |
59 | | -//! DisplayLine::Source { |
60 | | -//! lineno: Some(151), |
61 | | -//! inline_marks: vec![ |
62 | | -//! DisplayMark { |
63 | | -//! mark_type: DisplayMarkType::AnnotationStart, |
64 | | -//! annotation_type: DisplayAnnotationType::Error, |
65 | | -//! } |
66 | | -//! ], |
67 | | -//! line: DisplaySourceLine::Content { |
68 | | -//! text: " fn test() -> String {".to_string(), |
69 | | -//! range: (0, 24) |
70 | | -//! } |
71 | | -//! }, |
72 | | -//! DisplayLine::Source { |
73 | | -//! lineno: Some(152), |
74 | | -//! inline_marks: vec![ |
75 | | -//! DisplayMark { |
76 | | -//! mark_type: DisplayMarkType::AnnotationThrough, |
77 | | -//! annotation_type: DisplayAnnotationType::Error, |
78 | | -//! } |
79 | | -//! ], |
80 | | -//! line: DisplaySourceLine::Content { |
81 | | -//! text: " return \"test\";".to_string(), |
82 | | -//! range: (25, 46) |
83 | | -//! } |
84 | | -//! }, |
85 | | -//! DisplayLine::Source { |
86 | | -//! lineno: Some(153), |
87 | | -//! inline_marks: vec![ |
88 | | -//! DisplayMark { |
89 | | -//! mark_type: DisplayMarkType::AnnotationThrough, |
90 | | -//! annotation_type: DisplayAnnotationType::Error, |
91 | | -//! } |
92 | | -//! ], |
93 | | -//! line: DisplaySourceLine::Content { |
94 | | -//! text: " }".to_string(), |
95 | | -//! range: (47, 51) |
96 | | -//! } |
97 | | -//! }, |
98 | | -//! DisplayLine::Source { |
99 | | -//! lineno: None, |
100 | | -//! inline_marks: vec![], |
101 | | -//! line: DisplaySourceLine::Annotation { |
102 | | -//! annotation: Annotation { |
103 | | -//! annotation_type: DisplayAnnotationType::Error, |
104 | | -//! id: None, |
105 | | -//! label: vec![ |
106 | | -//! DisplayTextFragment { |
107 | | -//! content: "expected `String`, for `&str`.".to_string(), |
108 | | -//! style: DisplayTextStyle::Regular, |
109 | | -//! } |
110 | | -//! ] |
111 | | -//! }, |
112 | | -//! range: (3, 4), |
113 | | -//! annotation_type: DisplayAnnotationType::Error, |
114 | | -//! annotation_part: DisplayAnnotationPart::MultilineEnd, |
115 | | -//! } |
116 | | -//! |
117 | | -//! } |
118 | | -//! ] |
119 | | -//! }; |
120 | | -//! ``` |
121 | 34 | mod from_snippet;
|
122 | 35 | mod structs;
|
123 | 36 |
|
|
0 commit comments