about summary refs log tree commit diff
path: root/src/librustdoc/html
AgeCommit message (Collapse)AuthorLines
2022-08-25rustdoc: remove unused CSS for `.variants_table`Michael Howell-8/+0
Continuation of #100938 and #101010. This rule was added to support the old, table-based style for displaying enum variants, which are now displayed using headers and paragraphs.
2022-08-25rustdoc: remove unused CSS for `.multi-column`Michael Howell-10/+0
As a sanity check, [this tool] can be used to run a CSS query across an HTML tree to detect if a selector ever matches (I use compiler-docs and std docs). This isn't good enough, because I also need to account for JavaScript, but this class is never mentioned in any of the JS files, either. According to [blame], this class was added when rustdoc was first written, and, as far as I can tell, was never actually used. [this tool]: https://gitlab.com/notriddle/html-scanner [blame]: https://github.com/rust-lang/rust/blame/4d45b0745ab227feb9000bc15713ade4b99241ea/src/librustdoc/html/static/css/rustdoc.css#L753-L761
2022-08-25Fix missing cfg propagation for reexportsGuillaume Gomez-2/+9
2022-08-25Rollup merge of #100960 - rust-lang:notriddle/ayu-span-code, r=GuillaumeGomezYuki Okushi-1/+1
rustdoc: ayu code color selector more specific According to https://github.com/rust-lang/rust/pull/100960#issuecomment-1225970579, this selector is only really intended to apply to item info. However, it's so broad that it's hard to tell when it deliberately applies vs where it accidentally applies.
2022-08-24Remove the extra DOM level if there is only one child in rightside elementsGuillaume Gomez-14/+37
2022-08-24rustdoc: ayu code color selector more specificMichael Howell-1/+1
According to https://github.com/rust-lang/rust/pull/100960#issuecomment-1225970579, this selector is only really intended to apply to item info. However, it's so broad that it's hard to tell when it deliberately applies vs where it accidentally applies.
2022-08-24Rollup merge of #100938 - notriddle:notriddle/fields-table, r=sanxiynMatthias Krüger-4/+0
rustdoc: remove unused CSS rule According to [blame], this rule was added to support enum struct variants. However, enum struct variants don't use tables in their design any more, so this rule does nothing. [blame]: https://github.com/rust-lang/rust/blame/87991d5f5d72d6baca490141cb890211ba2f3843/src/librustdoc/html/static/css/rustdoc.css#L748
2022-08-24Unify rightside renderingGuillaume Gomez-32/+12
2022-08-24Auto merge of #96869 - sunfishcode:main, r=joshtriplettbors-1/+1
Optimize `Wtf8Buf::into_string` for the case where it contains UTF-8. Add a `is_known_utf8` flag to `Wtf8Buf`, which tracks whether the string is known to contain UTF-8. This is efficiently computed in many common situations, such as when a `Wtf8Buf` is constructed from a `String` or `&str`, or with `Wtf8Buf::from_wide` which is already doing UTF-16 decoding and already checking for surrogates. This makes `OsString::into_string` O(1) rather than O(N) on Windows in common cases. And, it eliminates the need to scan through the string for surrogates in `Args::next` and `Vars::next`, because the strings are already being translated with `Wtf8Buf::from_wide`. Many things on Windows construct `OsString`s with `Wtf8Buf::from_wide`, such as `DirEntry::file_name` and `fs::read_link`, so with this patch, users of those functions can subsequently call `.into_string()` without paying for an extra scan through the string for surrogates. r? `@ghost`
2022-08-23rustdoc: remove unused CSS ruleMichael Howell-4/+0
According to [blame], this rule was added to support enum struct variants. However, enum struct variants don't use tables in their design any more, so this rule does nothing. [blame]: https://github.com/rust-lang/rust/blame/87991d5f5d72d6baca490141cb890211ba2f3843/src/librustdoc/html/static/css/rustdoc.css#L748
2022-08-21Auto merge of #100847 - matthiaskrgr:rollup-0ga531s, r=matthiaskrgrbors-102/+151
Rollup of 11 pull requests Successful merges: - #100556 (Clamp Function for f32 and f64) - #100663 (Make slice::reverse const) - #100697 ( Minor syntax and formatting update to doc comment on `find_vtable_types_for_unsizing`) - #100760 (update test for LLVM change) - #100761 (some general mir typeck cleanup) - #100775 (rustdoc: Merge source code pages HTML elements together v2) - #100813 (Add `/build-rust-analyzer/` to .gitignore) - #100821 (Make some docs nicer wrt pointer offsets) - #100822 (Replace most uses of `pointer::offset` with `add` and `sub`) - #100839 (Make doc for stdin field of process consistent) - #100842 (Add diagnostics lints to `rustc_transmute` module (zero diags)) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-08-21Auto merge of #100645 - notriddle:notriddle/rustdoc-diet-plan, r=GuillaumeGomezbors-3/+8
rustdoc: strategic boxing to reduce the size of ItemKind and Type The `Type` change redesigns `QPath` to box the entire data structure instead of boxing `self_type` and the `trait_`. This reduces the size of several `ItemKind` variants, leaving `Impl` as the biggest variant. The `ItemKind` change boxes that variant's payload.
2022-08-21Rollup merge of #100775 - GuillaumeGomez:reduce-span-v2, r=notriddleMatthias Krüger-102/+151
rustdoc: Merge source code pages HTML elements together v2 This is the follow-up of https://github.com/rust-lang/rust/pull/100429. I strongly recommend to review it one commit at a time because otherwise it's a lot at once. For these ones, on each page, I run this JS: `document.getElementsByTagName('*').length`. The goal is to count the number of DOM elements. I took some pages that seemed big, but don't hesitate to check some others. I also added the "starting point" because it's quite nice to see how much the page was reduced thanks to these two PRs. | file name | before #100429 | before this PR | with this PR | diff | |-|-|-|-|-| | std/lib.rs.html (source link on std crate page) | 3455 | 2332 | 1772 | 24% | | alloc/vec/mod.rs.html (source on Vec type page) | 11012 | 5982 | 5833 | 2.5% | | alloc/string.rs.html (source on String type page) | 10800 | 6010 | 5822 | 3.2% | | std/sync/mutex.rs.html (source on Mutex type page) | 2953 | 2041 | 2038 | 0.1% | So unsurprisingly, the more attributes you have, the bigger the difference. You can test it [here](https://rustdoc.crud.net/imperio/reduce-span-v2/src/std/lib.rs.html). cc ``````@jsha`````` r? ``````@notriddle``````
2022-08-20Rollup merge of #100718 - GuillaumeGomez:fix-item-info, r=jshaMatthias Krüger-4/+9
[rustdoc] Fix item info display Fixes #100369. The solution I came up with was simply to wrap the "text part" of the `item-info` into another span so that `flex` wouldn't mess with it. Live demo is [here](https://rustdoc.crud.net/imperio/fix-item-info/foo/struct.ItemInfo.html). r? ``@jsha``
2022-08-20Fix hover and focus display for search results on ayu themeGuillaume Gomez-3/+4
2022-08-20Extend decoration test to detect regressionsGuillaume Gomez-3/+8
2022-08-20Clean up highlight `<span>` merge codeGuillaume Gomez-121/+118
2022-08-20Update rustdoc testsGuillaume Gomez-9/+11
2022-08-20Merge "EnterSpan" events to reduce code blocks DOM sizeGuillaume Gomez-23/+68
2022-08-19Fix invalid comparison for Class::Decoration in `is_equal_to`Guillaume Gomez-2/+2
2022-08-19Rollup merge of #100731 - notriddle:notriddle/deref-methods-1, r=jshaDylan DPC-6/+11
rustdoc: count deref and non-deref as same set of used methods Fixes #100679
2022-08-18rustdoc: count deref and non-deref as same set of used methodsMichael Howell-6/+11
2022-08-18Fix item-info displayGuillaume Gomez-4/+9
2022-08-18Remove unused CSS ruleGuillaume Gomez-14/+0
2022-08-18Simplify rustdoc themes by relying more on CSS variablesGuillaume Gomez-228/+30
2022-08-16rustdoc: factor Type::QPath out into its own boxMichael Howell-3/+8
This reduces the size of Type.
2022-08-14Update rustdoc testsGuillaume Gomez-31/+31
2022-08-14Don't generate ident elements as DOM nodesGuillaume Gomez-14/+23
2022-08-14Merge HTML elements in highlighting when they can be merged togetherGuillaume Gomez-8/+155
2022-08-13Rollup merge of #100299 - compiler-errors:issue-100283, r=notriddleMichael Goulet-5/+4
make `clean::Item::span` return `Option` instead of dummy span Fixes #100283
2022-08-13make clean::Item::span return option instead of dummy spanMichael Goulet-5/+4
2022-08-13avoid cloning and then iteratingKaDiWa-4/+9
2022-08-12Rollup merge of #100409 - jsha:highlight-lighter, r=GuillaumeGomezDylan DPC-27/+24
rustdoc: don't generate DOM element for operator In our source page highlighting, we were generating `<span class="op">` tags for all "operators", including e.g. `<` `>` around generic parameters, `*`, `&`. This contributed significantly to DOM size, but we don't actually style `.op` except in the ayu theme. Remove the styles for `.op` in ayu, and stop generating the `<span>`s. This reduces DOM size of an example page[1] from 265,938 HTML elements to 242,165 elements, a 9% reduction. r? ``@GuillaumeGomez`` Demo: (warning - slow!) https://rustdoc.crud.net/jsha/highlight-lighter/src/core/up/up/stdarch/crates/core_arch/src/x86/avx512f.rs.html [1]: https://doc.rust-lang.org/nightly/src/core/up/up/stdarch/crates/core_arch/src/x86/avx512f.rs.html
2022-08-11rustdoc: don't generate DOM element for operatorJacob Hoffman-Andrews-27/+24
In our source page highlighting, we were generating `<span class="op">` tags for all "operators", including e.g. `<` `>` around generic parameters, `*`, `&`. This contributed significantly to DOM size, but we don't actually style `.op` except in the ayu theme. Remove the styles for `.op` in ayu, and stop generating the `<span>`s. This reduces DOM size of an example page[1] from 265,938 HTML elements to 242,165 elements, a 9% reduction. [1]: https://doc.rust-lang.org/nightly/src/core/up/up/stdarch/crates/core_arch/src/x86/avx512f.rs.html
2022-08-11Rollup merge of #100374 - ↵Matthias Krüger-42/+98
GuillaumeGomez:improve_rustdoc_search_results_page_crates_selection, r=notriddle Improve crate selection on rustdoc search results page Take over of #98855 (screenshots and explanations are there). You can test it [here](https://rustdoc.crud.net/imperio/improve_rustdoc_search_results_page_crates_selection/std/index.html?search=test). cc ``@steffahn`` ``@jsha`` r? ``@notriddle``
2022-08-11Rollup merge of #99337 - jsha:simplify-highlight, r=GuillaumeGomezMatthias Krüger-79/+75
rustdoc: simplify highlight.rs Split render_with_highlighting, which took many optional parameters, into three functions for specific purposes, which each take a smaller number of mostly required parameters. Remove some plumbing to pass through an "edition" parameter, which was used solely to avoid highlighting some 2021 Edition keywords in non-2021 code. I've tested a build of std docs before and after, and this does not change the generated HTML at all. Followup from https://github.com/rust-lang/rust/pull/91264#discussion_r901151101 r? ```@GuillaumeGomez```
2022-08-10rustdoc: make item-infos dimmer on dark theme #93896Jacob Hoffman-Andrews-23/+8
Previously the item-info background colors were too bright for a dark theme, making a bright rectangle that draws the attention.
2022-08-10Add missing ID into the ID mapGuillaume Gomez-1/+2
2022-08-10Two small improvements:Frank Steffahn-3/+2
Fix oversight duplicate property left in CSS (dark theme). Improve wording in comment that mentions `appearance: none`
2022-08-10Improve crate selection on rustdoc search results pageFrank Steffahn-41/+97
Resolves all of issue #93240 Reproduces a similar change as #99086, but with improvements In particular, this PR inlcludes: * redesigning the crate-search selector so the background color matches its surroundings * decrease the font of the dropdown menu to a reaonable size * add a hover effect * make the color of the arrow theme-dependent, using a surrounding div, with :after pseudo-element that can then be transformed using CSS filters to approximate the desired color * fix the text "in" to match the title font * remove the "for xyz" in the "Results for xyz in [All crates]" title when searching for search term "xyz"; you can already see what you're searching for as it's typed in the search bar! * in line with #99086, handle super-long crate names appropriately without a long <select> element escaping the screen area; the improvement is that we also keep the title within a single line now; uses some flex layout shenanigans... * the margins / paddings are adjusted so the selected label of the <select> fits within the rest of that title nicely; also some inconsistency in the way that Firefox renders a <select> with "appearance: none" (roughly 4px more padding left and right of the text than e.g. Chrome) is worked around, and it now produces a result that looks (essentially) identical to Chrome * the color of the help menu and settings menu border in light theme is made to match with the color of the corresponding buttons, like they do (match) in the ayu theme * the casing of "All crates" changes to "all crates" * the new tests from #99086 are temporarily disabled, until they can be adapted later
2022-08-10Auto merge of #100346 - matthiaskrgr:rollup-6rljn4p, r=matthiaskrgrbors-7/+59
Rollup of 14 pull requests Successful merges: - #98775 (rustdoc: improve scroll locking in the rustdoc mobile sidebars) - #99479 (rustdoc-json: Remove doc FIXME for Import::id and explain) - #100040 (Error on broken pipe but do not backtrace or ICE) - #100072 (linker-plugin-lto.md: Correct the name of example c file) - #100098 (Some "this expression has a field"-related fixes) - #100226 (Do not manually craft a span pointing inside a multibyte character.) - #100240 (Fail gracefully when const pattern is not structural match.) - #100256 (Add some high-level docs to `FnCtxt` and `ItemCtxt`) - #100261 (Set tainted errors bit before emitting coerce suggestions.) - #100275 (also update anyhow in codegen_cranelift) - #100281 (Remove more Clean trait implementations) - #100314 (Mention `unit-test` in MIR opt test README) - #100319 (Remove more Clean trait implementations) - #100323 ([rustdoc] Don't render impl blocks with doc comment if they only contain private items by default) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-08-09rustdoc: simplify highlight.rsJacob Hoffman-Andrews-79/+75
Split render_with_highlighting, which took many optional parameters, into three functions for specific purposes, which each take a smaller number of mostly required parameters. Remove some plumbing to pass through an "edition" parameter, which was used solely to avoid highlighting some 2021 Edition keywords in non-2021 code.
2022-08-10Rollup merge of #98775 - notriddle:notriddle/mobile-sidebar-scroll-lock, r=jshaMatthias Krüger-7/+59
rustdoc: improve scroll locking in the rustdoc mobile sidebars This PR prevents the main content area from scrolling while the mobile sidebar is open on documentation pages (porting the scroll locking behavior from the source sidebar to the regular sidebar), and also fixes some bad behavior where opening a "mobile" sidebar, and growing the viewport so that the "desktop" mode without scroll locking is activated, could potentially leave the page stuck. This does not affect the behavior on larger screens. Only small ones, where the sidebar covers up the main content. Split out from #98772
2022-08-09Auto merge of #100150 - notriddle:notriddle/implementors-js, r=GuillaumeGomezbors-22/+73
rustdoc: use a more compact encoding for implementors/trait.*.js The exact amount that this reduces the size of an implementors file depends on whether most of the impls are synthetic or not. For `Send`, it reduces the file from 128K to 112K, while for `Clone` it went from 64K to 44K.
2022-08-07Don't document impossible to call default trait items on implsMichael Goulet-0/+9
2022-08-05rustdoc: use serde, which can escape strings more quicklyMichael Howell-35/+15
This means we don't gain as much as we did from using single-quotes, since serde_json can only produce double-quoted strings, but it's still a win.
2022-08-05rustdoc: reduce the number of intermediate Strings allocatedMichael Howell-13/+22
2022-08-04rustdoc: use a more compact encoding for implementors/trait.*.jsMichael Howell-21/+83
The exact amount that this reduces the size of an implementors file depends on whether most of the impls are synthetic or not. For `Send`, it reduces the file from 128K to 116K, while for `Clone` it went from 64K to 52K.
2022-08-03Rollup merge of #100083 - notriddle:notriddle/source-files-js, r=GuillaumeGomezMatthias Krüger-20/+31
rustdoc: use a more compact encoding for source-files.js This reduces the compiler-doc file from 40K to 36K, a 10% reduction in size.
2022-08-03Rollup merge of #100079 - camelid:fix-doc-star-search, r=Dylan-DPCDylan DPC-1/+1
Replace `* -> vec` with `-> vec` in docs Fixes #100078. Rustdoc's current syntax is `-> vec`.