-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
[rustdoc] Add a marker to tell users that there are hidden (deprecated) items in the search results #151559
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] Add a marker to tell users that there are hidden (deprecated) items in the search results #151559
Conversation
|
Some changes occurred in HTML/CSS/JS. |
| if (active) { | ||
| const previous = active.previousElementSibling; | ||
| if (previous) { | ||
| if (previous && previous.className !== DEPRECATED_COUNT_SELECTOR) { |
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.
When using the "up" arrow to go back from the search results to the search input, we need to skip the "marker".
Interestingly enough, we did it nicely the other way (going from search input to search results with down arrow), the selector targets directly the first item.
| .deprecated-count { | ||
| display: none; | ||
| } | ||
| .hide-deprecated-items .deprecated-count:not(:empty) { |
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.
The :not(:empty) is a little trick I thought about to not have to add conditions in JS to hide/show the marker. It's entirely based on whether it has content and if the setting is enabled. Quite proud of that one for some reason. 😆
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 trick should probably have a comment explaining it.
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 can share my pride with the rest of the world. I approve this idea! =D
This comment has been minimized.
This comment has been minimized.
…n the search results
…precated item marker"
e436693 to
0e240d3
Compare
|
Looks pretty good, just would like to see a comment explaining how those two rules controlling the display will interact (despite being core to the concept of css, css's specificity rules are rarely taken advantage of, and not super widely understood). |
|
I added a comment. Do you see another CSS rule which might need explanations? |
|
Hold on, can't you put the Actually I'm talking myself out of it, the current way has better graceful degradation on old browsers that don't support Maybe just put a comment to the effect of "this will be overridden if there are any deprecated items in the search results" next to the I haven't noticed anything else that could use a comment in this file, but I haven't looked very carefully either. |
|
Hum, that seems like a bit too precise comment there no? It's writing in plain text what this is doing. |
|
My logic is that css specificity is not widely understood, and if you're not aware of its existence, it wouldn't be obvious that one rule would override the other. This is just my intuition and I have no data to back it up (I don't know if such data exists), but also this is the Rust project, and most contributors will be Rust programmers, not web developers (and many web developers will use tailwind or similar instead of idiomatic css)... Even just having "css specificity" somewhere in the existing comment would leave a breadcrumb for someone to follow if they were confused. Ultimately, it's a pretty small thing, and I'm not going to block the PR on it if you don't think it's worth it. |
|
Hum. What I suggest then is to send a follow-up as I'm really having issues to see what you have in mind. Maybe I'm simply not understanding what you mean. Looking forward to the follow-up then and thanks for the review! @bors r=lolbinarycat rollup |
…cated-search, r=lolbinarycat [rustdoc] Add a marker to tell users that there are hidden (deprecated) items in the search results Someone on mastodon rightfully pointed out that having a visual indication that some search results were hidden would be a good idea if the "hide deprecated items" setting is enabled. In particular if no results are displayed. It looks like this: <img width="861" height="228" alt="Screenshot From 2026-01-24 00-26-33" src="https://github.com/user-attachments/assets/93aeef11-a550-47dc-9c78-219ea4fd822c" /> r? @lolbinarycat
Rollup of 8 pull requests Successful merges: - #150474 (Tidy: detect ui tests subdirectory changes so `tests/ui/README.md` stays in sync) - #150572 (Improve move error diagnostic for `AsyncFn` closures) - #151596 (Fix -Zmir-enable-passes to detect unregistered enum names in declare_passes macro) - #151802 (Make `QueryDispatcher::Qcx` an associated type) - #151559 ([rustdoc] Add a marker to tell users that there are hidden (deprecated) items in the search results) - #151665 (Fix contrast ratio for `Since` element in rustodoc dark theme) - #151798 (Update `askama` to `0.15.3`) - #151800 (Subscribe myself to translation diagnostics)
Rollup of 12 pull requests Successful merges: - #150474 (Tidy: detect ui tests subdirectory changes so `tests/ui/README.md` stays in sync) - #150572 (Improve move error diagnostic for `AsyncFn` closures) - #151596 (Fix -Zmir-enable-passes to detect unregistered enum names in declare_passes macro) - #151802 (Make `QueryDispatcher::Qcx` an associated type) - #149110 (Implement `cast_slice` for raw pointer types) - #151559 ([rustdoc] Add a marker to tell users that there are hidden (deprecated) items in the search results) - #151665 (Fix contrast ratio for `Since` element in rustdoc dark theme) - #151785 (Stabilize feature(push_mut)) - #151798 (Update `askama` to `0.15.3`) - #151800 (Subscribe myself to translation diagnostics) - #151804 (Document, sort, and tweak spellcheck entries in `typos.toml`) - #151805 (Fix grammar in `env::current_exe()#Security`)
Rollup merge of #151559 - GuillaumeGomez:marker-hidden-deprecated-search, r=lolbinarycat [rustdoc] Add a marker to tell users that there are hidden (deprecated) items in the search results Someone on mastodon rightfully pointed out that having a visual indication that some search results were hidden would be a good idea if the "hide deprecated items" setting is enabled. In particular if no results are displayed. It looks like this: <img width="861" height="228" alt="Screenshot From 2026-01-24 00-26-33" src="https://github.com/user-attachments/assets/93aeef11-a550-47dc-9c78-219ea4fd822c" /> r? @lolbinarycat
Someone on mastodon rightfully pointed out that having a visual indication that some search results were hidden would be a good idea if the "hide deprecated items" setting is enabled. In particular if no results are displayed.
It looks like this:
r? @lolbinarycat