about summary refs log tree commit diff
path: root/src/librustdoc/html/static/css/rustdoc.css
AgeCommit message (Collapse)AuthorLines
2024-04-17Fix copy-path buttonGuillaume Gomez-7/+10
2024-04-09rustdoc: load icons from css instead of inlineMichael Howell-2/+18
This cuts the HTML overhead for a page by about 1KiB, significantly reducing the overall size of the docs bundle.
2024-04-03Default to light theme is JS is enabled but not workingGuillaume Gomez-1/+7
2024-02-18Rollup merge of #120526 - GuillaumeGomez:mobile-long-crate-name, r=notriddleLeón Orell Valerian Liehr-6/+1
rustdoc: Correctly handle long crate names on mobile Fixes https://github.com/rust-lang/rust/issues/120471. It now renders like this: ![image](https://github.com/rust-lang/rust/assets/3050060/065b4b8b-ba55-4163-a928-8d7bf735c111) r? `@notriddle`
2024-01-31rustdoc: Correctly handle long crate names on mobileGuillaume Gomez-6/+1
2024-01-29Improve display of crate name when hoveredGuillaume Gomez-4/+2
2024-01-19Rollup merge of #117662 - GuillaumeGomez:links-in-headings, r=notriddleMatthias Krüger-1/+20
[rustdoc] Allows links in headings Reopening of https://github.com/rust-lang/rust/pull/94360. # Explanations Rustdoc currently doesn't follow the markdown spec on headings: we don't allow links in them. So instead of having headings linking to themselves, this PR generates an anchor on the left side like this: ![image](https://github.com/rust-lang/rust/assets/3050060/a118a7e9-5ef8-4d07-914f-46defc3245c3) <details> <summary>previous version</summary> ![image](https://github.com/rust-lang/rust/assets/3050060/c34fa844-9cd4-47dc-bb51-b37f5f66afee) </details> Having the anchor always displayed allows for mobile devices users to be able to have a link to the anchor. The different color used for the anchor itself is the same as links so people notice when looking at it that they can click on it. You can test it [here](https://rustdoc.crud.net/imperio/links-in-headings/std/index.html). cc `@camelid` r? `@notriddle`
2024-01-01use css variable for z-index of the sidebarLukas Markeffsky-5/+5
and calculate the z-indices of things that go over the sidebar
2023-12-31rustdoc ui: adjust tooltip z-index to be above sidebarLukas Markeffsky-1/+1
2023-12-31Auto merge of #119066 - notriddle:notriddle/sidebar-source-redesign, ↵bors-93/+75
r=GuillaumeGomez rustdoc: clean up source sidebar hide button This is a redesign of the feature, with parts pulled from https://github.com/rust-lang/rust/pull/119049 but with a button that looks more like a button and matches the one used on other sidebar pages. Preview: * http://notriddle.com/rustdoc-html-demo-8/source-sidebar-resize/src/std/lib.rs.html * http://notriddle.com/rustdoc-html-demo-8/source-sidebar-resize/std/index.html | | Before | After | |--|--|--| | Closed | ![image](https://github.com/rust-lang/rust/assets/1593513/092bed75-79c3-412f-8e7b-557f30dfb1e3) | ![image](https://github.com/rust-lang/rust/assets/1593513/b68e1ee9-9aef-484d-a5b1-2fd29c9d72ea) | Open | ![image](https://github.com/rust-lang/rust/assets/1593513/95cf9545-25b1-48ec-820b-02e1aec99839) | ![image](https://github.com/rust-lang/rust/assets/1593513/923532f6-59e0-4d7c-9976-21699c30d42e) | Mobile Closed | ![image](https://github.com/rust-lang/rust/assets/1593513/9bc00cc5-937c-4120-94be-94c7cb6d5297) | ![image](https://github.com/rust-lang/rust/assets/1593513/76a744d8-aac2-46fe-abb9-3b34e2d3ccaa) | Mobile Open | ![image](https://github.com/rust-lang/rust/assets/1593513/d19a94fe-47b1-462d-a280-44fc215b9b72) | ![image](https://github.com/rust-lang/rust/assets/1593513/2b2e3dec-b610-4b12-8a72-35b86359ba45)
2023-12-24Fix display of warning block if it is first element of the top doc blockGuillaume Gomez-0/+3
2023-12-19Fix corner cases when dealing with mobile modeMichael Howell-6/+9
2023-12-18Use folder icon instead of hamburger and sidebarMichael Howell-17/+26
2023-12-18Add border bottom for source sidebar title areaMichael Howell-8/+3
2023-12-18Stop using the trigram of heaven as a hamburger buttonMichael Howell-7/+20
It doesn't look quite right, because the lines are too far apart, and it's not going to be announced by screenreaders as a menu button, since that's not what the symbol means. This adds a real tooltip and uses a better drawing of the icon.
2023-12-18Add back the columnMichael Howell-18/+15
2023-12-17rustdoc: clean up source sidebar hide buttonMichael Howell-87/+52
This is a redesign of the feature, with parts pulled from https://github.com/rust-lang/rust/pull/119049 but with a button that looks more like a button and matches the one used on other sidebar pages.
2023-12-15Rollup merge of #115660 - notriddle:notriddle/sidebar-resize, r=GuillaumeGomezGuillaume Gomez-9/+162
rustdoc: allow resizing the sidebar / hiding the top bar Fixes #97306 Preview: http://notriddle.com/rustdoc-html-demo-4/sidebar-resize/std/index.html ![image](https://github.com/rust-lang/rust/assets/1593513/a2f40ea2-0436-4e44-99e8-d160dab2a680) ## Summary This feature adds: 1. A checkbox to the Settings popover to hide the persistent navigation bar (the sidebar on large viewports and the top bar on small ones). 2. On large viewports, it adds a resize handle to the persistent sidebar. Resizing it into nothing is equivalent to turning off the persistent navigation bar checkbox in Settings. 3. If the navigation bar is hidden, a toolbar button to the left of the search appears. Clicking it brings the navigation bar back. ## Motivation While "mobile mode" is definitely a good default, it's not the only reason people have wanted to hide the sidebar: * Some people use tiling window managers, and don't like rustdoc's current breakpoints. Changing the breakpoints might help with that, but there's no perfect solution, because there's a gap between "huge screen" and "smartphone" where reasonable people can disagree about whether it makes sense for the sidebar to be on-screen. https://github.com/rust-lang/rust/issues/97306 * Some people ask for ways to reduce on-screen clutter because it makes it easier to focus. There's not a media query for that (and if there was, privacy-conscious users would turn it off). https://github.com/rust-lang/rust/issues/59829 This feature is designed to avoid these problems. Resizing the sidebar especially helps, because it provides a way to hide the sidebar without adding a new top-level button (which would add clutter), and it provides a way to make rustdoc play nicer in complex, custom screen layouts. ## Guide and Reference-level explanation On a desktop or laptop with a mouse, resize the sidebar by dragging its right edge. On any browser, including mobile phones, the sticky top bar or side bar can be hidden from the Settings area (the button with the cog wheel, next to the search bar). When it's hidden, a convenient button will appear on the search bar's left. ## Drawbacks This adds more JavaScript code to the render blocking area. ## Rationale and alternatives The most obvious way to allow people to hide the sidebar would have been to let them "manually enter mobile mode." The upside is that it's a feature we already have. The downside is that it's actually really hard to come up with a terse description. Is it: * A Setting that forces desktop viewers to always have the mobile-style top bar? If so, how do we label it? Should it be visible on mobile, and, if so, does it just not do anything? * A persistent hide/show sidebar button, present on desktop, just like on mobile? That's clutter that I'd like to avoid. ## Prior art * The new file browser in GitHub uses a similar divider with a mouse-over indicator * mdBook and macOS Finder both allow you to resize the sidebar to nothing as a gesture to hide it * https://www.nngroup.com/articles/drag-drop/ ## Future possibilities https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/Table.20of.20contents proposes a new, second sidebar (a table of contents). How should it fit in with this feature? Should it be resizeable? Hideable? Can it be accessed on mobile?
2023-12-07Fix display of features in rustdocGuillaume Gomez-9/+12
2023-12-05Make headings anchor hidden by default and show on hoverGuillaume Gomez-3/+19
2023-12-05Rework doc blocks headings by not turning them into links anymore and ↵Guillaume Gomez-0/+3
putting an anchor to their left side
2023-11-30rustdoc: `div.where` instead of fmt-newline classMichael Howell-5/+2
This is about equally readable, a lot more terse, and stops special-casing functions and methods. ```console $ du -hs doc-old/ doc-new/ 671M doc-old/ 670M doc-new/ ```
2023-11-29rustdoc: remove small from `small-section-header`Michael Howell-5/+5
There's no such thing as a big section header, so I don't know why the name was used.
2023-10-23Rollup merge of #105666 - notriddle:notriddle/stab-baseline, r=GuillaumeGomezMatthias Krüger-0/+1
rustdoc: align stability badge to baseline instead of bottom | desc | img | |------|-----| | before | ![image](https://user-images.githubusercontent.com/1593513/207412598-3a6468ca-a169-4810-a689-4797688385df.png) | | | | | after | ![image](https://user-images.githubusercontent.com/1593513/207412720-b120269a-48a3-40e9-a9b0-6769bb05e104.png) | Preview: http://notriddle.com/notriddle-rustdoc-demos/stab-baseline/test_dingus/index.html Based on comment from https://github.com/rust-lang/rust/pull/105509#discussion_r1044816673 r? ``@joshtriplett``
2023-10-11rustdoc: avoid whole page layout on each frameMichael Howell-4/+14
This makes two changes, based on experimenting with different browsers: - It debounces resizing the body text. This improves behavior on huge pages like struct.Vec.html, because it doesn't have to do layout. - It does the sidebar width updates directly on the sidebar instead of doing it on the `<HTML>` element. Doing it on `<HTML>` causes it to recalculate CSS for the entire document, also causing layout jank.
2023-10-11rustdoc: bundle sidebar button icon into CSSMichael Howell-1/+22
This removes an HTTP request from the loading pipeline, and allows it to be changed with a media query.
2023-10-11rustdoc: enforce BODY_MIN constraint on sidebar resizeMichael Howell-7/+12
2023-10-11rustdoc: allow resizing the sidebarMichael Howell-7/+124
2023-10-08Clean up subversion layoutMichael Howell-0/+5
2023-10-08rustdoc: clean up the In [name] up-pointerMichael Howell-1/+1
This commit makes three changes for consistency and readability: - It shows the sibling navigation on module pages. It's weird that it didn't work before, and is inconsistent with everything else (even Crates have sibling navigation with other Crates). - It hides the "In [parent]" header if it's the same as the current crate, and if there's no other header between them. We need to keep it on modules and types, since they have their own header and data between them, and we don't want to show siblings under a header implying that they're children. - It adds a margin to deal with the headers butting directly into the branding lockup.
2023-10-08rustdoc: align crate name with search barMichael Howell-5/+27
Based on PR feedback.
2023-10-08rustdoc: remove rust logo from non-Rust cratesMichael Howell-2/+3
2023-10-08rustdoc: clean up the layout for annotated version numbersMichael Howell-0/+1
This should result in a layout for the actual standard library, when built on CI, that looks like this: _____ / \ std | R | 1.74.0-nightly \_____/ (203c57dbe 2023-09-17) Having the whole version as one string caused it to flex wrap, because the sidebar isn't wide enough to fit the whole thing.
2023-10-08rustdoc: show crate name beside small logoMichael Howell-12/+45
This commit changes the layout to something a bit less "look at my logo!!!111" gigantic, and makes it clearer where clicking the logo will actually take you. It also means the crate name is persistently at the top of the sidebar, even when in a sub-item page, and clicking that name takes you back to the root. | | Short crate name | Long crate name | |---------|------------------|-----------------| | Root | ![short-root] | ![long-root] | Subpage | ![short-subpage] | ![long-subpage] [short-root]: https://github.com/rust-lang/rust/assets/1593513/fe2ce102-d4b8-44e6-9f7b-68636a907f56 [short-subpage]: https://github.com/rust-lang/rust/assets/1593513/29501663-56c0-4151-b7de-d2637e167125 [long-root]: https://github.com/rust-lang/rust/assets/1593513/f6a385c0-b4c5-4a9c-954b-21b38de4192f [long-subpage]: https://github.com/rust-lang/rust/assets/1593513/97ec47b4-61bf-4ebe-b461-0d2187b8c6ca https://notriddle.com/rustdoc-html-demo-4/logo-lockup/image/index.html https://notriddle.com/rustdoc-html-demo-4/logo-lockup/crossbeam_channel/index.html https://notriddle.com/rustdoc-html-demo-4/logo-lockup/adler/struct.Adler32.html https://notriddle.com/rustdoc-html-demo-4/logo-lockup/crossbeam_channel/struct.Sender.html This improves visual information density (the construct with the logo and crate name is *shorter* than the logo on its own, because it's not square) and navigation clarity (we can now see what clicking the Rust logo does, specifically). Compare this with the layout at [Phoenix's Hexdocs] (which is what this proposal is closely based on), the old proposal on [Internals Discourse] (which always says "Rust standard library" in the sidebar, but doesn't do the side-by-side layout). [Phoenix's Hexdocs]: https://hexdocs.pm/phoenix/1.7.7/overview.html [Internals Discourse]: https://internals.rust-lang.org/t/poc-of-a-new-design-for-the-generated-rustdoc/11018 In newer versions of rustdoc, the crate name and version are always shown in the sidebar, even in subpages. Clicking the crate name does the same thing clicking the logo always did: return you to the crate root. While this actually takes up less screen real estate than the old layout on desktop, it takes up more HTML. It's also a bit more visually complex. I could do what the Internals POC did and keep the vertically stacked layout all the time, instead of doing a horizontal stack where possible. It would take up more screen real estate, though. This design is lifted almost verbatim from Hexdocs. It seems to work for them. [`opentelemetry_process_propagator`], for example, has a long application name. [`opentelemetry_process_propagator`]: https://hexdocs.pm/opentelemetry_process_propagator/OpentelemetryProcessPropagator.html Has anyone written the rationale on why the Rust logo shows up on projects that aren't the standard library? If we turned it off on non-standard crates by default, it would line wrap crate names a lot less often. Or maybe we should encourage crate authors to include their own logo more often? It certainly helps give people a better sense of "place." I'm not sure of anything that directly follows up this one. Plenty of other changes could be made to improve the layout, like * coming up with a less cluttered way to do disclosure (there's a lot of `[-]` on the page) * doing a better job of separating lateral navigation (vec::Vec links to vec::IntoIter) and the table of contents (vec::Vec links to vec::Vec::new) * giving readers more control of how much rustdoc hows them, and giving doc authors more control of how much it generates * better search that reduces the need to browse But those are mostly orthogonal, not future possibilities unlocked by this change.
2023-09-19rustdoc: add test cases, and fix, search tabsMichael Howell-4/+8
2023-09-15rustdoc: merge theme css into rustdoc.cssMichael Howell-0/+410
Based on https://github.com/rust-lang/rust/pull/115812#issuecomment-1717960119 Having them in separate files used to make more sense, before the migration to CSS variables made the theme files as small as they are nowadays. This is already how docs.rs and mdBook do it.
2023-09-13Merge settings.css into rustdoc.cssGuillaume Gomez-0/+64
2023-08-14Add warning block support in rustdocGuillaume Gomez-3/+23
2023-07-31rustdoc: align stability badge to baseline instead of bottomMichael Howell-0/+1
r? @joshtripplet
2023-07-20Remove adjustments that used to be necessary for search's crate selector ↵Frank Steffahn-9/+0
appearance (padding) to look identical on Firefox. New versions of Firefox appear to have changed behavior to agree with Chrome.
2023-07-18Fix display of aliases in rustdoc search resultsGuillaume Gomez-1/+4
2023-07-14rustdoc: use `src` consistently over `source` in JavaScriptMichael Howell-1/+1
Since the directory that contains source files is called `src`, it makes sense to name the scripts that way, too.
2023-07-14rustdoc: use `src` consistently over `source` in codeMichael Howell-29/+29
The CSS uses an inconsistent mix of both. This commit switches it to always use `src`.
2023-07-03Fix display of long inline cfg labelsGuillaume Gomez-3/+3
2023-06-28Fix display of long items in search resultsGuillaume Gomez-6/+24
2023-06-23Reduce typename width to 6.25remNoah Lev-1/+1
This makes "existential type" look slightly cramped (though still readable), but it makes all other typenames look better. Existential types are currently very rare, and we can always tweak this later if necessary.
2023-06-23Make typenames a bit wider to support "existential type"Noah Lev-1/+1
2023-06-22Align search results horizontally for easy scanningNoah Lev-0/+2
The recent PR #110688 added info about an item's kind before its name in search results. However, because the kind and name are inline with no alignment, it's now hard to visually scan downward through the search results, looking at item names. This PR fixes that by horizontally aligning search results such that there are now two columns of information.
2023-06-19rustdoc: js: change color and reduce size of typename in search resultAlexis (Poliorcetics) Bourget-0/+4
2023-06-03Move type name directly into the same DOM elementGuillaume Gomez-13/+0