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

rustdoc does not consistently apply syntax highlighting to the item declaration #117555

Closed
Wilfred opened this issue Nov 3, 2023 · 2 comments · Fixed by #117869
Closed

rustdoc does not consistently apply syntax highlighting to the item declaration #117555

Wilfred opened this issue Nov 3, 2023 · 2 comments · Fixed by #117869
Labels
A-rustdoc-ui Area: Rustdoc UI (generated HTML) C-enhancement Category: An issue proposing an enhancement or a PR with one. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@Wilfred
Copy link
Contributor

Wilfred commented Nov 3, 2023

There doesn't seem to be keyword or comment highlighting for the first snippet on rustdoc pages.

https://doc.rust-lang.org/std/path/struct.PathBuf.html

Screenshot 2023-11-03 at 11 28 28

https://doc.rust-lang.org/std/default/trait.Default.html (there is some highlighting here, but less than other snippets)

Screenshot 2023-11-03 at 11 29 00

By contrast, other snippets seem to be fine, e.g. https://doc.rust-lang.org/std/vec/struct.Vec.html#examples has keyword and comment highlighting:

Screenshot 2023-11-03 at 11 30 49

I searched for rustdoc syntax highlighting issues, but I couldn't find anything relevant. #75981 notes that rustdoc is using the lexer to highlight, but I'd expect that to handle at least comments correctly. This issue seems to have existed for a while, e.g. #103050 shows the same missing comment highlighting.

@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Nov 3, 2023
@clubby789 clubby789 changed the title rustdoc does not apply full syntax highlighting to the first code snippet rustdoc does not apply full syntax highlighting to the item declaration Nov 3, 2023
@clubby789 clubby789 added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. C-enhancement Category: An issue proposing an enhancement or a PR with one. A-rustdoc-ui Area: Rustdoc UI (generated HTML) and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Nov 3, 2023
@clubby789 clubby789 changed the title rustdoc does not apply full syntax highlighting to the item declaration rustdoc does not consistently apply syntax highlighting to the item declaration Nov 3, 2023
@GuillaumeGomez
Copy link
Member

It's true that pub and struct should be highlighted. I'll send a fix shortly.

@GuillaumeGomez
Copy link
Member

I opened #117643, but as mentioned in the PR, I'm really not sure this is a good idea. You can test the feature there.

@bors bors closed this as completed in 591b845 Dec 3, 2023
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Dec 3, 2023
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`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rustdoc-ui Area: Rustdoc UI (generated HTML) C-enhancement Category: An issue proposing an enhancement or a PR with one. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
4 participants