-
Notifications
You must be signed in to change notification settings - Fork 664
feat(rome_console): add a Codespan utility struct to display annotated code fragments #2341
Conversation
///! This module if a fork of https://github.com/brendanzab/codespan, | ||
/// adapted to use the `rome_console` markup for formatting |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
///! This module if a fork of https://github.com/brendanzab/codespan, | |
/// adapted to use the `rome_console` markup for formatting | |
//! This module if a fork of https://github.com/brendanzab/codespan , | |
//! adapted to use the `rome_console` markup for formatting |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we add this project to the credits section? https://rome.tools/credits/#forks
/// A note. | ||
Note, | ||
/// A help message. | ||
Help, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the the difference between these two? How do we know when to use one or the other? Should we add it to the documentation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The basic difference seem to be that Note
is printed in green and is converted to the Hint
severity in the LSP, while Help
is printed in blue and is converted to the Information
severity in the LSP. Overall they don't seem to be used much yet, a quick grep over the entire codebase returned no usage of the help severity while the note severity is used for only two diagnostics, and even then it's in footer notes and not in actual codespan labels.
source_file: &'diagnostic SourceFile<'diagnostic>, | ||
labeled_file: Option<LabeledFile<'diagnostic>>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the difference between these two?
Deploying with Cloudflare Pages
|
Summary
This PR adds a simplified copy of the code in
crates/rome_diagnostics/src/codespan
torome_console
, exposing aCodespan
struct intended to display annotated code as markup in the console. This is the first step in a refactor ofDiagnostic
to make the struct implementrome_console::fmt::Display
on top of common markup and utilities, essentially turning the rendering logic for diagnostics into the following markup:Example