Skip to content

Commit c736e03

Browse files
committed
docs(tryfn): Improve documentation
1 parent 8e26ddb commit c736e03

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

crates/tryfn/src/lib.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,17 @@
66
//! # Examples
77
//!
88
//! ```rust,no_run
9+
//! fn some_func(num: usize) -> usize {
10+
//! // ...
11+
//! # 10
12+
//! }
13+
//!
914
//! tryfn::Harness::new(
1015
//! "tests/fixtures/invalid",
1116
//! setup,
1217
//! test,
1318
//! )
1419
//! .select(["tests/cases/*.in"])
15-
//! .action_env("SNAPSHOTS")
1620
//! .test();
1721
//!
1822
//! fn setup(input_path: std::path::PathBuf) -> tryfn::Case {
@@ -29,7 +33,7 @@
2933
//! let raw = std::fs::read_to_string(input_path)?;
3034
//! let num = raw.parse::<usize>()?;
3135
//!
32-
//! let actual = num + 10;
36+
//! let actual = some_func(num);
3337
//!
3438
//! Ok(actual)
3539
//! }
@@ -38,6 +42,7 @@
3842
use libtest_mimic::Trial;
3943

4044
pub use snapbox::assert::Action;
45+
pub use snapbox::data::DataFormat;
4146
pub use snapbox::Data;
4247

4348
/// [`Harness`] for discovering test inputs and asserting against snapshot files
@@ -87,7 +92,7 @@ where
8792

8893
/// Path patterns for selecting input files
8994
///
90-
/// This used gitignore syntax
95+
/// This uses gitignore syntax
9196
pub fn select<'p>(mut self, patterns: impl IntoIterator<Item = &'p str>) -> Self {
9297
let mut overrides = ignore::overrides::OverrideBuilder::new(&self.root);
9398
for line in patterns {
@@ -160,6 +165,7 @@ where
160165
}
161166
}
162167

168+
/// Function signature for generating a test [`Case`] from a path fixture
163169
pub trait Setup {
164170
fn setup(&self, fixture: std::path::PathBuf) -> Case;
165171
}
@@ -173,6 +179,7 @@ where
173179
}
174180
}
175181

182+
/// Function signature for running a test [`Case`]
176183
pub trait Test<S, E>
177184
where
178185
S: std::fmt::Display,
@@ -192,7 +199,7 @@ where
192199
}
193200
}
194201

195-
/// A test case enumerated by the [`Harness`] with data from the `setup` function
202+
/// A test case enumerated by the [`Harness`] with data from the [`Setup`] function
196203
pub struct Case {
197204
/// Display name
198205
pub name: String,

0 commit comments

Comments
 (0)