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

Open impl blocks by default #84552

Merged
merged 6 commits into from
Apr 27, 2021

Conversation

GuillaumeGomez
Copy link
Member

@GuillaumeGomez GuillaumeGomez commented Apr 25, 2021

Fixes #84558.
Part of #84422.

As you can see on https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TyCtxt.html, impl blocks are currently not open by default whereas they should.

I also realized that a test was outdated so I removed it and opened #84550 because it seems like the rustdoc-gui test suite isn't run on CI...

cc @jyn514
r? @jsha

@GuillaumeGomez GuillaumeGomez added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. A-rustdoc-ui Area: Rustdoc UI (generated HTML) A-rustdoc-js Area: Rustdoc's JS front-end labels Apr 25, 2021
@rust-highfive
Copy link
Collaborator

Some changes occurred in HTML/CSS/JS.

cc @GuillaumeGomez

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 25, 2021
// This test ensures that the impl blocks are open by default.
goto: file://|DOC_PATH|/index.html
wait-for: 5000
assert: ("#main > details.implementors-toggle", "open", "")
Copy link
Member

Choose a reason for hiding this comment

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

Can you add a test that intentionally fails to make sure this runs at all?

Copy link
Member Author

Choose a reason for hiding this comment

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

They are not run, that's for sure. Otherwise, it'd have failed a long time ago because of nojs-attr-pos.goml.

Copy link
Member

Choose a reason for hiding this comment

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

Ok. In the meantime, can you run it locally and make sure it passes?

Copy link
Member Author

Choose a reason for hiding this comment

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

This version didn't because I forgot to commit the one with the correct URL (struct.Foo.html and not index.html). But otherwise it works as expected.

Copy link
Member

@jyn514 jyn514 Apr 25, 2021

Choose a reason for hiding this comment

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

Can you fix it to have the correct URL? I don't see the point of adding a test we know will fail.

While you're at it, can you update the other test to pass instead of removing it altogether?

Copy link
Member Author

Choose a reason for hiding this comment

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

Look at my comment below.

Copy link
Member Author

Choose a reason for hiding this comment

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

While you're at it, can you update the other test to pass instead of removing it altogether?

The test which fails checked for attributes toggles. Since they don't have toggles anymore, there is no point of keeping the test.

Copy link
Member

Choose a reason for hiding this comment

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

The test which fails checked for attributes toggles. Since they don't have toggles anymore, there is no point of keeping the test.

Can you instead test that it doesn't have toggles?

Copy link
Member Author

Choose a reason for hiding this comment

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

Would it be useful to check that something was removed? For example, if we put back toggles on attributes with a different DOM, the test would still be happy. Which is why it's simpler to enforce what exists over what doesn't. (Not sure if that makes sense said like this ><)

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with @GuillaumeGomez. When removing "code that does X," it's often tempting to add a test for "doesn't do X anymore." But the problem is there are a zillion ways it could wind up doing X again, and it's impossible to cover all of them (or even a reasonable fraction). It winds up adding to the test running time, and the burden of maintaining tests, without a corresponding benefit.

@GuillaumeGomez
Copy link
Member Author

Also, I need to make some improvements on the test I added, so please don't r+ right now. :)

@GuillaumeGomez
Copy link
Member Author

I also added a fix for the expansion of the "blocks" based on the URL hash.

Comment on lines 1432 to 1433
} else if (e.tagName === "DETAILS") {
e.open = true;
Copy link
Contributor

Choose a reason for hiding this comment

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

As I understand it, we hide things during load because we're going to manipulate their DOM, and DOM manipulation on hidden things goes faster. The main DOM manipulation is adding the [+] toggles. When we fully switch over to <details> we won't need to hide portions of the DOM during load anymore.

I'd like to start doing that as we go. Rather than opening the <details> tags on load, we should set them to the global default in our generated HTML, and on load we should hide or show them according to settings.

Copy link
Member Author

Choose a reason for hiding this comment

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

Not all details should be opened by details. For example the traits implementations blocks.

Copy link
Member Author

Choose a reason for hiding this comment

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

Or did you mean that we should generate the <details> with "open" directly? Still: we will need this JS in any case for when we press the global toggle.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, I mean that for default-shown sections we should generate <details open>.

I agree we need JS to make <details> respond to the global toggle, but I believe that's already in place. And it wouldn't be in this chunk of code, which executes on load rather than in response to the global toggle.

Copy link
Member Author

Choose a reason for hiding this comment

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

You're right, I'll modify it then.

@camelid
Copy link
Member

camelid commented Apr 25, 2021

I just opened an issue about this (#84558), but it looks like this should fix it! Do you want to mark this PR as fixing that issue?

@GuillaumeGomez
Copy link
Member Author

@camelid I updated the PR message. :)

@GuillaumeGomez
Copy link
Member Author

@jsha Updated!

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.

@bors r+

@GuillaumeGomez
Copy link
Member Author

Not sure it works as review comment.

@bors: r=jsha

@bors
Copy link
Contributor

bors commented Apr 26, 2021

📌 Commit 6c8969c 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 Apr 26, 2021
@bors
Copy link
Contributor

bors commented Apr 27, 2021

⌛ Testing commit 6c8969c with merge 6eb956f...

@bors
Copy link
Contributor

bors commented Apr 27, 2021

☀️ Test successful - checks-actions
Approved by: jsha
Pushing 6eb956f to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Apr 27, 2021
@bors bors merged commit 6eb956f into rust-lang:master Apr 27, 2021
@rustbot rustbot added this to the 1.53.0 milestone Apr 27, 2021
@GuillaumeGomez GuillaumeGomez deleted the open-impl-blocks-by-default branch April 27, 2021 08:30
@lf-
Copy link
Contributor

lf- commented May 3, 2021

For anyone wondering what's going on with the nightly preventing getting this patch, that's tracked here:
#84538

@GuillaumeGomez
Copy link
Member Author

You can get the last rustdoc version if you remove rustfmt from your components (not ideal but it works).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rustdoc-js Area: Rustdoc's JS front-end A-rustdoc-ui Area: Rustdoc UI (generated HTML) merged-by-bors This PR was explicitly merged by bors. 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: Box docs collapse implementations by default on nightly
8 participants