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] Render tuple fields in structs correctly #80320

Closed

Conversation

RDambrosio016
Copy link
Contributor

This PR makes rustdoc render public tuple fields correctly similar to normal fields, previously no rendering would happen and the description of the field was effectively discarded.

Before:
before

After:
after

I was thinking about coloring the 0 a different color, maybe the color of primitives so it stands out more, but id like to hear opinions on that first.

@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @ollie27 (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 Dec 23, 2020
@jyn514 jyn514 added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Jan 5, 2021
@camelid
Copy link
Member

camelid commented Jan 22, 2021

I was thinking about coloring the 0 a different color, maybe the color of primitives so it stands out more, but id like to hear opinions on that first.

I do think it makes sense for it to be a different color, but it seems that coloring it as a primitive might be confusing.

@RDambrosio016
Copy link
Contributor Author

I agree, but i suck at design, especially colors 😄

@bors
Copy link
Contributor

bors commented Jan 22, 2021

☔ The latest upstream changes (presumably #81271) made this pull request unmergeable. Please resolve the merge conflicts.

@camelid
Copy link
Member

camelid commented Jan 25, 2021

r? @GuillaumeGomez

@camelid camelid added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Jan 25, 2021
@@ -0,0 +1,11 @@
// @has tuple_struct_fields/struct.Tooople.html
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also add a check like:

Suggested change
// @has tuple_struct_fields/struct.Tooople.html
// @has tuple_struct_fields/struct.Tooople.html
// @has - 'Tuple Fields'

to make sure the heading is correct?

Copy link
Contributor Author

@RDambrosio016 RDambrosio016 Jan 25, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think i added that at one point then removed it because it wasn't working (and the errors are less helpful than staring at a wall), but ill try again tomorrow 👍

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(and the errors are less helpful than staring at a wall)

Yeah, htmldocck errors could use some work.

@GuillaumeGomez
Copy link
Member

GuillaumeGomez commented Jan 25, 2021

I was thinking about coloring the 0 a different color, maybe the color of primitives so it stands out more, but id like to hear opinions on that first.

As you see fit. I don't have a strong opinion there...

@@ -3079,21 +3079,22 @@ fn item_struct(
_ => None,
})
.peekable();
if let doctree::Plain = s.struct_type {
if let doctree::Plain | doctree::Tuple = s.struct_type {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't even know we could do that in rust! 😮

@@ -0,0 +1,11 @@
// @has tuple_struct_fields/struct.Tooople.html
// @has - //span '0: usize'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you write more complete paths please? It's much easier when an unwanted change occur to find out where it's from in such cases.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As i stated in an earlier comment, i tried that, but the test harness kept erroring and i could not figure out why, which is why i removed it

Copy link
Member

@GuillaumeGomez GuillaumeGomez Jan 25, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can help with that! :) If it's the same as a normal field, the path should look like this:

//section[@id="main"]/span[@id="structfield.0"] '0: usize'

Also, please add tests to ensure that "Tuple fields" header is there and that the fields are in the sidebar too.

@@ -0,0 +1,11 @@
// @has tuple_struct_fields/struct.Tooople.html
// @has - //span '0: usize'
// @has - 'Wow! i love tuple fields!'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same.

// @has tuple_struct_fields/struct.Tooople.html
// @has - //span '0: usize'
// @has - 'Wow! i love tuple fields!'
// @!has - 'I should be invisible'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@camelid
Copy link
Member

camelid commented Jan 29, 2021

Does this fix #42615? (For structs and enums.)

@JohnCSimon
Copy link
Member

@RDambrosio016 - ping from triage, can you please address the merge conflict and comments from the reviewers? Thanks.

@RDambrosio016
Copy link
Contributor Author

I'll see if i can get to it today, ive just been very busy with other things and i kind of forgot about this 😅

@JohnTitor JohnTitor removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 2, 2021
@crlf0710
Copy link
Member

@RDambrosio016 Ping from triage, any updates on this?

@JohnCSimon JohnCSimon added the S-inactive Status: Inactive and waiting on the author. This is often applied to closed PRs. label Apr 4, 2021
@JohnCSimon
Copy link
Member

@RDambrosio016 Ping from triage - unfortunately I'm going to have to close this as inactive. Please reopen this when you're ready to continue.

GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Jul 27, 2021
…oc, r=jyn514

Add support for tuple struct field documentation

Fixes  rust-lang#42615.
This is rust-lang#80320 updated to new codebase and with added tests.
Part of rust-lang#83255.

cc `@camelid` (since you were involved on the original PR).
r? `@jyn514`
JohnTitor added a commit to JohnTitor/rust that referenced this pull request Jul 28, 2021
…oc, r=jyn514

Add support for tuple struct field documentation

Fixes  rust-lang#42615.
This is rust-lang#80320 updated to new codebase and with added tests.
Part of rust-lang#83255.

cc ``@camelid`` (since you were involved on the original PR).
r? ``@jyn514``
JohnTitor added a commit to JohnTitor/rust that referenced this pull request Jul 28, 2021
…oc, r=jyn514

Add support for tuple struct field documentation

Fixes  rust-lang#42615.
This is rust-lang#80320 updated to new codebase and with added tests.
Part of rust-lang#83255.

cc ```@camelid``` (since you were involved on the original PR).
r? ```@jyn514```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-inactive Status: Inactive and waiting on the author. This is often applied to closed PRs. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. 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.

None yet

10 participants