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

Prevent feature information to be hidden if it's on the impl directly #79300

Merged
merged 1 commit into from
Nov 22, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/librustdoc/html/static/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2332,12 +2332,18 @@ function defocusSearchBar() {
var dontApplyBlockRule = toggle.parentNode.parentNode.id !== "main";
if (action === "show") {
removeClass(relatedDoc, "fns-now-collapsed");
removeClass(docblock, "hidden-by-usual-hider");
// Stability information is never hidden.
if (hasClass(docblock, "stability") === false) {
removeClass(docblock, "hidden-by-usual-hider");
}
onEachLazy(toggle.childNodes, adjustToggle(false, dontApplyBlockRule));
onEachLazy(relatedDoc.childNodes, implHider(false, dontApplyBlockRule));
} else if (action === "hide") {
addClass(relatedDoc, "fns-now-collapsed");
addClass(docblock, "hidden-by-usual-hider");
// Stability information should be shown even when detailed info is hidden.
if (hasClass(docblock, "stability") === false) {
GuillaumeGomez marked this conversation as resolved.
Show resolved Hide resolved
addClass(docblock, "hidden-by-usual-hider");
}
Comment on lines +2344 to +2346
Copy link
Member

Choose a reason for hiding this comment

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

What does stability have to do with it? IIUC this is hiding it when you have #[unstable] in the source - why?

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh that's interesting in fact! Let me check that. If you're right, we're badly handling a few things in there.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, so "stability" groups a few things, including the feature attributes. Inside it, it is the "portability" class the important one. However, we don't generate items like "deprecated" on implementations as it seems. And even if we did, it'd make sense to print them, and since they're stored inside the stability element... For reference, it looks like this:

<div class="stability">
  <div class="stab portability">This is supported on <strong>non-crate feature <code>traits</code></strong> only.</div>
</div>

And deprecated looks like this:

<div class="stability">
  <div class="stab deprecated"><span class="emoji">👎</span> Deprecated</div>
</div>

And when you merge both:

<div class="stability">
  <div class="stab deprecated"><span class="emoji">👎</span> Deprecated</div>
  <div class="stab portability">This is supported on <strong>non-crate feature <code>traits</code></strong> only.</div>
</div>

So it kinda makes sense, however we should maybe rename the item class. What do you think about renaming it then? However, I'll do it in another PR to prevent mixing too much things.

Copy link
Member

@jyn514 jyn514 Nov 22, 2020

Choose a reason for hiding this comment

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

Printing both, even on implementations, sounds like the right approach to me :) happy to wait for another cleanup PR.

onEachLazy(toggle.childNodes, adjustToggle(true, dontApplyBlockRule));
onEachLazy(relatedDoc.childNodes, implHider(true, dontApplyBlockRule));
}
Expand Down