diff --git a/crates/lib/README.md b/crates/lib/README.md index eded49a..8c7acf7 100644 --- a/crates/lib/README.md +++ b/crates/lib/README.md @@ -19,13 +19,13 @@ _The library which powers [Watchexec CLI](https://watchexec.github.io) and other ## Quick start -```rust +```rust ,no_run use miette::{IntoDiagnostic, Result}; use watchexec::{ Watchexec, action::{Action, Outcome}, config::{InitConfig, RuntimeConfig}, - handler::PrintDebug, + handler::{Handler as _, PrintDebug}, }; #[tokio::main] @@ -64,13 +64,20 @@ async fn main() -> Result<()> { Outcome::both(Outcome::Clear, Outcome::Start), )); - Ok::<(), std::io::Error>(()) + Ok(()) + + // (not normally required! ignore this when implementing) + as std::result::Result<_, MietteStub> } }); - let _ = we.main().await.into_diagnostic()?; + we.reconfigure(runtime); + we.main().await.into_diagnostic()?; Ok(()) } + +// ignore this! it's stuff to make the above code get checked by cargo doc tests! +struct YourConfigFormat; impl YourConfigFormat { async fn load_from_file(_: &str) -> std::result::Result { Ok(Self) } fn apply(&self, _: &mut RuntimeConfig) {} } use miette::Diagnostic; use thiserror::Error; #[derive(Debug, Error, Diagnostic)] #[error("stub")] struct MietteStub; ``` diff --git a/crates/lib/src/lib.rs b/crates/lib/src/lib.rs index 8595860..d5edda1 100644 --- a/crates/lib/src/lib.rs +++ b/crates/lib/src/lib.rs @@ -116,3 +116,9 @@ mod watchexec; #[doc(inline)] pub use crate::watchexec::{ErrorHook, Watchexec}; + +#[doc(hidden)] +pub mod readme_doc_check { + #[doc = include_str!("../README.md")] + pub struct Readme; +}