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 three-column layout for large desktops #120818
base: master
Are you sure you want to change the base?
Conversation
This commit adds the headers for the top level documentation to rustdoc's existing table of contents, along with associated items. It only show two levels of headers. Going further would require the sidebar to be wider, and that seems unnecessary (the crates that have manually-built TOCs usually don't need deeply nested headers).
This comment has been minimized.
This comment has been minimized.
ba77713
to
c0f7d2a
Compare
This comment has been minimized.
This comment has been minimized.
c0f7d2a
to
cf5d33a
Compare
This comment has been minimized.
This comment has been minimized.
This commit adds a floating TOC box to the right, leaving the sibling/module/crate navigation on the left. This kicks in at a size a little below 1920x1080, where desktops with very wide monitors are: it's also around the point where the content area can be full width while allowing two sidebars. It only kicks in if the browser supports grid layouts, but that should be most of them, and we can't get rid of the two-column layout anyway, since it's the layout you get on something like a portrait iPad. This design, where it can be used, is meant to clearly split up the table of contents and the site navigation, so the right side floating box has the same color as the page while the left sidebar does not. It also pushes it down further, so that it's not as high as the search bar, though that's a bit more subtle than the color.
cf5d33a
to
b222f02
Compare
The UI is very weird, it adds new lines in the left sidebar and a floating menu on the right. Wouldn't it be possible to not make it stand out as much? Like just having a border on the left and making it take the "full space" on the right and top? |
I'm not sure what to add that I didn't already mention in the Rationale and Alternatives section:
The line in the left sidebar could be removed, but is mostly meant to work like the one in the Source Files viewer, since its scroll behavior is the same. |
Isn't it possible to "cheat" in order to make it look like a plain sidebar while keeping it in the same scroll interactions? |
You could hide the scollbar of the sidebar and then manually scroll it via javascript to keep it in sync with the section the main page is showing. This would only be necessary if the TOC is longer than a screen height anyway. |
Let's not. The content of the TOC can be part of the main page (so sharing the same scroll). |
Are you thinking of having it work like this? Screencast.from.2024-02-12.10-31-32.webmI'm not sure that's useful. The page is so much longer than the TOC. If you click anything in the TOC, it's basically guaranteed to disappear, and you have to scroll back to the top to get to it.
That doesn't seem unusual, since trait implementations and methods are listed in there. That's not a SpidersGeorg type. Those are all very basic, normall error-ish trait implementations, and there's enough of them to fill the page. |
Yeah I think vertical menus that only show the name and nothing else just take up way too much space for the limited value they provide. They just don't strike the right balance imo. But if one doesn't already know what one is looking for then a summary that's more verbose than just the name but more concise than the full docs would help. For an alternative design look at javadocs. For interfaces they have a horizontal list: https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/util/Map.html I'm not saying javadocs strike the perfect balance on everything, but imo in at least those two aspects they're doing better than rustdoc |
I haven't reviewed this yet because I'm assuming this is effectively
S-waiting-on-team
|
☔ The latest upstream changes (presumably #123725) made this pull request unmergeable. Please resolve the merge conflicts. |
CC @the8472 @GuillaumeGomez
Dependent on #120736
Summary
On very large displays, use a three-column layout, splitting up the TOC and ModNav.
Preview
Motivation
Multiple people have asked for a doc layout that makes better use of the larger screens that Rust development itself is usually done on.
More importantly, people have asked for the navigation aids that rustdoc already has, but buries underneath the list of Methods and such. This is a side-effect of mixing together lateral navigation with the table of contents.
It's not quite this simple, unfortunately. Because ModNav is loaded by JS, it populates after the TOC, which means if we put it on top we get a content jump. It cannot go above anything else.
The three-column layout avoids this no-no, and also does a better job of communicating the information hierarchy.
The module navigation is grey in an otherwise-white page, but the floating TOC is not. It's also paired with the logo, while the TOC is paired with the page's name. These are both meant to communicate the difference between the TOC and the ModNav.
By exposing the ModNav more easily, the You Are Here highlighted item name is more commonly visible. Look at the left sidebar in the screenshot.
That tabbed-out
HashMap
struct name under theStructs
header underIn std::collections
is great.Also, this is how MDN does it. Presumably, they know what they're doing.
Drawbacks
This is, really, a pretty serious backslide on the decluttering. If someone really needs to get rid of these things, they can. Click the Settings button, the hide the TOC. But that's probably not a great first impression.
Rationale and alternatives
Why is the TOC in a box?
It's a scrollbar thing.
An earlier version of this feature divided the browser into three equally-tall sections. It's the way I wanted the feature to work. But, in doing so, I would have to pick between two bad options for the main document's scrolling behavior:
body
tag. Doing this breaks a bunch of built-in browser behaviors.To side-step this problem, the box helps telegraph what's actually going on. The one inside the box scrolls the box that contains it, while the one outside the box scrolls the page.
Why isn't there a configuration switch to force the one-sidebar view?
Does anybody want this? There's already an option to turn the TOC off entirely, if it's distracting.
Why isn't there a way to resize the TOC box?
It fills all available space. What you'd get would be a way to resize the content area.
Resizing the content area, while it sounds nice, would require a bunch of layout optimization, because right now, resizing it requires too much layout work and is very very slow.
Prior art
This layout is very similar to MDN.
Unresolved questions