Skip to content

Commit a1007dd

Browse files
committed
fix!: Move around items in the public api
BREAKING CHANGE: This moves `snippet::*` and `Renderer` to root
1 parent b0848f7 commit a1007dd

File tree

11 files changed

+38
-43
lines changed

11 files changed

+38
-43
lines changed

Diff for: benches/simple.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ extern crate criterion;
44

55
use criterion::{black_box, Criterion};
66

7-
use annotate_snippets::renderer::Renderer;
8-
use annotate_snippets::snippet::{Annotation, AnnotationType, Slice, Snippet, SourceAnnotation};
7+
use annotate_snippets::{Annotation, AnnotationType, Renderer, Slice, Snippet, SourceAnnotation};
98

109
fn create_snippet(renderer: Renderer) {
1110
let snippet = Snippet {

Diff for: examples/expected_type.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
use annotate_snippets::renderer::Renderer;
2-
use annotate_snippets::snippet::{Annotation, AnnotationType, Slice, Snippet, SourceAnnotation};
1+
use annotate_snippets::{Annotation, AnnotationType, Renderer, Slice, Snippet, SourceAnnotation};
32

43
fn main() {
54
let snippet = Snippet {

Diff for: examples/footer.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
use annotate_snippets::renderer::Renderer;
2-
use annotate_snippets::snippet::{Annotation, AnnotationType, Slice, Snippet, SourceAnnotation};
1+
use annotate_snippets::{Annotation, AnnotationType, Renderer, Slice, Snippet, SourceAnnotation};
32

43
fn main() {
54
let snippet = Snippet {

Diff for: examples/format.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
use annotate_snippets::renderer::Renderer;
2-
use annotate_snippets::snippet::{Annotation, AnnotationType, Slice, Snippet, SourceAnnotation};
1+
use annotate_snippets::{Annotation, AnnotationType, Renderer, Slice, Snippet, SourceAnnotation};
32

43
fn main() {
54
let snippet = Snippet {

Diff for: examples/multislice.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
use annotate_snippets::renderer::Renderer;
2-
use annotate_snippets::snippet::{Annotation, AnnotationType, Slice, Snippet};
1+
use annotate_snippets::{Annotation, AnnotationType, Renderer, Slice, Snippet};
32

43
fn main() {
54
let snippet = Snippet {

Diff for: src/lib.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,22 @@
2929
//! Snippet --> Renderer --> impl Display
3030
//! ```
3131
//!
32-
//! The input type - [Snippet](self::snippet) is a structure designed
32+
//! The input type - [Snippet] is a structure designed
3333
//! to align with likely output from any parser whose code snippet is to be
3434
//! annotated.
3535
//!
36-
//! The middle structure - [Renderer](self::renderer) is a structure designed
36+
//! The middle structure - [Renderer] is a structure designed
3737
//! to convert a snippet into an internal structure that is designed to store
3838
//! the snippet data in a way that is easy to format.
39-
//! [Renderer](self::renderer) also handles the user-configurable formatting
39+
//! [Renderer] also handles the user-configurable formatting
4040
//! options, such as color, or margins.
4141
//!
4242
//! Finally, `impl Display` into a final `String` output.
4343
4444
mod display_list;
4545
pub mod renderer;
46-
pub mod snippet;
46+
mod snippet;
47+
48+
#[doc(inline)]
49+
pub use renderer::Renderer;
50+
pub use snippet::*;

Diff for: src/renderer/mod.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
//!
33
//! # Example
44
//! ```
5-
//! use annotate_snippets::renderer::Renderer;
6-
//! use annotate_snippets::snippet::{Annotation, AnnotationType, Slice, Snippet};
5+
//! use annotate_snippets::{Annotation, AnnotationType, Renderer, Slice, Snippet};
76
//! let snippet = Snippet {
87
//! title: Some(Annotation {
98
//! label: Some("mismatched types"),

Diff for: src/snippet.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
//! Example:
44
//!
55
//! ```
6-
//! use annotate_snippets::snippet::*;
6+
//! use annotate_snippets::*;
77
//!
88
//! Snippet {
99
//! title: Some(Annotation {

Diff for: tests/deserialize/mod.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
use serde::{Deserialize, Deserializer, Serialize};
22

3-
use annotate_snippets::renderer::Renderer;
43
use annotate_snippets::{
5-
renderer::Margin,
6-
snippet::{Annotation, AnnotationType, Slice, Snippet, SourceAnnotation},
4+
renderer::Margin, Annotation, AnnotationType, Renderer, Slice, Snippet, SourceAnnotation,
75
};
86

97
#[derive(Deserialize)]

Diff for: tests/fixtures_test.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ mod deserialize;
22
mod diff;
33

44
use crate::deserialize::Fixture;
5-
use annotate_snippets::renderer::Renderer;
6-
use annotate_snippets::snippet::Snippet;
5+
use annotate_snippets::Renderer;
6+
use annotate_snippets::Snippet;
77
use glob::glob;
88
use std::{error::Error, fs::File, io, io::prelude::*};
99

Diff for: tests/formatter.rs

+20-21
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
1-
use annotate_snippets::renderer::Renderer;
2-
use annotate_snippets::snippet::{self, Snippet};
1+
use annotate_snippets::{Annotation, AnnotationType, Renderer, Slice, Snippet, SourceAnnotation};
32

43
#[test]
54
fn test_i_29() {
65
let snippets = Snippet {
7-
title: Some(snippet::Annotation {
6+
title: Some(Annotation {
87
id: None,
98
label: Some("oops"),
10-
annotation_type: snippet::AnnotationType::Error,
9+
annotation_type: AnnotationType::Error,
1110
}),
1211
footer: vec![],
13-
slices: vec![snippet::Slice {
12+
slices: vec![Slice {
1413
source: "First line\r\nSecond oops line",
1514
line_start: 1,
1615
origin: Some("<current file>"),
17-
annotations: vec![snippet::SourceAnnotation {
16+
annotations: vec![SourceAnnotation {
1817
range: (19, 23),
1918
label: "oops",
20-
annotation_type: snippet::AnnotationType::Error,
19+
annotation_type: AnnotationType::Error,
2120
}],
2221
fold: true,
2322
}],
@@ -37,14 +36,14 @@ fn test_i_29() {
3736
#[test]
3837
fn test_point_to_double_width_characters() {
3938
let snippets = Snippet {
40-
slices: vec![snippet::Slice {
39+
slices: vec![Slice {
4140
source: "こんにちは、世界",
4241
line_start: 1,
4342
origin: Some("<current file>"),
44-
annotations: vec![snippet::SourceAnnotation {
43+
annotations: vec![SourceAnnotation {
4544
range: (6, 8),
4645
label: "world",
47-
annotation_type: snippet::AnnotationType::Error,
46+
annotation_type: AnnotationType::Error,
4847
}],
4948
fold: false,
5049
}],
@@ -65,14 +64,14 @@ fn test_point_to_double_width_characters() {
6564
#[test]
6665
fn test_point_to_double_width_characters_across_lines() {
6766
let snippets = Snippet {
68-
slices: vec![snippet::Slice {
67+
slices: vec![Slice {
6968
source: "おはよう\nございます",
7069
line_start: 1,
7170
origin: Some("<current file>"),
72-
annotations: vec![snippet::SourceAnnotation {
71+
annotations: vec![SourceAnnotation {
7372
range: (2, 8),
7473
label: "Good morning",
75-
annotation_type: snippet::AnnotationType::Error,
74+
annotation_type: AnnotationType::Error,
7675
}],
7776
fold: false,
7877
}],
@@ -95,20 +94,20 @@ fn test_point_to_double_width_characters_across_lines() {
9594
#[test]
9695
fn test_point_to_double_width_characters_multiple() {
9796
let snippets = Snippet {
98-
slices: vec![snippet::Slice {
97+
slices: vec![Slice {
9998
source: "お寿司\n食べたい🍣",
10099
line_start: 1,
101100
origin: Some("<current file>"),
102101
annotations: vec![
103-
snippet::SourceAnnotation {
102+
SourceAnnotation {
104103
range: (0, 3),
105104
label: "Sushi1",
106-
annotation_type: snippet::AnnotationType::Error,
105+
annotation_type: AnnotationType::Error,
107106
},
108-
snippet::SourceAnnotation {
107+
SourceAnnotation {
109108
range: (6, 8),
110109
label: "Sushi2",
111-
annotation_type: snippet::AnnotationType::Note,
110+
annotation_type: AnnotationType::Note,
112111
},
113112
],
114113
fold: false,
@@ -132,14 +131,14 @@ fn test_point_to_double_width_characters_multiple() {
132131
#[test]
133132
fn test_point_to_double_width_characters_mixed() {
134133
let snippets = Snippet {
135-
slices: vec![snippet::Slice {
134+
slices: vec![Slice {
136135
source: "こんにちは、新しいWorld!",
137136
line_start: 1,
138137
origin: Some("<current file>"),
139-
annotations: vec![snippet::SourceAnnotation {
138+
annotations: vec![SourceAnnotation {
140139
range: (6, 14),
141140
label: "New world",
142-
annotation_type: snippet::AnnotationType::Error,
141+
annotation_type: AnnotationType::Error,
143142
}],
144143
fold: false,
145144
}],

0 commit comments

Comments
 (0)