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

Add empty impl blocks if they have documentation #90905

Merged
merged 4 commits into from
Jun 6, 2022

Conversation

GuillaumeGomez
Copy link
Member

Fixes #90866.

The update for the test script is needed to count the number of impl blocks we have with only the struct. To be noted that with #89676 merged, it wouldn't be needed (I don't know what is the status of it btw. cc @Mark-Simulacrum).

It looks like this:

Screenshot from 2021-11-14 16-51-28

cc @jyn514
r? @camelid

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 14, 2021
@GuillaumeGomez GuillaumeGomez changed the title Empty impl blocks Add empty impl blocks if they have documentation Nov 14, 2021
@GuillaumeGomez GuillaumeGomez added A-rustdoc-ui Area: Rustdoc UI (generated HTML) T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Nov 14, 2021
@rust-log-analyzer

This comment has been minimized.

@GuillaumeGomez
Copy link
Member Author

Every time I run cargo fmt on librustdoc I get this error...

@camelid
Copy link
Member

camelid commented Nov 14, 2021

Sorry, I likely won't be able to review this for some time. r? @jyn514

@rust-highfive rust-highfive assigned jyn514 and unassigned camelid Nov 14, 2021
@GuillaumeGomez
Copy link
Member Author

r? @jsha

@rust-highfive rust-highfive assigned jsha and unassigned jyn514 Nov 20, 2021
@jyn514
Copy link
Member

jyn514 commented Nov 24, 2021

Every time I run cargo fmt on librustdoc I get this error...

You need to use x.py fmt src/librustdoc.

@jyn514
Copy link
Member

jyn514 commented Nov 24, 2021

@GuillaumeGomez why did you add a warning note to the documentation? It seems like unnecessary clutter, you can already see it's empty just by looking at it.

@jyn514 jyn514 added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 24, 2021
@jyn514
Copy link
Member

jyn514 commented Nov 24, 2021

The update for the test script is needed to count the number of impl blocks we have with only the struct. To be noted that with #89676 merged, it wouldn't be needed (I don't know what is the status of it btw).

Can you explain this a little more? Why was the existing test framework insufficient? How would #89676 have helped?

@GuillaumeGomez
Copy link
Member Author

Every time I run cargo fmt on librustdoc I get this error...

You need to use x.py fmt src/librustdoc.

Absolutely, just the force of habit. :)

@GuillaumeGomez why did you add a warning note to the documentation? It seems like unnecessary clutter, you can already see it's empty just by looking at it.

Because I found that this suggestion made sense. But we can talk more about it if you think it's not useful. (cc @jsha too)

Can you explain this a little more? Why was the existing test framework insufficient? How would #89676 have helped?

Sure, I needed to count the number of items with this text. Currently we can't count how many items have this text, only how many items have this attribute or how many items with this XPath exist. With #89676, I could have used the *[text()="some text"] directly into the XPath and count the number of items matching it. Currently, we can't use *[text() = "..."] to filter items because of the limitations of the tool we use.

@@ -1634,6 +1634,18 @@ fn render_impl(
}

if let Some(ref dox) = cx.shared.maybe_collapsed_doc_value(&i.impl_item) {
if render_mode == RenderMode::Normal
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, shouldn't it be impossible for render_mode to be RenderMode::Deref and for trait.is_some() to be true at the same time, since the recursive deref check only documents inherent impls? Why check both?

I wonder if we could combine those somehow maybe? Or maybe it makes more sense to show traits that the deref target implements 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

It's already checked just a few lines above so completely unneeded, you're absolutely right.

Copy link
Member Author

Choose a reason for hiding this comment

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

As for showing the traits on the Deref types, I think it would just be too much information (or we will need to think how to display them). But that's for another time. 😄 Maybe open an issue so we can talk about it later on?

@GuillaumeGomez GuillaumeGomez added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Dec 2, 2021
@GuillaumeGomez
Copy link
Member Author

Updated!

@bors
Copy link
Contributor

bors commented Dec 19, 2021

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

@jsha
Copy link
Contributor

jsha commented May 1, 2022

Earlier, @jyn514 said:

why did you add a warning note to the documentation? It seems like unnecessary clutter, you can already see it's empty just by looking at it.

and @GuillaumeGomez replied:

Because I found that #90866 (comment) made sense. But we can talk more about it if you think it's not useful. (cc @jsha too)

I see a 👍🏻 from @jyn514 on the linked comment so I'm taking that as agreement that the warning for empty impl blocks is a good idea.

Copy link
Contributor

@jsha jsha left a comment

Choose a reason for hiding this comment

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

It's not clear to me why a new kind of matcher in the test infrastructure is needed. Can you explain that more?

src/etc/htmldocck.py Show resolved Hide resolved
src/etc/htmldocck.py Show resolved Hide resolved
src/librustdoc/html/render/mod.rs Outdated Show resolved Hide resolved
src/librustdoc/passes/stripper.rs Show resolved Hide resolved
@GuillaumeGomez
Copy link
Member Author

It's not clear to me why a new kind of matcher in the test infrastructure is needed. Can you explain that more?

It's because the current XPath support is very bad. You can't do: //*[text() = "whatever"] and I need to count elements with a given text. Hence why I added this new case. To fix the XPath handling, I have #89676 open.

@GuillaumeGomez GuillaumeGomez force-pushed the empty-impl-blocks branch 2 times, most recently from 2eebfbd to 4511d24 Compare May 3, 2022 10:25
@GuillaumeGomez
Copy link
Member Author

Updated!

@bors
Copy link
Contributor

bors commented May 28, 2022

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

@GuillaumeGomez
Copy link
Member Author

Updated!

@jsha
Copy link
Contributor

jsha commented Jun 5, 2022

@bors r+ rollup

@GuillaumeGomez
Copy link
Member Author

Weird, didn't work.

@bors=jsha rollup

@GuillaumeGomez
Copy link
Member Author

And I failed the command of course. ^^'

@bors r=jsha rollup

@bors
Copy link
Contributor

bors commented Jun 5, 2022

📌 Commit eca12e3 has been approved by jsha

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 5, 2022
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jun 5, 2022
…=jsha

Add empty impl blocks if they have documentation

Fixes rust-lang#90866.

The update for the test script is needed to count the number of impl blocks we have with only the struct. To be noted that with rust-lang#89676 merged, it wouldn't be needed (I don't know what is the status of it btw. cc `@Mark-Simulacrum).`

It looks like this:

![Screenshot from 2021-11-14 16-51-28](https://user-images.githubusercontent.com/3050060/141689100-e57123c0-bf50-4c42-adf5-d991e169a0e4.png)

cc `@jyn514`
r? `@camelid`
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Jun 6, 2022
…=jsha

Add empty impl blocks if they have documentation

Fixes rust-lang#90866.

The update for the test script is needed to count the number of impl blocks we have with only the struct. To be noted that with rust-lang#89676 merged, it wouldn't be needed (I don't know what is the status of it btw. cc ``@Mark-Simulacrum).``

It looks like this:

![Screenshot from 2021-11-14 16-51-28](https://user-images.githubusercontent.com/3050060/141689100-e57123c0-bf50-4c42-adf5-d991e169a0e4.png)

cc ``@jyn514``
r? ``@camelid``
bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 6, 2022
…askrgr

Rollup of 7 pull requests

Successful merges:

 - rust-lang#90905 (Add empty impl blocks if they have documentation)
 - rust-lang#97683 (Fail gracefully when encountering an HRTB in APIT. )
 - rust-lang#97721 (Do `suggest_await_before_try` with infer variables in self, and clean up binders)
 - rust-lang#97752 (typo: `-Zcodegen-backend=llvm -Cpasses=list` should work now)
 - rust-lang#97759 (Suggest adding `{}` for `'label: non_block_expr`)
 - rust-lang#97764 (use strict provenance APIs)
 - rust-lang#97765 (Restore a test that was intended to test `as` cast to ptr)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 77f0209 into rust-lang:master Jun 6, 2022
@rustbot rustbot added this to the 1.63.0 milestone Jun 6, 2022
@GuillaumeGomez GuillaumeGomez deleted the empty-impl-blocks branch June 6, 2022 11:42
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) S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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 does not show documentation on empty impl blocks
10 participants