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

Beginning of more beautiful rustc --explain #25033

Closed
wants to merge 4 commits into from

Conversation

GuillaumeGomez
Copy link
Member

As mentionned in #24523, here is the beginning of the more beautiful printing. Only tested under linux. It doesn't -yet- manage terminals which doesn't handle color printing. Any opinion is welcome.

@rust-highfive
Copy link
Collaborator

r? @nikomatsakis

(rust_highfive has picked a reviewer for you, use r? to override)

@GuillaumeGomez GuillaumeGomez changed the title Beginning of beautifuler rustc --explain Beginning of more beautiful rustc --explain May 1, 2015
@killercup
Copy link
Member

This sounds quite cool. Can you maybe add a screenshot?

I guess by only using blue and red for highlights, you don't need to concern yourself with detecting the terminals background color (since red and blue both work on dark and light backgrounds). Do you have any plans for a more complex color scheme?

@GuillaumeGomez
Copy link
Member Author

I actually asked yesterday on the IRC if there is any color code but no one answered. For the parsing, I wanted to use the one made in rustdoc (I asked for help for that but no answer yet neither ^^). Here is the current display :

screenshot from 2015-05-02 13 00 04

@bluss
Copy link
Member

bluss commented May 2, 2015

Errors and warnings are already colored. Rustc uses som kind of term library for this. You should look into it.

@killercup
Copy link
Member

@GuillaumeGomez, @bluss is right, there is a libterm (docs) that seems to do some terminal output stuff.

@GuillaumeGomez
Copy link
Member Author

Oh nice ! I'll take a look then !

@huonw
Copy link
Member

huonw commented May 2, 2015

It would be good to have this code not directly inside lib.rs, e.g. a explain.rs submodule would be better.

@GuillaumeGomez
Copy link
Member Author

@huonw: Don't worry, it was just a start to have an idea of what it'll look like after. For now, the code is just ugly.

@GuillaumeGomez
Copy link
Member Author

I created an explain.rs submodule and I also use the libterm. But I'm not very happy of the color code. Another one could be nice. Any idea of how I could improve it ?

@ghost
Copy link

ghost commented May 2, 2015

I'm concerned about the maintainability of this code. Could we use something like https://github.com/rkitover/vimpager or http://www.gnu.org/software/src-highlite/ for this purpose, instead? We have the vim definitions already so this would be a matter of shelling out, of course conditional on vim being present.

The build changes may be non-trivial but would be more future-proof, I think. Thoughts?

@GuillaumeGomez
Copy link
Member Author

I'm a fan of emacs actually. :-p Once again, this code is just a preview, I don't intend to continue this one. I'd prefer use something from inside the compiler (I'm thinking about the librustdoc).

@michaelsproul
Copy link
Contributor

One way I thought of doing this would be to write a custom renderer for Hoedown (the markdown parser used by rustdoc). This would give us heading highlighting almost for free, and then we could generalise the code in src/librustdoc/html/higlight.rs to highlight code blocks.

@GuillaumeGomez
Copy link
Member Author

@michaelsproul: hum... Why not. Originally, I was going to use the rustdoc, not modify it. However it seems even better this way, I'll give it a try.

@michaelsproul
Copy link
Contributor

@GuillaumeGomez: It's a whole lot of FFI and stuff, but if you're up for it...

@GuillaumeGomez
Copy link
Member Author

I am. I'll start to see how rustdoc works before going any further and then I'll modify it.

@nikomatsakis
Copy link
Contributor

@GuillaumeGomez So I am confused as to what should happen with this current PR -- should we close it, as you are now trying an alternative approach?

@GuillaumeGomez
Copy link
Member Author

I'm still working on rustdoc. I don't have much time recently (and I'm sorry about that). So can you keep it open while I start the other one please ?

@alexcrichton
Copy link
Member

Closing due to inactivity, but I'm looking forward to see where this goes!

@GuillaumeGomez GuillaumeGomez deleted the explain branch July 8, 2015 10:52
@GuillaumeGomez GuillaumeGomez mentioned this pull request Apr 27, 2016
10 tasks
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

Successfully merging this pull request may close these issues.

8 participants