From d0d0f8492f3b476f5d59b3d60f819a221cfe39ff Mon Sep 17 00:00:00 2001 From: Brooks J Rady Date: Sat, 26 Apr 2025 19:09:57 +0100 Subject: [PATCH] docs(miette): sync README and `rustdoc` --- src/lib.rs | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 6396c9f..2e07663 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -51,6 +51,7 @@ //! - [... handler options](#-handler-options) //! - [... dynamic diagnostics](#-dynamic-diagnostics) //! - [... syntax highlighting](#-syntax-highlighting) +//! - [... primary label](#-primary-label) //! - [... collection of labels](#-collection-of-labels) //! - [Acknowledgements](#acknowledgements) //! - [License](#license) @@ -690,6 +691,37 @@ //! [`with_syntax_highlighting`](MietteHandlerOpts::with_syntax_highlighting) //! method. See the [`highlighters`] module docs for more details. //! +//! ### ... primary label +//! +//! You can use the `primary` parameter to `label` to indicate that the label +//! is the primary label. +//! +//! ```rust,ignore +//! #[derive(Debug, Diagnostic, Error)] +//! #[error("oops!")] +//! struct MyError { +//! #[label(primary, "main issue")] +//! primary_span: SourceSpan, +//! +//! #[label("other label")] +//! other_span: SourceSpan, +//! } +//! ``` +//! +//! The `primary` parameter can be used at most once: +//! +//! ```rust,ignore +//! #[derive(Debug, Diagnostic, Error)] +//! #[error("oops!")] +//! struct MyError { +//! #[label(primary, "main issue")] +//! primary_span: SourceSpan, +//! +//! #[label(primary, "other label")] // Error: Cannot have more than one primary label. +//! other_span: SourceSpan, +//! } +//! ``` +//! //! ### ... collection of labels //! //! When the number of labels is unknown, you can use a collection of `SourceSpan`