Skip to content

Link to corresponding sections for enum variants in rustdoc #75178

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

Closed
wants to merge 3 commits into from

Conversation

RDambrosio016
Copy link
Contributor

@RDambrosio016 RDambrosio016 commented Aug 5, 2020

resolves #74849 (for structs rustdoc shows fields omitted, so i am not sure if that should be removed and replaced for this)

This makes the text for each variant in an enum declaration a link to their corresponding section. As for the color that must be decided, i am by no means a design expert, i chose the color used for statics since it looked nice and not overbearing. But if you have an idea for a better color feel free to comment!

@Aaron1011 For structs do you mean rustdoc should render fields as well with clickable links for the fields?

Example of the output on dark theme
Example

@rust-highfive
Copy link
Contributor

Some changes occurred in HTML/CSS/JS.

cc @GuillaumeGomez

Some changes occurred in HTML/CSS themes.

cc @GuillaumeGomez

A change occurred in the Ayu theme.

cc @Cldfire

@rust-highfive
Copy link
Contributor

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @GuillaumeGomez (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 5, 2020
@Cldfire
Copy link
Contributor

Cldfire commented Aug 5, 2020

As far as the colors go, I played around with the blues a bit and came up with:

  • Light theme: #2f71b3

image

  • Dark theme: #8eb4db

image

  • Ayu theme: #98c1ee

image

They all have good contrast for their respective backgrounds and fit in well with the surrounding colors.

Something else I noticed was that in the light and dark themes, we went from:

image

to, after this PR:

image

(layout: is colored now.) We should color the enum variants down there instead since that's the color that corresponds to the new links (or maybe we could leave them uncolored?).

@GuillaumeGomez
Copy link
Member

I'm not a big fan of adding link in code blocks nor adding extra colors to the fields description (I don't mind adding colors in the type code block though).

@Aaron1011
Copy link
Member

resolves #74849 (for structs rustdoc shows fields omitted, so i am not sure if that should be removed and replaced for this)

@RDambrosio016: I think that's only for private fields/structs. For example, rustc_infer::traits::Obligation shows all of the fields. I think it would be useful to generate links for structs as well.

@GuillaumeGomez: I think links in code blocks are very useful, especially for larger enums. For example, having links on rustc_hir::ExprKind would make it much easier to read the description for any particular variant.

@GuillaumeGomez
Copy link
Member

You already have all the links in the sidebar.

@Aaron1011
Copy link
Member

@GuillaumeGomez: Personally, I find it easier to read through the code block enum declaration, rather than looking at the sidebar. Types used in codeblocks already have links - is there any harm in adding more?

@GuillaumeGomez
Copy link
Member

Which types in codeblocks already have links?

Also, I said I don't like it but if people are in favor, then we'll merge it, don't worry. ;)

@Aaron1011
Copy link
Member

@GuillaumeGomez: Any type used in a codeblock (other than a plain generic parameter T) has a link: see the pages I listed in #75178 (comment) for examples

@GuillaumeGomez
Copy link
Member

This is a good argument.

@GuillaumeGomez
Copy link
Member

Ok, I've been thinking about it for a while, and here's my conclusion: this is a good idea. However, we should also do it for all types with fields (as long as we provide a section for the fields). What do you think?

Otherwise, great work here!

@ollie27 ollie27 added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Aug 5, 2020
@jyn514 jyn514 added the C-feature-accepted Category: A feature request that has been accepted pending implementation. label Aug 7, 2020
@RDambrosio016
Copy link
Contributor Author

It has been decided this feature should be expanded to be more expansive, and it should be incrementally implemented, therefore i will be closing this PR and opening a tracking issue. Then incrementally opening PRs to add this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-accepted Category: A feature request that has been accepted pending implementation. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rustdoc should link fields/variants to their corresponding section
7 participants