Commit Graph

87 Commits

Author SHA1 Message Date
Benjamin Lee 1816b06a2e
feat(theme): restructure automatic color selection (#177)
Fixes: https://github.com/zkat/miette/issues/176

Change the default ansi color theme to use colors that are more similar
to the colors from the default RGB theme. In particular, don't use red
for any of the span labels, since that color is also used for errors.

BREAKING CHANGES:
* the default theme now prefers ANSI colors, even if RGB is supported
* `MietteHandlerOpts::ansi_colors` is removed
* `MietteHandlerOpts::rgb_color` now takes an enum that controls the
  color format used when color support is enabled, and has no effect
  otherwise.
2022-06-24 08:30:36 -07:00
Marcel Müller f783a0e2ae
Allow using smartpointers with source_diagnostic (#169)
* Add more tests for diagnostic_source

* Use Borrow::borrow instead of AsRef

AsRef is not reflexive, meaning that it is not implemented as &T for all
T. Borrow is though, so we use that to make sure that we always get a
reference that is correct, even in the presence of smart pointers.
2022-05-13 08:19:05 -07:00
Matthias Beyer bc449c8426
feat(diagnostic_source): add protocol method for Diagnostic-aware source chaining (#165)
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2022-05-05 08:32:37 -07:00
Kat Marchán 1a36fa7ec8
fix(graphical): fix issue with duplicate labels when span len is 0 (#159)
Fixes: https://github.com/zkat/miette/issues/130
2022-04-22 19:31:51 -07:00
Kat Marchán 9da62cd05d feat(label): use macro magic instead of optional flag for optional labels 2022-04-17 22:43:01 -07:00
Kat Marchán ea55f458fa feat(help): allow non-option values in #[help] fields 2022-04-17 22:43:01 -07:00
Kat Marchán 23ee3642d1
feat(labels): allow optional labels in derive macro (#153)
Fixes: https://github.com/zkat/miette/issues/110
2022-04-17 19:41:10 -07:00
Kat Marchán 45093c2f58
feat(help): update macro to allow optional help text (#152)
Fixes: https://github.com/zkat/miette/issues/148
2022-04-17 18:19:28 -07:00
Kat Marchán b98b098282
fix(clippy): misc clippy fixes 2022-04-03 18:33:51 -07:00
Finomnis b4a9d4cd9b
feat(report): Add conversion from Report to Box<dyn Error> (#149) 2022-04-03 13:10:32 -07:00
Bartek Iwańczuk 5151411ebb
feat: add fancy-no-backtrace feature (#144) 2022-03-22 12:30:52 -07:00
Moritz Mœller 5d23c0d61d
fix(docs): Docs overhaul (#124)
* Fixed/formatted all intradoc links. Various other small doc fixes/typography/etc.

* Clarified semantic similarity with anyhow/eyre types/macros.

* Removed unused MietteError::SetPrinterFailure.

* README now generaed from lib.rs via `cargo readme`.

* More doc fixes, made ErrorHook type public.

* Indentation (docs).
2022-02-25 08:39:18 -08:00
Paul Colomiets 50bcec909a
fix(handlers): source code propagation for JSON handler (#122)
A part of fix of #99, follow up of #117
2022-02-22 16:06:29 -08:00
Paul Colomiets 75d4505e7d
feat(derive): allow `Report` in `related` (#121)
Fixes: #119
2022-02-21 19:12:37 -08:00
Paul Colomiets 3a17fceabb feat(handlers): propagate source code to related errors
Fixes #99
2022-02-19 16:58:48 -08:00
Paul Colomiets 50519264d4 feat(report): add `with_source_code`
Fixes #64
2022-02-19 16:58:48 -08:00
Kyle Brown 5b8b5478b6
feat(derive): Make derive macro `diagnostic` attribute more flexible. (#115)
Fixes: #114 

* Improved defaulting

* Added correct combining logic
Added variable number of diagnostic attributes

* Error handling, testing, and docs improvements

Co-authored-by: Kyle Brown <kyleb@liquidrocketry.com>
2022-02-17 22:04:03 -08:00
Paul Colomiets 2649fd27c4
feat(Report): adds `.context()` method to the `Report` (#109)
Techically there was a hidden undocumented `context` method. But it was
just copied from the `eyre` and there is no evidence that it was used by
any user in miette (the method was an alias for `.handler()`).

Fixes #108
2022-01-17 17:16:08 -08:00
Paul Colomiets f158f4e370
fix(handlers): Fix label position (#107)
Fixes #106

While fixing the bug I've also extended the handler to print not just
where label starts but also where label ends.

Also implements #97, but for narratabble handler only.

This adds dependency on `unicode-width`, but it was already in the
dependency chain (`textwidth` depends on it). Although, previously it
was only for `"fancy"` feature, now it always required since narratable
handler is supported without `"fancy"`.
2022-01-17 11:07:29 -08:00
Paul Colomiets 645ef6a1b6
fix(json): proper escapes for JSON strings (#101)
Includes two fixes:
1. Things like `\n` are not doubly-escaped any more
2. The backslash `\` itself in the source is escaped
2022-01-07 17:35:24 -08:00
Paul Colomiets 52e5ec8064
fix(chain): correct `Chain` structure exported (#102)
This fixes all current complier and clippy warnings.
2022-01-07 17:34:39 -08:00
dvermd 53b246829a
feat(handlers): Add JSON handler (#90) 2021-11-15 08:49:22 -08:00
Kirill Vasiltsov 1f70140c2e
feat(tabs): Add replace tabs with spaces option (#82)
Fixes: https://github.com/zkat/miette/issues/73
2021-10-05 21:05:57 -07:00
Kat Marchán fc917021ea tests: got narrated tests passing again 2021-09-22 16:34:21 -07:00
Kat Marchán b10693a91c tests: fix doctests and such 2021-09-22 16:34:21 -07:00
Kat Marchán eb9f6986e9 tests: all graphical tests passing 2021-09-22 16:34:21 -07:00
Kat Marchán 8e11baab7b feat(related): Add related diagnostics (#68)
Fixes: https://github.com/zkat/miette/issues/47
2021-09-22 16:34:21 -07:00
Kat Marchán 3a901ace68 tests: more testing 2021-09-22 16:34:21 -07:00
Kat Marchán 49f635fb65 tests: rename printer.rs to graphical.rs 2021-09-22 16:34:21 -07:00
Kat Marchán 0544d7654e tests: update printer tests so they compile 2021-09-22 16:34:21 -07:00
Kat Marchán f87b158b22 feat(labels): replace snippet stuff with simpler labels (#62) 2021-09-22 16:34:21 -07:00
Kat Marchán cd69a8ae92 test: prefix Error: to make things look more accurate 2021-09-22 16:34:21 -07:00
Kat Marchán 2c43740346 feat(theme): more styling changes 2021-09-22 16:34:21 -07:00
Kat Marchán 559113bd1c tests: add test for wide character support 2021-09-22 16:34:21 -07:00
Kat Marchán 93374173e3 feat(footer): add footer support to graphical and narrated
Fixes: https://github.com/zkat/miette/issues/34
2021-09-22 16:34:21 -07:00
Kat Marchán 247e8f8b39 feat(deps): move fancy reporter (and its deps) to a feature
BREAKING CHANGE: The default fancy reporter is no longer available unless you enable the "fancy" feature. This also means you will not be pulling in a bunch of deps if you are using miette for a library

Fixes: https://github.com/zkat/miette/issues/25
2021-09-22 16:34:21 -07:00
Kat Marchán 4c2463f9ae feat(report): make a single big MietteHandler that can switch modes
BREAKING CHANGE: linkification option method on GraphicalReportHandler has been changed to .with_links(bool)
2021-09-22 16:34:21 -07:00
Kat Marchán 643e769a80
tests: update tests after shortening header because of Error: 2021-09-13 17:49:38 -07:00
Cormac Relf 2fa5551c81
feat(derive): Add `#[diagnostic(forward(field_name), code(...))]` (#41) 2021-09-13 15:39:04 -07:00
Robin Appelman d994add912
fix(report): Fix end of previous line wrongly being included in highlight (#52) 2021-09-13 09:57:54 -07:00
Kat Marchán eaebde92cf
feat(report): make header line as wide as terminal 2021-09-10 17:09:52 -07:00
Kat Marchán bc72532465
feat(report): take terminal width into account for wrapping text 2021-09-10 12:39:10 -07:00
Kat Marchán f482dcec6a
feat(report): wrap multiline messages to keep formatting
Fixes: https://github.com/zkat/miette/issues/51
2021-09-10 08:16:40 -07:00
Kat Marchán 1ba3f2f5d2
fix(report): get rid of the weird arrow thing. it does not look good 2021-09-10 07:36:09 -07:00
Kat Marchán 533ff5f348
fix(reporter): improve color situation and style things a little nicer 2021-09-08 20:59:19 -07:00
Kat Marchán 00ebb13ea6
tests: have at least one test with multiple causes 2021-09-08 19:46:04 -07:00
Kat Marchán 824cd8bebe
feat(printer): use uparrow for empty highlights and fix 0-offset display bug 2021-09-07 17:41:28 -07:00
Kat Marchán 3f9da04b86
feat(report): anyhow-ify DiagnosticReport (#35)
This PR overhauls the toplevel/main experience for `miette`. It adds a new `Report` type based on `eyre::Report` and overhauls various types to fit into this model, as well as prepare for some [future changes in Rust](https://github.com/nrc/rfcs/pull/1) that will make it possible to integrate `miette` directly with crates like `eyre` instead of having to use this specific `Report`.

As such, this PR is a major breaking change, especially for anyone using `DiagnosticReport` and company.

BREAKING CHANGES:
* `DiagnosticReport` is now just `Report`, and is a different, `eyre::Report`-like type.
* `DiagnosticResult` is now just `Result`.
* `.into_diagnostic()` now just transforms the error into a `Report`.
* `DiagnosticReportPrinter` has been replaced with `ReportHandler`
* `set_printer` has been replaced by `set_hook`
* `code` is now optional.
* `.into_diagnostic()` no longer takes a `code` argument.
* `#[diagnostic]` is now optional when deriving `Diagnostic`.
2021-09-04 21:22:46 -07:00
Cormac Relf 84219f6c80
fix(printer): Show snippet message for unnamed sources (#39)
Fixes: https://github.com/zkat/miette/issues/38
2021-08-29 19:28:17 -07:00
Felipe Seré 5a474370dd
fix(reporter): Only inc the line count if we haven't already done so with '\n' or '\r\n' (#37) 2021-08-29 12:33:45 -07:00