mirror of https://github.com/zkat/miette.git
Add docs
This commit is contained in:
parent
52e2dcbced
commit
7c4dd12d8d
23
src/lib.rs
23
src/lib.rs
|
|
@ -46,6 +46,7 @@
|
||||||
//! - [... multiple related errors](#-multiple-related-errors)
|
//! - [... multiple related errors](#-multiple-related-errors)
|
||||||
//! - [... delayed source code](#-delayed-source-code)
|
//! - [... delayed source code](#-delayed-source-code)
|
||||||
//! - [... handler options](#-handler-options)
|
//! - [... handler options](#-handler-options)
|
||||||
|
//! - [... dynamic diagnostics](#-dynamic-diagnostics)
|
||||||
//! - [Acknowledgements](#acknowledgements)
|
//! - [Acknowledgements](#acknowledgements)
|
||||||
//! - [License](#license)
|
//! - [License](#license)
|
||||||
//!
|
//!
|
||||||
|
|
@ -590,6 +591,28 @@
|
||||||
//! See the docs for [`MietteHandlerOpts`] for more details on what you can
|
//! See the docs for [`MietteHandlerOpts`] for more details on what you can
|
||||||
//! customize!
|
//! customize!
|
||||||
//!
|
//!
|
||||||
|
//! ### ... dynamic diagnostics
|
||||||
|
//!
|
||||||
|
//! If you...
|
||||||
|
//! - ...don't know all the possible errors upfront
|
||||||
|
//! - ...need to serialize/deserialize errors
|
||||||
|
//! then you may want to use [`miette!`], [`miette_diagnostic!`] macros or
|
||||||
|
//! [`MietteDiagnostic`] directly to create diagnostic on the fly.
|
||||||
|
//!
|
||||||
|
//! ```rs
|
||||||
|
//! # use miette::{miette, LabeledSpan, Report};
|
||||||
|
//!
|
||||||
|
//! let source = "2 + 2 * 2 = 8".to_string();
|
||||||
|
//! let report = miette!(
|
||||||
|
//! "Wrong answer",
|
||||||
|
//! labels = vec[
|
||||||
|
//! LabeledSpan::at(12..13, "this should be 6"),
|
||||||
|
//! ],
|
||||||
|
//! help = "'*' has greater precedence than '+'"
|
||||||
|
//! ).with_source_code(source);
|
||||||
|
//! println!("{:?}", report)
|
||||||
|
//! ```
|
||||||
|
//!
|
||||||
//! ## Acknowledgements
|
//! ## Acknowledgements
|
||||||
//!
|
//!
|
||||||
//! `miette` was not developed in a void. It owes enormous credit to various
|
//! `miette` was not developed in a void. It owes enormous credit to various
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue