Skip to content

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

Closed
@Wilfred

Description

@Wilfred
Contributor

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.

Activity

added
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
on Nov 3, 2023
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[/+] on Nov 3, 2023
added
T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.
C-enhancementCategory: An issue proposing an enhancement or a PR with one.
A-rustdoc-uiArea: Rustdoc UI (generated HTML)
and removed
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
on Nov 3, 2023
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[/+] on Nov 3, 2023
GuillaumeGomez

GuillaumeGomez commented on Nov 6, 2023

@GuillaumeGomez
Member

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

GuillaumeGomez

GuillaumeGomez commented on Nov 6, 2023

@GuillaumeGomez
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.

added a commit that references this issue on Dec 3, 2023

Rollup merge of rust-lang#117869 - GuillaumeGomez:comment-highlightin…

591b845
added a commit that references this issue on Dec 3, 2023
92531fc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-rustdoc-uiArea: Rustdoc UI (generated HTML)C-enhancementCategory: An issue proposing an enhancement or a PR with one.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Participants

      @Wilfred@GuillaumeGomez@clubby789@rustbot

      Issue actions

        rustdoc does not consistently apply syntax highlighting to the item declaration · Issue #117555 · rust-lang/rust