-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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 color on item name in item declaration #117643
Add color on item name in item declaration #117643
Conversation
r? @notriddle (rustbot has picked a reviewer for you, use r? to override) |
The job Click to see the possible cause of the failure (guessed by this bot)
|
Stupid question: why do we have two different colour systems? What's stopping us rendering all the 'documentation' system the same way as source code? (Full disclosure: I've been helping maintain the VS Code syntax highlighter for Rust recently, so I might be extra sensitive to highlighting inconsistencies.) |
This doesn't seem to be working for macros. |
The macros are the exceptions: they use code highlighting and not doc highlighting.
In documentation, we want to put more importance not on keywords but on items name (which you can click most of the time). You don't read documentation the same you read source code, hence why we have two different colour systems. |
Gotcha, that makes sense. So the goal is to distinguish examples (full highlighting) with prose that has clickable links? I see That makes total sense: in the header here you absolutely want to be able click I guess options might be: (1) Add comment highlighting to the documentation highlighter. I think this would help users read the declaration, because it makes the rest of the declaration more prominent. (2) Add a third highlighter, 'full highlighting but with links'. We could use it for declarations, and maybe even code snippets and highlighted source code like https://doc.rust-lang.org/src/alloc/vec/mod.rs.html too. Racket does this, and it makes the docs super easy to navigate: https://docs.racket-lang.org/guide/Lists__Iteration__and_Recursion.html#%28part._.Predefined_.List_.Loops%29 If these seem reasonable, I'm also willing to help if you have code pointers :) |
This is a very nice write-up. Adding comment highlighting seems like the best choice (ie, dimming it out a bit to give it less importance?)
I'm not sure to fully understand what you're suggesting here. By code snippets you mean code in paragraph like The code examples and source code pages are already highlighted, so not sure what you mean there either. In any case, having highlighting for comments in item declarations is easy to do: wrap the text inside The "tricky" part is to find where the comments are generated (a Closing this PR in any case. |
…g-item-decl, r=notriddle [rustdoc] Add highlighting for comments in items declaration Fixes rust-lang#117555. So after the discussion in rust-lang#117643, the outcome was that having the comments in the item declaration at the same level (in term of color) as the rest of the code was actually a bit distracting and could be improved. The current highlighting color for comments is "lighter" than the rest and I think it fits perfectly to improve the current situation. With this, we now have different "levels" which makes it easier to read and filter out what we want when reading the items declaration. Here's a screenshot: ![image](https://github.com/rust-lang/rust/assets/3050060/dbd98029-e98b-4997-9a89-6b823eaac9a4) r? `@notriddle`
Rollup merge of rust-lang#117869 - GuillaumeGomez:comment-highlighting-item-decl, r=notriddle [rustdoc] Add highlighting for comments in items declaration Fixes rust-lang#117555. So after the discussion in rust-lang#117643, the outcome was that having the comments in the item declaration at the same level (in term of color) as the rest of the code was actually a bit distracting and could be improved. The current highlighting color for comments is "lighter" than the rest and I think it fits perfectly to improve the current situation. With this, we now have different "levels" which makes it easier to read and filter out what we want when reading the items declaration. Here's a screenshot: ![image](https://github.com/rust-lang/rust/assets/3050060/dbd98029-e98b-4997-9a89-6b823eaac9a4) r? `@notriddle`
Fixes #117555.
I'm really not convinced this is a good idea. It does put more colors, but I'm not sure it's adding any value. We have two different color systems: one for source codes and one for documentation. Item declaration is actually using the same system as "documentation", so only highlighting links.
So in this draft, I generated an empty link on the item name to add some color, but again, really not convinced by this approach...
You can test it here.
Some screenshots: