Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add simple diagnostic rendering mode #85

Open
brendanzab opened this issue Jun 10, 2019 · 4 comments
Open

Add simple diagnostic rendering mode #85

brendanzab opened this issue Jun 10, 2019 · 4 comments

Comments

@brendanzab
Copy link
Owner

As part of #30 it might be nice to have a simple diagnostic rendering mode to make it easier on screen readers. This would only display a list of diagnostics, without the source snippets.

Here's an example of what it might look like:

error[E0308]: `case` clauses have incompatible types
    - FizzBuzz.fun:8:12: expected `String`, found `Nat`
        = expected type `String`
             found type `Nat`
        = FizzBuzz.fun:4:13: `case` clauses have incompatible types
        = FizzBuzz.fun:3:15: expected type `String` found here

error[E0308]: `case` clauses have incompatible types
    - FizzBuzz.fun:15:16: expected `String`, found `Nat`
        = expected type `String`
             found type `Nat`
        = FizzBuzz.fun:11:5: `case` clauses have incompatible types
        = FizzBuzz.fun:12:16: this is found to be of type `String`
        = FizzBuzz.fun:13:16: this is found to be of type `String`
        = FizzBuzz.fun:14:16: this is found to be of type `String`

Perhaps others have better ideas though?

@brendanzab
Copy link
Owner Author

Rustc has a --message-format short mode too, which effectively looks like:

FizzBuzz.fun:8:12: error[E0308]: `case` clauses have incompatible types
FizzBuzz.fun:15:16: error[E0308]: `case` clauses have incompatible types

@Johann150
Copy link
Contributor

Combining with information from #30, I think maybe a "medium mode" where notes are also rendered might be a good idea.

Another Idea would be to write information so it is easier to understand when only read by a screen reader (which might not pronounce punctuation characters for example). But this is probably something that would better be done using the proposed JSON output.

As an example, one could render the first example from the fizz_buzz test like this:

error E0308: `case` clauses have incompatible types
in file FizzBuzz.fun on line 8, column 12.
additional information:
line 8, column 12: expected `String`, found `Nat`.
line 3, column 15: expected type `String` found here.
line 4, column 14 until line 8: `case` clauses have incompatible types.

@brendanzab
Copy link
Owner Author

That sounds really cool! I like it! It would be nice if we offered the screen-reader support out of the box, but then allow people to build their own tools using JSON.

@Johann150
Copy link
Contributor

I am still not sure that "screen reader mode" (lets call it SCREAM 😅) should be built directly into codespan-reporting. On the one hand I think it should be something like a separate crate, like serde has serde_json etc. And I think this would be great to show how to build such tools. This would also not put users of SCREAM at the mercy of the users of codespan-reporting (programmers, which tend to be lazy) to implement some kind of command line parameter to enable it.

On the other hand I don't know how that should work because codespan-reporting is not the binary. So SCREAM would have to interface with another binary, somehow? That makes me believe that this would maybe even be a better addition to codespan-lsp, as interfacing with that would probably be easier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants