From 47e4d4d05c544b18c5ea76ae4de7c08f78234003 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kat=20March=C3=A1n?= Date: Sun, 26 Sep 2021 12:45:18 -0700 Subject: [PATCH] docs: add docs for handler options --- README.md | 21 +++++++++++++++++++++ src/handler.rs | 12 ++++++++++++ 2 files changed, 33 insertions(+) diff --git a/README.md b/README.md index 63bcb21..240086e 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,7 @@ and such might not want. - [... in `main()`](#-in-main) - [... diagnostic code URLs](#-diagnostic-code-urls) - [... snippets](#-snippets) + - [... handler options](#-handler-options) - [Acknowledgements](#acknowledgements) - [License](#license) @@ -353,6 +354,26 @@ pub struct MyErrorType { } ``` +### ... handler options + +[MietteHandler] is the default handler, and is very customizable. In most +cases, you can simply use [MietteHandlerOptions] to tweak its behavior instead +of falling back to your own custom handler. + +Usage is like so: + +```rust +miette::set_hook(|_| { + MietteHandlerOpts::new() + .terminal_links(true) + .unicode(false) + .context_lines(3) + .build() +}) +``` + +See the docs for [MietteHandlerOptions] for more details on what you can customize! + ## Acknowledgements `miette` was not developed in a void. It owes enormous credit to various other projects and their authors: diff --git a/src/handler.rs b/src/handler.rs index c11a2de..1e8818b 100644 --- a/src/handler.rs +++ b/src/handler.rs @@ -12,6 +12,18 @@ use crate::ThemeStyles; /** Create a custom [MietteHandler] from options. + +## Example + +```no_run +miette::set_hook(|_| { + MietteHandlerOpts::new() + .terminal_links(true) + .unicode(false) + .context_lines(3) + .build() +}) +``` */ #[derive(Default, Debug, Clone)] pub struct MietteHandlerOpts {