Fix watchexec example in docs found in #295 (#297)

This commit is contained in:
Félix Saparelli 2022-06-07 09:19:16 +00:00
parent f3e0f0cbda
commit ec26a99b7d
4 changed files with 20 additions and 4 deletions

View File

@ -125,7 +125,9 @@ pub enum RuntimeError {
#[diagnostic(code(watchexec::runtime::clearscreen))]
Clearscreen(#[from] clearscreen::Error),
/// Error received when parsing a glob (possibly from an [`IgnoreFile`](crate::ignore::files::IgnoreFile)) fails.
/// Error received when parsing a glob (possibly from an [`IgnoreFile`]) fails.
///
/// [`IgnoreFile`]: crate::ignore::IgnoreFile
#[error("cannot parse glob from ignore '{file:?}': {err}")]
#[diagnostic(code(watchexec::runtime::ignore_glob))]
GlobsetGlob {
@ -138,7 +140,9 @@ pub enum RuntimeError {
// TODO: extract glob error into diagnostic
},
/// Error received when an [`IgnoreFile`](crate::ignore::files::IgnoreFile) cannot be read.
/// Error received when an [`IgnoreFile`] cannot be read.
///
/// [`IgnoreFile`]: crate::ignore::IgnoreFile
#[error("cannot read ignore '{file}': {err}")]
#[diagnostic(code(watchexec::runtime::ignore_file_read))]
IgnoreFileRead {
@ -153,7 +157,7 @@ pub enum RuntimeError {
/// Error emitted by a [`Filterer`](crate::filter::Filterer).
///
/// With built-in filterers this will probably be a dynbox of
/// [`TaggedFiltererError`](crate::filter::tagged::error::TaggedFiltererError), but it is
/// [`TaggedFiltererError`](crate::error::TaggedFiltererError), but it is
/// possible to use a custom filterer which emits a different error type.
#[error("{kind} filterer: {err}")]
#[diagnostic(code(watchexec::runtime::filterer))]

View File

@ -20,7 +20,7 @@ use super::files::IgnoreFile;
///
/// This reads and compiles ignore files, and should be used for handling ignore files. It's created
/// with a project origin and a list of ignore files, and new ignore files can be added later
/// (unless [`finish`](Filter::finish()) is called).
/// (unless [`finish`](IgnoreFilterer::finish()) is called).
///
/// It implements [`Filterer`] so it can be used directly in another filterer; it is not designed to
/// be used as a standalone filterer.

View File

@ -63,6 +63,7 @@
//! }
//! });
//!
//! we.reconfigure(runtime);
//! we.main().await.into_diagnostic()?;
//! Ok(())
//! }

View File

@ -54,6 +54,17 @@ impl Watchexec {
///
/// Returns an [`Arc`] for convenience; use [`try_unwrap`][Arc::try_unwrap()] to get the value
/// directly if needed.
///
/// Note that `RuntimeConfig` is not a "live" or "shared" instance: if using reconfiguration,
/// you'll usually pass a `clone()` of your `RuntimeConfig` instance to this function; changes
/// made to the instance you _keep_ will not automatically be used by Watchexec, you need to
/// call [`reconfigure()`](Watchexec::reconfigure) with your updated config to apply the changes.
///
/// Watchexec will subscribe to most signals sent to the process it runs in and send them, as
/// [`Event`]s, to the action handler. At minimum, you should check for interrupt/ctrl-c events
/// and return an [`Outcome::Exit`], otherwise hitting ctrl-c will do nothing.
///
/// [`Outcome::Exit`]: crate::action::Outcome::Exit
pub fn new(
mut init: InitConfig,
mut runtime: RuntimeConfig,