spectreconsole / errata Goto Github PK
View Code? Open in Web Editor NEWA library that makes it easy to create and display diagnostics of different kinds.
License: MIT License
A library that makes it easy to create and display diagnostics of different kinds.
License: MIT License
When adding a label to the last character of a file rendering will fail with an invalid offset
error.
Assuming the following file:
---
Title: Home
---
# Foo
Bar
And the following label:
report.AddDiagnostic(
Diagnostic.Error("This will fail")
.WithLabel(new Label("Demo/Files/Example2.md", new Location(5, 3), "Issue on last character of the line")
.WithColor(Color.Yellow)
.WithLength(1)));
Output will be:
┌─Errata Error────────────────────────────────────────────┐
│ An error occured when rendering diagnostic │
│ Error: Invalid offset │
│ │
│ If you belive this is a bug in Errata, please submit it │
│ at https://github.com/spectreconsole/errata/issues/new │
└─────────────────────────────────────────────────────────┘
See pascalberger@d9926e1 for a repro
I was looking for a way to render Reports to a string (accepting drawbacks like losing the colors, monospace font requirement for display, etc.), and it seems that this would require implementing a special IAnsiConsole.
Do this sound viable, or would expect problems? Or maybe there is already a way to do this that I just haven't found?
Thanks!
We should add context lines so it's easier to understand what's going on when looking at a diagnostic.
See https://twitter.com/malfaitrobin/status/1431572577370116099?s=20&t=wiR6C0IN9ichq3LOikP8ag for example.
Errata is a good fit to print diagnostic information from another tool. Currently it will throw an exception as soon as something unexpected happens (file not found, label position out of range). There are cases where this can happen (e.g. error references state from memory not from disk). In the current version Errate will throw and stop rendering. It would be helpful to have a setting to enable a mode where such errors would be printed to the console instead of an exception being thrown
Right now, we don't really care about how long a label message is or the line it references, but for some files, it might look strange and mess up the rendering of diagnostics. We should handle these scenarios better.
If I have a line like this:
Foo
And ad a label at position 3 with length 1, Errata will throw an exception label column cannot start at the end of the line
.
I would expect the label to be rendered like this:
Foo
^
My label
See https://github.com/pascalberger/errata/blob/label-position-eol/examples/Demo/Program.cs#L60_L65 for a repro.
Labels can currently be created for a range or location consisting of line and column. It would be useful to have the possibility to create a label for a whole line. Currently this is possible by either set column to 1 or appropriate length or span if this information is available.
API could look like this:
report.AddDiagnostic(
new Diagnostic("Fix formatting")
.WithLabel(new Label("Example/Files/Program.cs", new Location(42), "Code should not contain trailing whitespace")
.WithColor(Color.Yellow)));
Labels affecting a whole line can either by drawn across the whole line:
Or by marking the linke to the side:
It would be nice to namespace the dotnet tool examples like dotnet-errata-examples
to prevent possible collisions and make it clearer what it is (without having to look at the description field). Cheers!!
Labels can currently be created for a range or location consisting of line and column inside a file. It would be useful to have the possibility to create labels for a whole file.
API could look like this:
report.AddDiagnostic(
new Diagnostic("Fix formatting")
.WithLabel(new Label("Example/Files/Program.cs", "Code should not contain trailing whitespace")
.WithColor(Color.Yellow)));
Label affecting a whole file could look like this:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.