rustdoc: sidebar items not shown on crate page on docs.rs #99121
Labels
A-rustdoc-ui
Area: Rustdoc UI (generated HTML)
T-rustdoc
Relevant to the rustdoc team, which will review and decide on the PR/issue.
On docs.rs pages, until recently, the crate page (the top of the hierarchy for a crate) would show structs, enums, traits, etc in the sidebar, in addition to the page contents:
https://docs.rs/rustls/0.20.6/rustls/index.html
In more recently built pages, it doesn't:
I believe this is in part due to my refactoring in #98124 - I believed (based on behavior for library/std) that crate pages were not intended to show structs, etc in the sidebar.
However, it gets more complicated. The code in main.js shows that it's not supposed to display those "sidebar items" on module pages. Crate pages are considered module pages (they have
class="crate mod ..."
).rust/src/librustdoc/html/static/js/main.js
Lines 482 to 483 in 29554c0
So why does docs.rs show the sidebar items on a crate page? The check above operates on
document.body
, but docs.rs rewrites the HTML so what used to be the body tag becomes<div id="rustdoc_body_wrapper" class="...">
. So the class is still present from CSS' perspective but it's on the wrong div so the check passes. On doc.rs, nothing is considered a module page so every page gets the full list of sidebar items. The check is buggy; or another way of thinking about it is that the interface between rustdoc and docs.rs is not clearly defined. A better way to do this particular check might be to use rustdoc-vars instead of piggybacking on CSS semantics.I think we should fix the most recent change, so docs.rs gets sidebar items on crate and module pages again, and then discuss what behavior we actually intend.
Some context: here's the PR from about a year ago where we tried to suppress showing structs etc on module pages: https://github.com/rust-lang/rust/pull/84834/files#r625337543
The text was updated successfully, but these errors were encountered: