about summary refs log tree commit diff
path: root/src/librustdoc/html/templates
AgeCommit message (Collapse)AuthorLines
2023-01-30rustdoc: do not include empty default-settings tag in HTMLMichael Howell-0/+2
2023-01-27rustdoc: remove inline javascript from copy-path buttonMichael Howell-1/+1
2023-01-13rustdoc: remove unnecessary DOM class `h1.fqn`Michael Howell-1/+1
It's misleading. The main heading sometimes isn't an fully qualified name at all. It's also redundant. It's always a child of `div.main-heading`, so just use that.
2023-01-04rustdoc: remove unnecessary wrapper around sidebar and mobile logosMichael Howell-16/+12
This commit changes `.sidebar a:hover:not(.logo-container)` to add the `:not()` pseudo-class, retaining the old appearance of the logo when mousing over it. This didn't used to be necessary because the `a.sidebar-logo` was `display:inline`, and was what got the `background` changed on hover, while the `div.logo-container` inside it was `display:block`. This resulted in the hover rule not having any effect, because the logo-container box was not actually nested inside the sidebar-logo box: https://www.w3.org/TR/CSS2/visuren.html#anonymous-block-level > When an inline box contains an in-flow block-level box, the inline box (and its inline ancestors within the same line box) are broken around the block-level box (and any block-level siblings that are consecutive or separated only by collapsible whitespace and/or out-of-flow elements), splitting the inline box into two boxes (even if either side is empty), one on each side of the block-level box(es). The line boxes before the break and after the break are enclosed in anonymous block boxes, and the block-level box becomes a sibling of those anonymous boxes. When such an inline box is affected by relative positioning, any resulting translation also affects the block-level box contained in the inline box.
2022-12-19rustdoc: remove width-limiter from source pages, stop overriding CSSMichael Howell-2/+2
2022-11-23Improve accessibility:Guillaume Gomez-0/+1
* Set aria-label attribute on search input * Put anchor text directly into the DOM and not in the CSS
2022-11-19rustdoc: fix scrape-examples JS pathMichael Howell-1/+1
2022-11-05Rollup merge of #101702 - jsha:static-files2, r=notriddle,GuillaumeGomezMatthias Krüger-29/+29
rustdoc: add hash to filename of toolchain files All static files used by rustdoc are now stored in static.files/ and their filenames include a hash of their contents. Their filenames no longer include the contents of the --resource-suffix flag. This clarifies caching semantics. Anything in static.files can use Cache-Control: immutable because any updates will show up as a new URL. Invocation-specific files like crates-NN.js, search-index-NN.js, and sidebar-items-NN.js still get the resource suffix. This has a useful side effect: once toolchain files aren't affected by resource suffix, it will become possible for docs.rs to include crate version in the resource suffix. That should fix a caching issue with `/latest/` URLs: https://github.com/rust-lang/docs.rs/issues/1593. My goal is that it should be safe to serve all rustdoc JS, CSS, and fonts with infinite caching headers, even when new versions of a crate are uploaded in the same place as old versions. The --disable-minification flag is removed because it would vary the output of static files based on invocation flags. Instead, for rustdoc development purposes it's preferable to symlink static files to a non-minified copy for quick iteration. Example listing: ``` $ cd build/x86_64-unknown-linux-gnu/doc/ && find . | egrep 'js$|css$' | egrep -v 'sidebar-items|implementors' | sort ./crates1.65.0.js ./rust.css ./search-index1.65.0.js ./source-files1.65.0.js ./static.files/ayu-2bfd0af01c176fd5.css ./static.files/dark-95d11b5416841799.css ./static.files/light-c83a97e93a11f15a.css ./static.files/main-efc63f77fb116394.js ./static.files/normalize-76eba96aa4d2e634.css ./static.files/noscript-5bf457055038775c.css ./static.files/rustdoc-7a422337900fa894.css ./static.files/scrape-examples-3dd10048bcead3a4.js ./static.files/search-47f3c289722672cf.js ./static.files/settings-17b08337296ac774.js ./static.files/settings-3f95eacb845293c0.css ./static.files/source-script-215e9db86679192e.js ./static.files/storage-26d846fcae82ff09.js ``` Fixes #98413
2022-10-30Rollup merge of #101944 - notriddle:notriddle/toggle-all-docs, ↵Michael Howell-3/+3
r=jsha,GuillaumeGomez rustdoc: clean up `#toggle-all-docs` This change converts the element from an `<a>` link to a button. It's pretty much directly trading slightly more CSS for slightly less HTML, and it's also semantically correct (so you don't get a broken "bookmark" option when you right click on it). While doing this, I also got rid of the unnecessary `class="inner"` attribute on the inner span. There was a style targeting `.collapse-toggle > .inner`, but no CSS ever targeted the `#toggle-all-docs > .inner`. Preview: https://notriddle.com/notriddle-rustdoc-test/button-toggle-all-docs/index.html
2022-10-29rustdoc: add hash to filename of toolchain filesJacob Hoffman-Andrews-29/+29
All static files used by rustdoc are now stored in static.files/ and include a hash of their contents. They no longer include the contents of the --resource-suffix flag. This clarifies caching semantics. Anything in static.files can use Cache-Control: immutable because any updates will show up as a new URL. Invocation-specific files like crates-NN.js, search-index-NN.js, and sidebar-items-NN.js still get the resource suffix. The --disable-minification flag is removed because it would vary the output of static files based on invocation flags. Instead, for rustdoc development purposes it's preferable to symlink static files to a non-minified copy for quick iteration.
2022-10-27rustdoc: remove redundant `div.search-container`Michael Howell-18/+16
This wrapper DIV was originally added in 89e1fb322321c05497caa01372ceb7d5b57fa680, when it allowed the search bar's size to be calculated without using `calc()`. This `width` hack can be removed using flexbox.
2022-10-24rustdoc: clean up `#toggle-all-docs`Michael Howell-3/+3
This change converts the element from an `<a>` link to a button. It's pretty much directly trading slightly more CSS for slightly less HTML, and it's also semantically correct (so you don't get a broken "bookmark" option when you right click on it). While doing this, I also got rid of the unnecessary `class="inner"` attribute on the inner span. There was a style targeting `.collapse-toggle > .inner`, but no CSS ever targeted the `#toggle-all-docs > .inner`.
2022-10-24rustdoc: remove unused `.sidebar-logo` DOM on source pagesMichael Howell-0/+2
2022-10-20rustdoc: improve appearance of source page navigation barMichael Howell-24/+22
This commit changes things so that the search bar is exactly centered between the top of the page and the top of the source code content area.
2022-10-18rustdoc: remove class name `location` from sidebar sibling navMichael Howell-1/+1
This change tweaks the CSS to apply most of its styles to `.sidebar h2`, cleaning up a few redundant rules from `.mobile-topbar .location` and restoring useful navigation aids in mobile mode.
2022-10-16rustdoc: remove unused `.sub-logo-container` DOM on non-source pagesMichael Howell-0/+2
2022-10-15rustdoc: make the help button a link to a pageMichael Howell-1/+1
This allows you to open the help section in a new browser tab, which is a pretty reasonable thing to want for a documentation page.
2022-10-08rustdoc: remove mobile topbar from source pages instead of hiding itMichael Howell-0/+2
2022-10-05rustdoc: remove unused CSS class `in-band`Michael Howell-13/+11
Since a7c25b29575c17434406b69773f8c2961af343b3 removed `in-band` from code headers, the only remaining uses of the `in-band` class are: https://github.com/rust-lang/rust/blob/02cd79afb8080fce8c8ce35533c54d8ecf8f390e/src/librustdoc/html/render/write_shared.rs#L520-L521 https://github.com/rust-lang/rust/blob/02cd79afb8080fce8c8ce35533c54d8ecf8f390e/src/librustdoc/html/templates/print_item.html#L2-L3 https://github.com/rust-lang/rust/blob/02cd79afb8080fce8c8ce35533c54d8ecf8f390e/src/librustdoc/html/render/context.rs#L637-L638 https://github.com/rust-lang/rust/blob/02cd79afb8080fce8c8ce35533c54d8ecf8f390e/src/librustdoc/html/render/mod.rs#L368-L369 https://github.com/rust-lang/rust/blob/02cd79afb8080fce8c8ce35533c54d8ecf8f390e/src/librustdoc/html/render/mod.rs#L401-L402 https://github.com/rust-lang/rust/blob/02cd79afb8080fce8c8ce35533c54d8ecf8f390e/src/librustdoc/html/static/js/main.js#L525 Since all of these uses are nested below `h1.fqn`, we can get rid of it, and the support code that was used for when `in-band` was part of item rendering.
2022-08-25rustdoc: remove `type="text/css" from stylesheet linksMichael Howell-4/+4
MDN directly recommends this in <https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link>, since "CSS is the only stylesheet language used on the web."
2022-07-29Remove unwanted extra white space characters from HTMLGuillaume Gomez-9/+9
2022-07-14Correctly handle crate level page on docs.rs as wellGuillaume Gomez-1/+1
2022-06-23Move help popup into a pocket menu as wellGuillaume Gomez-1/+3
2022-06-20Improve loading of crates.js and sidebar-items.jsJacob Hoffman-Andrews-7/+8
Now that the "All Crates" dropdown is only rendered on the search results page, there is no need to load crates.js on most pages. Load it only on crate pages. Also, add the `defer` attribute so it does not block page rendering. For sidebar-items.js, move the script tag to `<head>`. Since it already has the defer attribute it won't block loading. The defer attribute does preserve ordering between scripts, so instead of the callback on load, it can set a global variable on load, which is slightly simpler. Also, since it is required to finish rendering the page, beginning its load earlier is better. Remove generation and handling of sidebar-vars. Everything there can be computed with information available in JS via other means. Remove the "other" wrapper in the sidebar. It was unnecessary. Remove excess script fields
2022-05-14Remove theme picker buttonGuillaume Gomez-7/+0
2022-05-14Improve settings menu displayGuillaume Gomez-3/+5
2022-04-30Move settings into full JSGuillaume Gomez-1/+0
2022-03-04Rollup merge of #93418 - ojeda:no-shortcut, r=camelidDylan DPC-1/+1
rustdoc & doc: no `shortcut` for `rel="icon"` According to https://html.spec.whatwg.org/multipage/links.html#rel-icon: > For historical reasons, the `icon` keyword may be preceded by the keyword "`shortcut`". And to https://developer.mozilla.org/en-US/docs/Web/HTML/Link_types: > **Warning:** The `shortcut` link type is often seen before `icon`, but this link type is non-conforming, ignored and **web authors must not use it anymore.** While it was removed from the Rust logo case a while ago in commit 085679c ("Use theme-adaptive SVG favicon from other Rust sites"), it is still there for the custom logo case. Also updated a few other instances. Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2022-01-28rustdoc: no `shortcut` in `rel="icon"`Miguel Ojeda-1/+1
According to https://html.spec.whatwg.org/multipage/links.html#rel-icon: > For historical reasons, the `icon` keyword may be preceded by > the keyword "`shortcut`". And to https://developer.mozilla.org/en-US/docs/Web/HTML/Link_types: > **Warning:** The `shortcut` link type is often seen before `icon`, > but this link type is non-conforming, ignored and **web authors > must not use it anymore.** While it was removed from the Rust logo case a while ago in commit 085679c8414 ("Use theme-adaptive SVG favicon from other Rust sites"), it is still there for the custom logo case. Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2022-01-27rustdoc: remove tooltip from source linkMichael Howell-1/+1
This made more sense back when it was abbreviated, but now it seems redundant.
2022-01-23rustdoc: fix bump down typing search on SafariJacob Hoffman-Andrews-0/+1
2022-01-23Rollup merge of #93113 - GuillaumeGomez:unify-sizes, r=jshaMatthias Krüger-11/+9
Unify search input and buttons size Fixes #93060. Here what it looks like: ![Screenshot from 2022-01-20 21-38-19](https://user-images.githubusercontent.com/3050060/150418571-fefd6538-b3ee-4dd2-b77b-77e96bcfa0ed.png) ![Screenshot from 2022-01-20 21-38-22](https://user-images.githubusercontent.com/3050060/150418570-53ba259b-9bd4-4084-8b43-d74a5752d712.png) You can test it [here](https://rustdoc.crud.net/imperio/unify-sizes/std/index.html). r? ``@jsha``
2022-01-21Fix spacing for `·` between stability and sourceJacob Hoffman-Andrews-1/+1
2022-01-21Unify search input and buttons sizeGuillaume Gomez-11/+9
2022-01-19Move back templates into html folderGuillaume Gomez-0/+219
2022-01-10Migrate rustdoc from Tera to AskamaDirkjan Ochtman-205/+0
See #84419.
2022-01-10Rollup merge of #92602 - jsha:source-link-2, r=GuillaumeGomezMatthias Krüger-24/+26
Make source links look cleaner Change from syntaxy-looking [src] to the plain word "source". Change the syntaxy-looking `[-]` at the top of the page to say "collapse". Reduce opacity of rightside content. Part of #59851 r? `@GuillaumeGomez` Demo: https://rustdoc.crud.net/jsha/source-link-2/std/string/struct.String.html [Discussed on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/display.20of.20source.20link).
2022-01-08Make source links look cleanerJacob Hoffman-Andrews-24/+26
Change from syntaxy-looking [src] to the plain word "source".
2022-01-05Move crate drop-down to search results pageJacob Hoffman-Andrews-5/+1
This reduces clutter on doc pages.
2021-12-15Apply rust-logo class only on default logoJacob Hoffman-Andrews-18/+14
Also replace ' with " in rustdoc template
2021-12-07Add missing whitespace before disabled HTML attributeGuillaume Gomez-1/+1
2021-12-05Auto merge of #91356 - GuillaumeGomez:improve-rustdoc-layout, r=jshabors-39/+54
Improve rustdoc layout This is an overtake of https://github.com/rust-lang/rust/pull/89385 originally written by `@cynecx.` I kept the original commit and simply added the missing fixes into a new one. You can test it online [here](https://rustdoc.crud.net/imperio/improve-rustdoc-layout/std/index.html). r? `@jsha`
2021-12-03Rollup merge of #91170 - jsha:preload-fonts, r=GuillaumeGomezMatthias Krüger-0/+6
rustdoc: preload fonts Follow-up from #82315. I noticed that font loading was so slow that even when loading from local disk, we get a flash of unstyled text (FOUT) followed by a reflow when the fonts load. With this change, we reliably get the appropriate fonts in the first render pass when loading locally, and we get it some of the time when loading from a website. This only preloads woff2 versions. According to https://caniuse.com/?search=preload and https://caniuse.com/?search=woff2, all browsers that support preload also support woff2, so this is fine; we will never load two copies of a font. Don't preload italic font faces because they aren't used on all pages. Demo: https://rustdoc.crud.net/jsha/preload-fonts/std/string/struct.String.html
2021-12-02Rename CSS class main-inner into width-limiterGuillaume Gomez-1/+1
2021-12-02Rename ID "main" into "main-content"Guillaume Gomez-1/+1
2021-12-02Fix remaining bugsGuillaume Gomez-1/+0
2021-11-29rustdoc: show logo in source sub navcynecx-37/+49
2021-11-29rustdoc: merge source sidebar into main sidebarcynecx-12/+1
2021-11-29rustdoc: fix source viewcynecx-7/+18
2021-11-29rustdoc: use flexbox to layout sidebar and main contentcynecx-32/+36