about summary refs log tree commit diff
path: root/src/librustdoc/html/static/rustdoc.css
AgeCommit message (Collapse)AuthorLines
2021-05-14Unify toggle rules on smaller resolutionsGuillaume Gomez-6/+3
2021-05-14Move @media rules at the end so they override the other rulesGuillaume Gomez-193/+195
2021-05-14Fix toggle position on mobileGuillaume Gomez-1/+8
2021-05-13rustdoc: use focus for search navigationJacob Hoffman-Andrews-13/+19
Rather than keeping track of highlighted element inside the JS, take advantage of `.focus()` and the :focus CSS pseudo-class. This required wrapping each row of results in one big <a> tag (because anchors can be focused, but table rows cannot). That in turn required moving from a table layout to a div layout with float. This makes it so Ctrl+Enter opens links in new tabs, and using the arrow keys to navigate off the bottom of the page scrolls the rest of the page into view. It also simplifies the keyboard event handling. It eliminates the need for click handlers on the search results, and for tracking mouse movements. This changes the UI treatment of mouse hovering. A hovered element now gets a light grey background, but does not change the focused element. It's possible to have two highlighted search results: one that is focused (via keyboard) and one that is hovered (via mouse). Pressing enter will activate the focused link; clicking will activate the hovered link. This matches up with how Firefox and Chrome handle suggestions in their URL bar, and avoids stray mouse movements changing the focus. Selecting tabs is now done with left/right arrows while any search result is focused. The visibility of results on each search tab is controlled with the "active" class, rather than by setting display: none directly. Note that the old code kept track of highlighted search element when tabbing back and forth. The new code doesn't.
2021-05-13Rollup merge of #85175 - GuillaumeGomez:rustdoc-cleanup, r=jshaGuillaume Gomez-73/+2
Rustdoc cleanup Part of https://github.com/rust-lang/rust/issues/83332. The goal of this PR is to remove a few unused things: * The "loading content" things are now unneeded. * Some toggle CSS rules were still there. * Some parts of the JS had a different indent, fixed it. r? `@jsha`
2021-05-13Fix display for "implementors" sectionGuillaume Gomez-1/+1
2021-05-12Rollup merge of #85174 - GuillaumeGomez:doc-code-block-border-radius, r=jshaGuillaume Gomez-2/+2
Fix border radius for doc code blocks in rustdoc In #85148, I made an invalid change on the border radius of the doc code blocks (look in the top left and bottom left corners of the code blocks). Before this fix: ![Screenshot from 2021-05-11 11-14-59](https://user-images.githubusercontent.com/3050060/117791459-a4f86b80-b24a-11eb-8ac3-facc719c799a.png) After this fix: ![Screenshot from 2021-05-11 11-05-29](https://user-images.githubusercontent.com/3050060/117791482-a9bd1f80-b24a-11eb-8c38-a01989595f5c.png) r? `@jsha`
2021-05-12Remove unused CSS rulesGuillaume Gomez-68/+2
2021-05-12Remove "loading content" which is now unnecessaryGuillaume Gomez-5/+0
2021-05-11Move global click handlers to per-element ones.Jacob Hoffman-Andrews-4/+4
In rustdoc's main.js, we had an onclick handler for the whole document that would dispatch to handlers for various elements. This change attaches the handlers to the elements that trigger them, instead. This simplfies the code and avoids reimplementing the browser's bubbling functionality. As part of this change, change from a class to an id for help button. Move the handlers and associated code for highlighting source lines into source-script.js (and factor out a shared regex).
2021-05-11Fix border radius for doc code blocks in rustdocGuillaume Gomez-2/+2
2021-05-10Rollup merge of #85148 - GuillaumeGomez:source-code-line-number, r=jshaGuillaume Gomez-9/+5
Fix source code line number display and make it clickable again Fixes https://github.com/rust-lang/rust/issues/85119. I used the same logic we're using for other codeblocks: putting the line number `<span>`s into the `example-wrap` directly and then add `display: inline-flex` on `example-wrap`. r? `@jsha`
2021-05-10Use an SVG image for clipboard instead of unicode characterGuillaume Gomez-4/+5
2021-05-10Fix line number not being clickable on source pagesGuillaume Gomez-9/+5
2021-05-10End toggle migrationGuillaume Gomez-0/+12
2021-05-02Add missing CSS rules for associated typesGuillaume Gomez-8/+11
2021-05-02Migrate trait and impl blocks' toggles intoGuillaume Gomez-4/+30
2021-04-29Rollup merge of #84690 - ↵Jack Huey-1/+0
GuillaumeGomez:unneeded-bottom-margin-search-results, r=Nemo157 Remove unneeded bottom margin on search results As you can see, there is still more than enough space at the bottom: ![Screenshot from 2021-04-29 11-26-57](https://user-images.githubusercontent.com/3050060/116530090-ea797800-a8dd-11eb-8eef-2288cf68e0d2.png) r? ``````@Nemo157``````
2021-04-29Rollup merge of #84688 - ↵Jack Huey-7/+0
GuillaumeGomez:remove-unnecessary-css-for-search-results, r=Nemo157 Remove unnecessary CSS rules for search results Discovered that this was useless when working on https://github.com/rust-lang/docs.rs/issues/1382. r? ````````@Nemo157````````
2021-04-29Rollup merge of #84451 - torhovland:flex, r=jshaJack Huey-14/+8
Use flex more consistently Builds on #84376, related to #84354. - Fully replaces `float: right` with `flex` on `.content .out-of-band`. - Uses `flex` more consistently with existing usage (on `h3`, `h4`, etc.). Tested on various widths to make sure the pages behave as before.
2021-04-29Remove unneeded bottom margin on search resultsGuillaume Gomez-1/+0
2021-04-29Remove unnecessary CSS rules for search resultsGuillaume Gomez-7/+0
2021-04-24Rollup merge of #84320 - jsha:details-implementors, ↵Yuki Okushi-1/+7
r=Manishearth,Nemo157,GuillaumeGomez Use details tag for trait implementors. Part of #83332 and following on from #83337 and #83355. This removes one category of JS-generated toggles (implementors), and replaces them with a `<details>` tag. This simplifies the JS, and fixes some bugs where things that were supposed to be hidden by the toggle were not hidden. Compare https://hoffman-andrews.com/rust/details-implementors/std/io/trait.Read.html#impl-Read vs https://doc.rust-lang.org/nightly/std/io/trait.Read.html#implementors. This introduces a `left: -23px` to put the toggle in the correct place, matching the current style for `.collapse-toggle`. It's worth noting this introduces a slight behavior change: since the entire line is now a `<summary>`, any part of the line is clickable. So for instance, in `impl Read for File`, clicking `impl` or `for` will collapse / expand the docs. Clicking `Read` or `File` still links to the appropriate documentation as before.
2021-04-24Rollup merge of #84321 - Swatinem:subvariant-details, r=GuillaumeGomezYuki Okushi-2/+3
rustdoc: Convert sub-variant toggle to HTML Instead of creating a JS toggle, this injects details/summary for sub-variants of enums. This also fixes the CSS so that the toggle button does not jump when expanding/collapsing. Takes inspiration from #83337 and should be considered part of #83332. Not quite sure if the `.sub-variant` selectors could be further simplified? AFAICS it is only used in that place, and that does not seem to allow any recursion.
2021-04-22Use flex more consistently.Tor Hovland-14/+8
2021-04-21Replaced flex gap with margin, for compatibility with older browsers.Tor Hovland-1/+1
2021-04-20Uses flex to fix formatting of h1 at any width.Tor Hovland-4/+9
2021-04-20Auto merge of #83900 - torhovland:issue-83832, r=jyn514bors-2/+4
Add stability tags to ImportItem. Fixes #83832.
2021-04-19rustdoc: use details tag for trait implementorsJacob Hoffman-Andrews-1/+7
This switches from JS-generated toggles to using the HTML <details> tag for expanding and collapsing entries in the "Implementors" section.
2021-04-19rustdoc: Convert sub-variant toggle to HTMLArpad Borsos-2/+3
Instead of creating a JS toggle, this injects details/summary for sub-variants of enums. This also fixes the CSS so that the toggle button does not jump when expanding/collapsing.
2021-04-18Give import items their own CSS class.Tor Hovland-2/+4
2021-04-17Reduce visual weight of attributes.Jacob Hoffman-Andrews-0/+4
2021-04-16Rollup merge of #83337 - Manishearth:item-hide, r=GuillaumeGomezDylan DPC-35/+47
rustdoc: Hide item contents, not items This tweaks rustdoc to hide item contents instead of items, and only when there are too many of them. This means that users will _always_ see the type parameters, and will _often_ see fields/etc as long as they are small. Traits have some heuristics for hiding only the methods or only the methods and the consts, since the associated types are super important. I'm happy to play around with the heuristics here; we could potentially make it so that structs/enums/etc are always hidden but traits will try really hard to show type aliases. This needs a test, but you can see it rendered at https://manishearth.net/sand/doc_render/bar/ <details> <summary> Code example </summary> ```rust pub struct PubStruct { pub a: usize, pub b: usize, } pub struct BigPubStruct { pub a: usize, pub b: usize, pub c: usize, pub d: usize, pub e: usize, pub f: usize, } pub union BigUnion { pub a: usize, pub b: usize, pub c: usize, pub d: usize, pub e: usize, pub f: usize, } pub union Union { pub a: usize, pub b: usize, pub c: usize, } pub struct PrivStruct { a: usize, b: usize, } pub enum Enum { A, B, C, D { a: u8, b: u8 } } pub enum LargeEnum { A, B, C, D, E, F, G, H, I, J } pub trait Trait { type A; #[must_use] fn foo(); fn bar(); } pub trait GinormousTrait { type A; type B; type C; type D; type E; type F; const N: usize = 1; #[must_use] fn foo(); fn bar(); } pub trait HugeTrait { type A; const M: usize = 1; const N: usize = 1; const O: usize = 1; const P: usize = 1; const Q: usize = 1; #[must_use] fn foo(); fn bar(); } pub trait BigTrait { type A; #[must_use] fn foo(); fn bar(); fn baz(); fn quux(); fn frob(); fn greeble(); } #[macro_export] macro_rules! foo { (a) => {a}; } ``` </details> Fixes https://github.com/rust-lang/rust/issues/82114
2021-04-13format cssFrançois Mockers-1/+2
2021-04-13add anchors links on hover to items from trait implFrançois Mockers-2/+3
2021-04-12Move color to themesManish Goregaokar-2/+0
2021-04-12Add css classesManish Goregaokar-10/+10
2021-04-12Improve CSS for "hide contents, not items"Jacob Hoffman-Andrews-34/+49
Introduce a first use of the `<details>` and `<summary>` tags as replacements for the JS-built toggles. I think this has the potential to replace all the JS toggles and generally clean up the JS, CSS, and HTML. Split rendering of attributes into two cases: in the case where they are rendered as descendents of a `<pre>` tag, where they use indent spaces and newlines for formatting, matching their surrounding markup. In the case where they are rendered as descendants of a `<code>` tag, they are rendered as `<div>`. This let me clean up some fragile CSS that was adjusting the margin-left of attributes depending on context. Remove toggles for attributes. With the ALLOWED_ATTRIBUTES filter, it's rare for an item to have more than one attribute, so hiding attributes behind a toggle doesn't save any screen space in the common case. Fix a couple of invocations of `matches!` that didn't compile on my machine. Fix a boolean for the JS `createToggle` call that was causing "Expand description" to show up spuriously on already-expanded descriptions. Add JS for auto-hide settings and hide all / show all. Remove a z-index property and some font color tweaks made unnecessary by the <details> toggles. Add CSS for the <details> toggles.
2021-04-12rustdoc: smartly hide associated items of traits if there are too many of themManish Goregaokar-3/+3
2021-04-12rustdoc: hide fields of structs/unions > 5Manish Goregaokar-1/+1
2021-04-12rustdoc: hide variants of enums > 5Manish Goregaokar-7/+6
2021-04-05Update Source Serif to release 4.004Trevor Spiteri-8/+8
Now the family name is Source Serif 4 (upstream issue 77) instead of Source Serif Pro.
2021-04-02rustdoc: Remove unused `spotlight` CSSCamelid-4/+1
I couldn't find any uses of this CSS. I think it was superseded by the `.notable-traits` CSS class and other similarly-named CSS classes.
2021-04-02Rollup merge of #83721 - GuillaumeGomez:copy-use, r=Nemo157Yuki Okushi-7/+16
Add a button to copy the "use statement" Fixes https://github.com/rust-lang/rust/issues/50239 When clicking on the button, it'll add the elements prepended by "use " and will end with a ";". So in the images below, I now have in my clipboard `use std::fs::OpenOptions;`. A screenshot of the newly added button: ![Screenshot from 2021-03-31 22-12-12](https://user-images.githubusercontent.com/3050060/113205430-90e64500-926e-11eb-8538-529829f611ec.png) A screenshot after it was clicked: ![Screenshot from 2021-03-31 22-15-31](https://user-images.githubusercontent.com/3050060/113205532-ad827d00-926e-11eb-893d-35f2f8f92696.png) r? `@Nemo157`
2021-03-31Add a button to copy the "use statement"Guillaume Gomez-7/+16
2021-03-29Wrap non-pre code blocksIvan Tham-1/+3
Fix #83550 regression
2021-03-24Rollup merge of #83405 - r00ster91:deprecated_emoji, r=GuillaumeGomezDylan DPC-0/+9
Slight visual improvements to warning boxes in the docs First I noticed that sometimes the thumbs-down emoji in the docs is hard to see and hard to look at because the yellow emoji color and the color of the box below are so bright. Especially if you look at the screen late at night you can notice it. I thought I should change that so I added a black outline around the emoji. It works using the [`text-shadow`](https://developer.mozilla.org/en-US/docs/Web/CSS/text-shadow) property. It may be a bit hacky but it seems to work well and browser compatibility looks pretty good too: [browser compatibility](https://developer.mozilla.org/en-US/docs/Web/CSS/text-shadow#browser_compatibility). For consistency the microscope has the black border too. Alternatively I had `drop-shadow(0px 0px 1px black);` in mind but its [browser compatibility](https://developer.mozilla.org/en-US/docs/Web/CSS/filter-function/drop-shadow()#browser_compatibility) doesn't look as good and the blurry shadow probably doesn't look as good either. Then, I thought that now that I'm at it I could also try changing the purple color to a color you would rather expect to see for deprecation: red. For the red I've taken the blue and reused it as a foundation and moved it to the red color spectrum. But then I thought that the purple color could still be reused for something else: for the boxes that tell you about portability (e.g. _only supported on Unix_). These are currently blue. I think blue doesn't really represent danger like it should. Not being cross-platform represents a danger because if you want to compile for a different platform, your code may not compile anymore. Blue looks too friendly and is in my opinion more suitable for a box containing general information like for instance "This is available since 1.0.0". None of the current three box types (unstable, deprecated and portability) are that. I think purple is a better fit for it because it's kind of in the middle between "use it" and "don't use it". Deprecated is definitely "don't use it". To illustrate this better, here's a color spectrum: Blue = friendly, "use it". ![image](https://user-images.githubusercontent.com/35064754/112139891-9a6b0f80-8bd3-11eb-94e1-dc747a3d4cf9.png) Red = danger, "don't use it". And the purple in the middle (the color that the portability box now has) probably represents "use it if you have to", so it's not entirely friendly and not entirely a danger. That is why I think it fits. However I made one change to that existing purple: I made the outer color a bit brighter because it's outstandingly dark compared to the other outer colors of the other boxes. This is all subjective but in my opinion it looks nicer. At first you might need to get used to it though. Notice the box colors and the black outlines around the emoji shapes: ![image](https://user-images.githubusercontent.com/35064754/112139327-ebc6cf00-8bd2-11eb-88ac-25219b43a1a0.png) ![image](https://user-images.githubusercontent.com/35064754/112139392-000acc00-8bd3-11eb-90c2-81feec93c521.png)
2021-03-24Rollup merge of #83393 - GuillaumeGomez:codeblock-tooltip-position, r=Nemo157Dylan DPC-1/+1
Codeblock tooltip position The codeblocks tooltips were misplaced. Normally, there is no top margin applied to a tooltip unless the codeblock is the first element of the doc block. The CSS rule was too vague though, applying it to all tooltips where the codeblock was the first child of its parent. Which can be easily seen with lists: Before: ![Screenshot from 2021-03-22 22-05-16](https://user-images.githubusercontent.com/3050060/112059812-a667ba80-8b5c-11eb-88dd-1c598ceb3766.png) After: ![Screenshot from 2021-03-22 22-06-31](https://user-images.githubusercontent.com/3050060/112059815-a7005100-8b5c-11eb-9e40-8fc57513e498.png) r? ``@Nemo157``
2021-03-23Slight visual improvements to warning boxes in the docsr00ster91-0/+9
2021-03-23Rollup merge of #80705 - tspiteri:italic-and-update-SourceCodePro, ↵Yuki Okushi-2/+9
r=GuillaumeGomez Update Source Code Pro and include italics Fixes #65502. #65665, a similar PR to this was merged but reverted because of https://github.com/rust-lang/rust/pull/65665#issuecomment-556860510. The issue in that comment is the upstream issue https://github.com/adobe-fonts/source-code-pro/issues/217 which should now be fixed in the upstream since [2.032R-ro/1.052R-it/1.012R-VAR release](https://github.com/adobe-fonts/source-code-pro/releases/tag/2.032R-ro/1.052R-it/1.012R-VAR), so I think this can now be merged. A couple of notes from the original PR: * Since this PR changes the font set, I think docs.rs would have to be updated if this PR is merged. * The fonts have a double extension (.ttf.woff); this is to keep the names consistent with the upstream font release which does that to distinguish these from the .otf.woff files (Source Code Pro otf renders poorly on older Windows system apps).