about summary refs log tree commit diff
path: root/src/librustdoc/html
AgeCommit message (Collapse)AuthorLines
2023-02-03rustdoc: use the same URL escape rules for fragments as for examplesMichael Howell-64/+54
2023-02-03Rollup merge of #107615 - notriddle:notriddle/nbsp, r=GuillaumeGomezMichael Goulet-12/+14
Replace nbsp in all rustdoc code blocks Based on #106125 by `@dtolnay` — this PR fixes the line wrapping bug. Fixes #106098. This makes code copyable from rustdoc rendered documentation into a Rust source file.
2023-02-03Replace nbsp in all rustdoc code blocksMichael Howell-12/+14
Co-Authored-By: David Tolnay <dtolnay@gmail.com>
2023-02-02Auto merge of #107000 - GuillaumeGomez:fix-items-in-doc-hidden-block, ↵bors-1/+1
r=notriddle,petrochenkov Fix handling of items inside a `doc(hidden)` block Fixes #106373. cc `@aDotInTheVoid` r? `@notriddle`
2023-02-02Rollup merge of #107531 - GuillaumeGomez:inline-images-in-css, r=notriddleMatthias Krüger-10/+13
Inline CSS background images directly into the CSS A nice advantage of this is that it removes a few entries in the list of static files. r? ``@notriddle``
2023-02-01Inline CSS background images directly into the CSSGuillaume Gomez-10/+13
2023-01-31Rollup merge of #107527 - notriddle:notriddle/wcagcontrast, r=GuillaumeGomezGuillaume Gomez-18/+5
rustdoc: stop making unstable items transparent Fixes #93393
2023-01-31Rollup merge of #107491 - notriddle:notriddle/setting-check, r=GuillaumeGomezGuillaume Gomez-2/+0
rustdoc: remove unused CSS from `.setting-check` These rules were needed for the mobile-style switches, but those were removed in 0f3ae6218ef1d9e9b14bf983b463785b14abc205
2023-01-31Rollup merge of #107354 - tspiteri:source-serif-4.005, r=GuillaumeGomezGuillaume Gomez-4/+12
rustdoc: update Source Serif 4 from 4.004 to 4.005 [Version 4.005](https://github.com/adobe-fonts/source-serif/releases/tag/4.005R) was released on 2023-01-20.
2023-01-31rustdoc: stop making unstable items transparentMichael Howell-18/+5
Fixes #93393
2023-01-31rustdoc: remove inconsistently-present sidebar tooltipsMichael Howell-14/+4
Discussed in https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/Inconsistent.20sidebar.20tooltips/near/323565625
2023-01-31Clean up eslint annotations and remove unused JS functionGuillaume Gomez-2/+0
2023-01-31Rollup merge of #107482 - notriddle:notriddle/keywords, r=jshaYuki Okushi-16/+3
rustdoc: remove meta keywords from HTML Discussed in <https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/.60.3Cmeta.20name.3D.22keywords.22.3E.60>
2023-01-31Rollup merge of #107477 - GuillaumeGomez:css-var, r=notriddleYuki Okushi-32/+21
Migrate last part of CSS themes to CSS variables No changes in the output. This is already tested in `tests/rustdoc-gui/search-tab.goml` so no need to add a GUI test. r? `@notriddle`
2023-01-31Rollup merge of #107476 - notriddle:notriddle/item-decl-3, r=GuillaumeGomezYuki Okushi-317/+277
rustdoc: remove unnecessary wrapper `div.item-decl` from HTML
2023-01-30rustdoc: remove unused CSS from `.setting-check`Michael Howell-2/+0
These rules were needed for the mobile-style switches, but those were removed in 0f3ae6218ef1d9e9b14bf983b463785b14abc205
2023-01-30rustdoc: remove meta keywords from HTMLMichael Howell-16/+3
Discussed in <https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/.60.3Cmeta.20name.3D.22keywords.22.3E.60>
2023-01-30Migrate last part of CSS themes to CSS variablesGuillaume Gomez-32/+21
2023-01-30rustdoc: remove unnecessary wrapper div.item-decl from HTMLMichael Howell-317/+277
2023-01-30Rollup merge of #107177 - thanatos:fix-doc-errant-light-theme, r=notriddleMatthias Krüger-62/+54
Keep all theme-updating logic together Prior to this PR, if the page is restored from the browser bfcache¹, we call `switchToSavedTheme`. But `switchToSavedTheme` never looks at the `use-system-theme` preference. Further, if it can't find a saved theme, it will fall back to the default of "light". For a user with cookies disabled² whose preferred color scheme is dark, this means the theme will wobble back and forth between dark and light. The sequence that occurs is, 1. The page is loaded. During a page load, we consult `use-system-theme`: as cookies are disabled, this preference is unset. The default is true. Because the default is true, we look at the preferred color scheme: for our example user, that's "dark". **The page theme is set to dark.** We'll attempt to store these preferences in localStorage, but fail due to cookies being disabled. 2. The user navigates through the docs. Subsequent page loads happen, and the same process in step 1 recurs. Previous pages are (potentially) put into the bfcache. 3. The user navigates backwards/forwards, causing a page in bfcache to be pulled out of cache. The `pageShow` event handler is triggered. However, this calls `switchToSavedTheme`: this doesn't consider the system theme, as noted above. Instead, it only looks for a saved theme. However, with cookies disabled, there is none. It defaults to light. **The page theme is set to light!** The user wonders why the dark theme is lost. There are effectively two functions trying to determine and apply the correct theme: `updateSystemTheme` and `switchToSavedTheme`. Thus, we merge them into just one: `updateTheme`. This function contains all the logic for determining the correct theme, and is called in all circumstances where we need to set the theme: * The initial page load * If the browser preferred color scheme (i.e., light/dark mode) is changed * If the page is restored from bfcache * If the user updates the theme preferences (i.e., in `settings.js`) Fixes https://github.com/rust-lang/rust/issues/94250. ¹bfcache: https://web.dev/bfcache/ The bfcache is used to sleep a page, if the user navigates away from it, and to restore it from cache if the user returns to it. ²Note that the browser preference that enables/disables cookies really controls many forms of storage. The same preference thus also affects localStorage. (This is so a normal browser user doesn't need to understand the distinction between "cookies" and "localStorage".)
2023-01-30rustdoc: do not include empty default-settings tag in HTMLMichael Howell-0/+2
2023-01-30Keep all theme-updating logic togetherRoy Wellington Ⅳ-46/+54
Prior to this PR, if the page is restored from the browser bfcache¹, we call `switchToSavedTheme`. But `switchToSavedTheme` never looks at the `use-system-theme` preference. Further, if it can't find a saved theme, it will fall back to the default of "light". For a user with cookies disabled² whose preferred color scheme is dark, this means the theme will wobble back and forth between dark and light. The sequence that occurs is, 1. The page is loaded. During a page load, we consult `use-system-theme`: as cookies are disabled, this preference is unset. The default is true. Because the default is true, we look at the preferred color scheme: for our example user, that's "dark". **The page theme is set to dark.** We'll attempt to store these preferences in localStorage, but fail due to cookies being disabled. 2. The user navigates through the docs. Subsequent page loads happen, and the same process in step 1 recurs. Previous pages are (potentially) put into the bfcache. 3. The user navigates backwards/forwards, causing a page in bfcache to be pulled out of cache. The `pageShow` event handler is triggered. However, this calls `switchToSavedTheme`: this doesn't consider the system theme, as noted above. Instead, it only looks for a saved theme. However, with cookies disabled, there is none. It defaults to light. **The page theme is set to light!** The user wonders why the dark theme is lost. There are effectively two functions trying to determine and apply the correct theme: `updateSystemTheme` and `switchToSavedTheme`. Thus, we merge them into just one: `updateTheme`. This function contains all the logic for determining the correct theme, and is called in all circumstances where we need to set the theme: * The initial page load * If the browser preferred color scheme (i.e., light/dark mode) is changed * If the page is restored from bfcache * If the user updates the theme preferences (i.e., in `settings.js`) Fixes #94250. ¹bfcache: https://web.dev/bfcache/ The bfcache is used to sleep a page, if the user navigates away from it, and to restore it from cache if the user returns to it. ²Note that the browser preference that enables/disables cookies really controls many forms of storage. The same preference thus also affects localStorage. (This is so a normal browser user doesn't need to understand the distinction between "cookies" and "localStorage".)
2023-01-28rustdoc: remove unused class `has-srclink`Michael Howell-17/+5
Stopped being used in CSS with 73d0f7c7b68784f1db0a1f53855c20d118a7e8b0
2023-01-28Rollup merge of #107398 - scottmcm:its-their-funeral, r=dtolnayMatthias Krüger-6/+6
Remove `ControlFlow::{BREAK, CONTINUE}` Libs-API decided to remove these in #102697. Follow-up to #107023, which removed them from `compiler/`, but a couple new ones showed up since that was merged. r? libs
2023-01-27Remove from librustdoc and clippy tooScott McMurray-6/+6
2023-01-27rustdoc: remove inline javascript from copy-path buttonMichael Howell-2/+6
2023-01-27rustdoc: merge doctest tooltip with notable traits tooltipMichael Howell-109/+81
Fixes https://discord.com/channels/442252698964721669/443150878111694848/1066420140167680000 Fixes #91100
2023-01-27add comment to rustdoc.css on updating filename suffixesTrevor Spiteri-0/+8
2023-01-27Improve code readabilityGuillaume Gomez-1/+1
2023-01-27rustdoc: update Source Serif 4 from 4.004 to 4.005Trevor Spiteri-4/+4
Version 4.005 was released on 2023-01-20.
2023-01-27Rollup merge of #107336 - notriddle:notriddle/import-item-module-item, ↵Yuki Okushi-4/+3
r=GuillaumeGomez rustdoc: remove mostly-unused CSS classes `import-item` and `module-item`
2023-01-27Rollup merge of #107325 - petrochenkov:hiddoc2, r=GuillaumeGomezYuki Okushi-32/+12
rustdoc: Stop using `HirId`s Use `LocalDefId`s instead. Rustdoc doesn't work with item bodies, so it almost never needs fine-grained HIR IDs.
2023-01-27Rollup merge of #107284 - notriddle:notriddle/plus, r=jshaYuki Okushi-1/+18
rustdoc: use smarter encoding for playground URL The old way would compress okay with DEFLATE, but this version makes uncompressed docs smaller, which matters for memory usage and stuff like `cargo doc`. Try it out: <https://play.rust-lang.org/?code=fn+main()+{%0Alet+mut+v+=+Vec::new();%0Av.push(1+/+1);%0Aprintln!(%22{}%22,+v[0]);%0A}> In local testing, this change shrinks sample pages by anywhere between 4.0% and 0.031% $ du -b after.dir/std/vec/struct.Vec.html before.dir/std/vec/struct.Vec.html 759235 after.dir/std/vec/struct.Vec.html 781842 before.dir/std/vec/struct.Vec.html 100*((759235-781842)/781842)=-2.8 $ du -b after.dir/std/num/struct.Wrapping.html before.dir/std/num/struct.Wrapping.html 3194173 after.dir/std/num/struct.Wrapping.html 3204351 before.dir/std/num/struct.Wrapping.html 100*((3194173-3204351)/3204351)=-0.031 $ du -b after.dir/std/keyword.match.html before.dir/std/keyword.match.html 8151 after.dir/std/keyword.match.html 8495 before.dir/std/keyword.match.html 100*((8151-8495)/8495)=-4.0 Gzipped tarball sizes seem shrunk, but not by much. du -s before.tar.gz after.tar.gz 69600 before.tar.gz 69480 after.tar.gz 100*((69480-69600)/69600)=-0.17
2023-01-27Rollup merge of #107242 - notriddle:notriddle/title-ordering, r=GuillaumeGomezYuki Okushi-1/+1
rustdoc: make item links consistently use `title="{shortty} {path}"` The ordering in item tables was flipped in 3030cbea957adbd560bf2eaa34c1b8a56daee16a, making it inconsistent with the ordering in method signatures. Compare these (before this PR is merged): https://github.com/rust-lang/rust/blob/c8e6a9e8b6251bbc8276cb78cabe1998deecbed7/src/librustdoc/html/render/print_item.rs#L455-L459 https://github.com/rust-lang/rust/blob/c8e6a9e8b6251bbc8276cb78cabe1998deecbed7/src/librustdoc/html/format.rs#L903-L908
2023-01-26rustdoc: remove mostly-unused CSS classes import/module-itemMichael Howell-4/+3
2023-01-26rustdoc: use smarter encoding for playground URLMichael Howell-1/+18
The old way would compress okay with DEFLATE, but this version makes uncompressed docs smaller, which matters for memory usage and stuff like `cargo doc`. Try it out: <https://play.rust-lang.org/?code=fn+main()+{%0Alet+mut+v+=+Vec::new();%0Av.push(1+/+1);%0Aprintln!(%22{}%22,+v[0]);%0A}> In local testing, this change shrinks sample pages by anywhere between 4.0% and 0.031% $ du -b after.dir/std/vec/struct.Vec.html before.dir/std/vec/struct.Vec.html 759235 after.dir/std/vec/struct.Vec.html 781842 before.dir/std/vec/struct.Vec.html 100*((759235-781842)/781842)=-2.8 $ du -b after.dir/std/num/struct.Wrapping.html before.dir/std/num/struct.Wrapping.html 3194173 after.dir/std/num/struct.Wrapping.html 3204351 before.dir/std/num/struct.Wrapping.html 100*((3194173-3204351)/3204351)=-0.031 $ du -b after.dir/std/keyword.match.html before.dir/std/keyword.match.html 8151 after.dir/std/keyword.match.html 8495 before.dir/std/keyword.match.html 100*((8151-8495)/8495)=-4.0 Gzipped tarball sizes seem shrunk, but not by much. du -s before.tar.gz after.tar.gz 69600 before.tar.gz 69480 after.tar.gz 100*((69480-69600)/69600)=-0.17
2023-01-26rustdoc: Stop using `HirId`sVadim Petrochenkov-32/+12
Use `LocalDefId`s instead
2023-01-25Rollup merge of #107266 - kadiwa4:source_viewer_scrollbar, r=notriddleMatthias Krüger-1/+1
rustdoc: prohibit scroll bar on source viewer in Safari Fixes #106455.
2023-01-25Rollup merge of #107244 - notriddle:notriddle/primitive-reference-link, ↵Matthias Krüger-8/+2
r=GuillaumeGomez rustdoc: rearrange HTML in primitive reference links This patch avoids hard-to-click single character links by making the generic part of the link: Before: <a href="#">&</a>T After: <a href="#">&T</a>
2023-01-24rustdoc: prevent scroll bar on source viewerKaDiWa-1/+1
2023-01-23rustdoc: rearrange HTML in primitive reference linksMichael Howell-8/+2
This patch avoids hard-to-click single character links by making the generic part of the link: Before: <a href="#">&</a>T After: <a href="#">&T</a>
2023-01-23rustdoc: remove dead settings JS for obsolete select-wrapperMichael Howell-11/+0
2023-01-23rustdoc: simplify settings popover DOMMichael Howell-35/+33
* Changes the class names so that they all start with `setting-`. That should make it harder to accidentally use a setting class outside the settings popover, where loading the CSS might accidentally change the styles of something unrelated. * Get rid of an unnecessary wrapper DIV around the radio button line. * Simplify CSS selectors by making the DOM easier and more intuitive to target.
2023-01-23rustdoc: make item links consistently use `title="{shortty} {path}"`Michael Howell-1/+1
The ordering in item tables was flipped in 3030cbea957adbd560bf2eaa34c1b8a56daee16a, making it inconsistent with the ordering in method signatures. Compare these: https://github.com/rust-lang/rust/blob/c8e6a9e8b6251bbc8276cb78cabe1998deecbed7/src/librustdoc/html/render/print_item.rs#L455-L459 https://github.com/rust-lang/rust/blob/c8e6a9e8b6251bbc8276cb78cabe1998deecbed7/src/librustdoc/html/format.rs#L903-L908
2023-01-23Rollup merge of #107186 - GuillaumeGomez:correct-pseudo-element-selector, ↵Dylan DPC-4/+4
r=notriddle rustdoc: Use correct pseudo-element selector As explained [here](https://developer.mozilla.org/en-US/docs/Web/CSS/Pseudo-elements#syntax). I wrote it on top of #107152 so we'll need to wait for this one to be merged first. r? `@notriddle`
2023-01-22Rollup merge of #107174 - petrochenkov:defidoc, r=notriddleMatthias Krüger-10/+10
rustdoc: Use `DefId(Map,Set)` instead of `FxHash(Map,Set)` Not all uses are converted, a few cases iterating through maps/sets and requiring nontrivial changes are kept. cc https://github.com/rust-lang/rust/pull/106977
2023-01-22Rollup merge of #107152 - GuillaumeGomez:migrate-to-css-var, r=notriddleMatthias Krüger-21/+12
Migrate scraped-examples top and bottom "borders" to CSS variables r? `@notriddle`
2023-01-22Use correct pseudo-element selectorGuillaume Gomez-4/+4
2023-01-21This function appears to be unusedRoy Wellington Ⅳ-16/+0
The comment says that it is called from main.js, but there don't seem to be any references to it in main.js. A quick ripgrep says there are no references in all of librustdoc.
2023-01-22rustdoc: Use `DefId(Map,Set)` instead of `FxHash(Map,Set)`Vadim Petrochenkov-10/+10
Not all uses are converted, a few cases iterating through maps/sets and requiring nontrivial changes are kept.