Discussion
Loading...

Post

Log in
  • About
  • Code of conduct
  • Privacy
  • Users
  • Instances
  • About Bonfire
kat
kat
@zkat@toot.cat  ·  activity timestamp 2 months ago

I am once again reminded that I should probably do a better job of letting people know that if they use miette, or things that use miette, you can put NO_GRAPHICS=1 in an env var, and instead of drawing fancy graphical diagnostics, miette will automatically drop into a "narratable" renderer that's optimized for screen readers. The output looks like:

oops!
Diagnostic severity: error
Begin snippet for bad_file.rs starting at line 1, column 1

snippet line 1: source
snippet line 2: text
label at line 2, columns 3 to 6: this bit here
snippet line 3: here
diagnostic help: try doing it better next time?
diagnostic code: oops::my::bad

This works for any tool or library using miette unless they're manually messing with renderer settings and preventing this fallback from happening.

#Miette #Rust #RustLang

screenshot of a test for the corresponding graphical version of the diagnostic being shown in the toot
screenshot of a test for the corresponding graphical version of the diagnostic being shown in the toot
screenshot of a test for the corresponding graphical version of the diagnostic being shown in the toot
  • Copy link
  • Flag this post
  • Block
Hans
Hans
@Hans@tuebingen.network replied  ·  activity timestamp 2 months ago

@zkat Is this environment variable a commonly accepted standard like the NO_COLOR one?

  • Copy link
  • Flag this comment
  • Block
kat
kat
@zkat@toot.cat replied  ·  activity timestamp 2 months ago

@Hans not as far as I know

  • Copy link
  • Flag this comment
  • Block
Sven
Sven
@HeNeArXn@chaos.social replied  ·  activity timestamp 2 months ago

@zkat that's a very cool feature!

  • Copy link
  • Flag this comment
  • Block
lui x31, .LkleinesFilmröllchen
lui x31, .LkleinesFilmröllchen
@filmroellchen@chaos.social replied  ·  activity timestamp 2 months ago

@zkat @ekuber i did not know this! as i'm using custom options in #spcasm , ill check right away if it can still do this (and add tests for it). thanks!!

  • Copy link
  • Flag this comment
  • Block
kat
kat
@zkat@toot.cat replied  ·  activity timestamp 2 months ago

@filmroellchen https://github.com/zkat/miette/blob/df7bcfa17d9c0813286050ee245d5c3d94653f1c/src/handler.rs#L25-L40

basically if you're setting a custom handler hook, you need to make sure it's not forcing graphical. Otherwise, it'll do the proper fallback (see https://github.com/zkat/miette/blob/df7bcfa17d9c0813286050ee245d5c3d94653f1c/src/handler.rs#L344-L354)

You can also use this to do your own logic, such as doing it on NO_COLOR instead of NO_GRAPHICS

  • Copy link
  • Flag this comment
  • Block
lui x31, .LkleinesFilmröllchen
lui x31, .LkleinesFilmröllchen
@filmroellchen@chaos.social replied  ·  activity timestamp 2 months ago

@zkat ok it works fine! great feature thanks!

  • Copy link
  • Flag this comment
  • Block
nadja
nadja
@dequbed@mastodon.chaosfield.at replied  ·  activity timestamp 2 months ago

@zkat that's really cool and a great way to add accessibility to a crate like miette. Thank you!

  • Copy link
  • Flag this comment
  • Block

bonfire.cafe

A space for Bonfire maintainers and contributors to communicate

bonfire.cafe: About · Code of conduct · Privacy · Users · Instances
Bonfire social · 1.0.2-alpha.7 no JS en
Automatic federation enabled
Log in
  • Explore
  • About
  • Members
  • Code of Conduct