about summary refs log tree commit diff
path: root/src/librustdoc/html/static
AgeCommit message (Collapse)AuthorLines
2021-05-12Remove unused CSS rulesGuillaume Gomez-71/+2
2021-05-12Remove "loading content" which is now unnecessaryGuillaume Gomez-50/+0
2021-05-11Move global click handlers to per-element ones.Jacob Hoffman-Andrews-127/+136
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-11rustdoc: remove explicit boolean comparisons.Jacob Hoffman-Andrews-69/+64
For boolean variables it's shorter and more readable to check the value directly, or negate it with `!`. In a couple of cases I reordered an if/else pair because it made the initial `if` statement simpler. Removed unused isType parameter from two functions.
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-12/+8
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-7/+25
2021-05-10Fix line number not being clickable on source pagesGuillaume Gomez-12/+8
2021-05-10End toggle migrationGuillaume Gomez-204/+30
2021-05-02Auto merge of #84754 - GuillaumeGomez:toggle-migration, r=jshabors-100/+55
Migrate trait and impl blocks' toggles into Part of #83332 After this, I think only the "global" doc comment will be used as JS toggle. Once this PR is merged, I check what remains and remove them. There is one change that this PR brings: ![Screenshot from 2021-04-30 15-39-04](https://user-images.githubusercontent.com/3050060/116713412-0f9ce200-a9d5-11eb-979c-2e7a73d16706.png) ![Screenshot from 2021-04-30 15-39-07](https://user-images.githubusercontent.com/3050060/116713415-10357880-a9d5-11eb-9868-1ba9e5ebf65e.png) As you can see, I had to move the "undocumented" items below, they're not mixed with the others anymore. Unfortunately, I don't see a way to keep the current appearance without JS. As a a reminder, currently it looks like this: ![Screenshot from 2021-04-30 15-39-12](https://user-images.githubusercontent.com/3050060/116713547-31966480-a9d5-11eb-90bb-686042eefeec.png) ![Screenshot from 2021-04-30 15-39-15](https://user-images.githubusercontent.com/3050060/116713549-322efb00-a9d5-11eb-94a9-cfea073120db.png) r? `@jsha`
2021-05-02Add missing CSS rules for associated typesGuillaume Gomez-8/+11
2021-05-02Migrate trait and impl blocks' toggles intoGuillaume Gomez-94/+46
2021-04-30`copy_path` -> `window.copy_path` + add semicolonr00ster-2/+2
2021-04-30Apply suggestionsr00ster-29/+34
2021-04-30Reset the docs' copy path button after 1 secondr00ster-0/+10
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-28rustdoc: change aliases attribute to data-aliasesMichael Howell-1/+1
The "aliases" attribute is not listed [on MDN], so it sounds like it's rustdoc-specific. We don't want to conflict with any attributes that are added to the spec in the future. [on MDN]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Heading_Elements
2021-04-27Auto merge of #84552 - GuillaumeGomez:open-impl-blocks-by-default, r=jshabors-2/+4
Open impl blocks by default Fixes #84558. Part of #84422. As you can see on https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TyCtxt.html, impl blocks are currently not open by default whereas they should. I also realized that a test was outdated so I removed it and opened #84550 because it seems like the rustdoc-gui test suite isn't run on CI... cc `@jyn514` r? `@jsha`
2021-04-26Add open attribute on details which are supposed to be open by default ↵Guillaume Gomez-2/+0
instead of opening them with JS
2021-04-25Auto merge of #84325 - jsha:ephemeral-collapse, r=GuillaumeGomezbors-28/+18
rustdoc: make expand/collapse all ephemeral The `[+]` in the upper right of a rustdoc page expands or collapses all toggles on the page. That state is stored across page loads, but is used inconsistently. This change explicitly stops storing or using the state. This also moves the code for toggling display of trait implementations so that it's near the other toggling code. Fixes #84318
2021-04-25Fix expansion for item pointed to by the URL hashGuillaume Gomez-0/+2
2021-04-25Open all impl blocks by defaultGuillaume Gomez-2/+4
2021-04-24Rollup merge of #84320 - jsha:details-implementors, ↵Yuki Okushi-21/+14
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 #84433 - GuillaumeGomez:search-input-blur, r=jshaYuki Okushi-3/+6
Prevent control, shift and alt keys to make search input lose focus Part of #84384. r? ````@jsha````
2021-04-24Rollup merge of #84321 - Swatinem:subvariant-details, r=GuillaumeGomezYuki Okushi-6/+15
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-23improve wordingArpad Borsos-1/+1
2021-04-22Use flex more consistently.Tor Hovland-14/+8
2021-04-22Prevent control, shift and alt keys to make search input lose focusGuillaume Gomez-3/+6
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-20Rollup merge of #84340 - notriddle:patch-4, r=GuillaumeGomezDylan DPC-1/+1
rustdoc: Show nag box on IE11 Rustdoc doesn't work on IE11. It's been broken for months, it isn't supported by the [tiered browser support list], it's even more severely broken on other Rust websites, and IE11 doesn't support the `<details>` tag that we want to use. In the interest of honesty, let's give an actual error message for anyone on IE11. [tiered browser support list]: https://github.com/rust-lang/rfcs/blob/master/text/1985-tiered-browser-support.md
2021-04-20Auto merge of #83900 - torhovland:issue-83832, r=jyn514bors-5/+10
Add stability tags to ImportItem. Fixes #83832.
2021-04-19rustdoc: use details tag for trait implementorsJacob Hoffman-Andrews-21/+14
This switches from JS-generated toggles to using the HTML <details> tag for expanding and collapsing entries in the "Implementors" section.
2021-04-19Use onEachLazy to iterate DOMTokenListMichael Howell-1/+1
2021-04-19Remove collapse param from collapseNonInherent.Jacob Hoffman-Andrews-4/+4
2021-04-19rustdoc: Convert sub-variant toggle to HTMLArpad Borsos-6/+15
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-19Auto merge of #84283 - jsha:de-emphasize-attributes, r=GuillaumeGomezbors-3/+10
rustdoc: Reduce visual weight of attributes. Followup from #83337. As part of that PR, we stopped hiding attributes behind a toggle, because most things have just zero or one attributes. However, this made clear that the current rendering of attributes emphasizes them a lot, which distracts from function signatures. This PR changes their color of attributes to be the same as the toggles, and reduces their font weight. This also removes `#[lang]` from the list of ALLOWED_ATTRIBUTES. This attribute is an implementation detail rather than part of the public-facing documentation. ![image](https://user-images.githubusercontent.com/220205/115131061-cc407d80-9fa9-11eb-9a77-ad3f3217f391.png) Demo at https://hoffman-andrews.com/rust/de-emph-attr/std/string/struct.String.html#method.trim
2021-04-18rustdoc: make expand/collapse all ephemeralJacob Hoffman-Andrews-27/+17
The `[+]` in the upper right of a rustdoc page expands or collapses all toggles on the page. That state is stored across page loads, but is used inconsistently. This change explicitly stops storing or using the state.
2021-04-18Give import items their own CSS class.Tor Hovland-5/+10
2021-04-18Fix the wrong return value type description of validateResulthi-rustin-1/+1
2021-04-17Reduce visual weight of attributes.Jacob Hoffman-Andrews-3/+10
2021-04-17Rollup merge of #84150 - jsha:defer-search-js, r=GuillaumeGomezDylan DPC-1685/+1669
rustdoc: move some search code into search.js This reduces main.s from 3094 lines to 1587. Also it saves some bytes of download in the case where search isn't used. There were a fair number of variables that needed to be accessible in both main.js and search.js, but I didn't want to put too many symbols in the global namespace, so I consolidated much of the search-related state and functions into a new object `window.searchState`. Demo at https://hoffman-andrews.com/rust/move-search/std/?search=foo
2021-04-16Rollup merge of #83337 - Manishearth:item-hide, r=GuillaumeGomezDylan DPC-92/+75
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-13Split search.js from search-index.js.Jacob Hoffman-Andrews-6/+6
2021-04-13format cssFrançois Mockers-1/+2
2021-04-13add anchors links on hover to items from trait implFrançois Mockers-2/+3