-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Migrate trait and impl blocks' toggles into #84754
Conversation
Some changes occurred in HTML/CSS themes. Some changes occurred in HTML/CSS/JS. A change occurred in the Ayu theme. cc @Cldfire |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you need to add something around main.js line 1178, where we have showLargeItem
/ showImplementor
, to make these toggles respond to their corresponding settings.
Completely forgot about the settings, you're absolutely right, great catch! |
@@ -1810,3 +1833,14 @@ details.rustdoc-toggle[open] > summary::before { | |||
content: "[−]"; | |||
display: inline; | |||
} | |||
|
|||
details.undocumented > summary::before { | |||
content: "[+] Show hidden undocumented items"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting approach! This is different from how we've done the other toggles that have descriptions (hide-me
), but it makes sense to do it this way, since this particular toggle has a description both in its open and in its closed state. 👍🏻
a6cb17d
to
65a3e25
Compare
Fixed the settings application and applied your comments. Please tell me what you think of how I applied your closure idea. |
if (hideMethodDocs === true) { | ||
onEachLazy(document.getElementsByClassName("method"), function(e) { | ||
var toggle = e.parentNode; | ||
if (toggle) { | ||
toggle = toggle.parentNode; | ||
} | ||
} | ||
}; | ||
|
||
var funcImpl = function(e) { | ||
var next = e.nextElementSibling; | ||
if (next && hasClass(next, "item-info")) { | ||
next = next.nextElementSibling; | ||
} | ||
if (next && hasClass(next, "docblock")) { | ||
next = next.nextElementSibling; | ||
} | ||
if (!next) { | ||
return; | ||
} | ||
}; | ||
if (toggle && toggle.tagName === "DETAILS") { | ||
toggle.open = false; | ||
} | ||
}); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would fit in more nicely as part of the onEachLazy(document.getElementsByTagName("details"), function (e) {
loop below. That sections finds all the appropriate details tags and opens them if needed, which means we don't have to make the JS dependent on a very specific DOM structure by looking for a grandparent DETAILS
node. Since methods are default-open, we would add a clause to say:
var hideMethod = hideMethods && hasClass(e, "methods-toggle");
if (hideMethod) {
e.open = false;
}
Note that we also need the class methods-toggle
in the emitted HTML.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I'm shared here: I'm not a big fan of the idea to grow the HTML, but that would indeed improve the JS. So after giving it some thought, here is what I suggest: we will move the "method"/"function"/etc classes from the h3
/h4
into the grand-parent details. However, it seems to be out of context here, so if you're fine with it: I'll open an issue so that it can be done later and not be forgotten.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree HTML size is important, but I don't think we should economize by omitted classes when they are needed. That makes the CSS and JS more complex and harder to reason about. I'd rather look to bigger potential wins first - like deduplicating the tooltips subdocuments.
There's also an argument from consistency: We already put appropriate classes on the <details>
tags we've added so far. It would be odd to economize on this one particular item type and not the others.
At any rate, I don't want to hold up the whole PR for the next week; I'm find landing this piece as-is and we can discuss more when I'm back.
65a3e25
to
7b275da
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r=me with the sense of the toggled
variable inverted.
if (hideMethodDocs === true) { | ||
onEachLazy(document.getElementsByClassName("method"), function(e) { | ||
var toggle = e.parentNode; | ||
if (toggle) { | ||
toggle = toggle.parentNode; | ||
} | ||
} | ||
}; | ||
|
||
var funcImpl = function(e) { | ||
var next = e.nextElementSibling; | ||
if (next && hasClass(next, "item-info")) { | ||
next = next.nextElementSibling; | ||
} | ||
if (next && hasClass(next, "docblock")) { | ||
next = next.nextElementSibling; | ||
} | ||
if (!next) { | ||
return; | ||
} | ||
}; | ||
if (toggle && toggle.tagName === "DETAILS") { | ||
toggle.open = false; | ||
} | ||
}); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree HTML size is important, but I don't think we should economize by omitted classes when they are needed. That makes the CSS and JS more complex and harder to reason about. I'd rather look to bigger potential wins first - like deduplicating the tooltips subdocuments.
There's also an argument from consistency: We already put appropriate classes on the <details>
tags we've added so far. It would be odd to economize on this one particular item type and not the others.
At any rate, I don't want to hold up the whole PR for the next week; I'm find landing this piece as-is and we can discuss more when I'm back.
7b275da
to
0d52eb9
Compare
📌 Commit 0d52eb9 has been approved by |
☀️ Test successful - checks-actions |
Part of #83332
After this, I think only the "global" doc comment will be used as JS toggle. Once this PR is merged, I check what remains and remove them.
There is one change that this PR brings:
As you can see, I had to move the "undocumented" items below, they're not mixed with the others anymore. Unfortunately, I don't see a way to keep the current appearance without JS. As a a reminder, currently it looks like this:
r? @jsha