about summary refs log tree commit diff
path: root/src/librustdoc/html
AgeCommit message (Collapse)AuthorLines
2023-01-21Remove some superfluous type parameters from layout.rs.Michael Benfield-2/+2
Specifically remove V, which can always be VariantIdx, and F, which can always be Layout.
2023-01-21Migrate scraped-examples top and bottom "borders" to CSS variablesGuillaume Gomez-21/+12
2023-01-21rustdoc: compute maximum Levenshtein distance based on the queryMichael Howell-65/+84
The heuristic is pretty close to the name resolver. Fixes #103357
2023-01-20Rollup merge of #107131 - ↵Michael Goulet-6/+1
notriddle:notriddle/rustdoc-radio-display-inline-flex, r=GuillaumeGomez rustdoc: use CSS inline layout for radio line instead of flexbox This uses less code to lay them out the same way. Already tested here: https://github.com/rust-lang/rust/blob/5ce39f42bd2c8bca9c570f0560ebe1fce4eddb14/tests/rustdoc-gui/settings.goml#L123
2023-01-20Rollup merge of #107095 - notriddle:notriddle/sidebar-current, r=GuillaumeGomezMichael Goulet-1/+1
rustdoc: remove redundant CSS selector `.sidebar .current` Since the current sidebar item is already a link, it doesn't do anything.
2023-01-20rustdoc: use CSS inline layout for radio line instead of flexboxMichael Howell-6/+1
This uses less code to lay them out the same way.
2023-01-19rustdoc: remove redundant CSS selector `.sidebar .current`Michael Howell-1/+1
Since the current sidebar item is already a link, it doesn't do anything.
2023-01-19Revert "Improve code readability"Guillaume Gomez-1/+1
This reverts commit eb93d1bedeab64c6f5d661df6a309a5b8a9273ca.
2023-01-19Auto merge of #106810 - oli-obk:resolver_reverse_plumbing, r=petrochenkovbors-1/+1
Various cleanups around pre-TyCtxt queries and functions part of #105462 based on https://github.com/rust-lang/rust/pull/106776 (everything starting at [0e2b39f](https://github.com/rust-lang/rust/pull/106810/commits/0e2b39fd1ffde51b50d45ccbe41de52b85136b8b) is new in this PR) r? `@petrochenkov` I think this should be most of the uncontroversial part of #105462.
2023-01-18Rollup merge of #107045 - notriddle:notriddle/settings-css-setting-line, ↵Michael Goulet-5/+1
r=GuillaumeGomez rustdoc: remove redundant CSS rule `#settings .setting-line` Since the current version of settings.js always nests things below a div with ID `settings`, this rule always overrode the one above.
2023-01-18Rollup merge of #107042 - notriddle:notriddle/rustdoc-js-question, ↵Michael Goulet-1/+5
r=GuillaumeGomez rustdoc: fix corner cases with "?" JS keyboard command
2023-01-18Rollup merge of #105796 - ↵Michael Goulet-50/+64
notriddle:notriddle/rustdoc-search-stop-doing-demerits, r=GuillaumeGomez rustdoc: simplify JS search routine by not messing with lev distance Since the sorting function accounts for an `index` field, there's not much reason to also be applying changes to the levenshtein distance. Instead, we can just not treat `lev` as a filter if there's already a non-sentinel value for `index`. <details> This change gives slightly more weight to the index and path part, as search criteria, than it used to. This changes some of the test cases, but not in any obviously-"worse" way, and, in particular, substring matches are a bigger deal than levenshtein distances (we're assuming that a typo is less likely than someone just not typing the entire name). The biggest change is the addition of a `path_lev` field to result items. It's always zero if the search query has no parent path part and for type queries, making the check in the `sortResults` function a no-op. When it's present, it is used to implement different precedence for the parent path and the tail. Consider the query `hashset::insert`, a test case [that already exists and can be found here](https://github.com/rust-lang/rust/blob/5c6a1681a9a7b815febdd9de2f840da338984e68/src/test/rustdoc-js-std/path-ordering.js). We want the ordering shown in the test case: ``` { 'path': 'std::collections::hash_set::HashSet', 'name': 'insert' }, { 'path': 'std::collections::hash_set::HashSet', 'name': 'get_or_insert' }, { 'path': 'std::collections::hash_set::HashSet', 'name': 'get_or_insert_with' }, { 'path': 'std::collections::hash_set::HashSet', 'name': 'get_or_insert_owned' }, { 'path': 'std::collections::hash_map::HashMap', 'name': 'insert' }, ``` We do not want this ordering, which is the ordering that would occur if substring position took priority over `path_lev`: ``` { 'path': 'std::collections::hash_set::HashSet', 'name': 'insert' }, { 'path': 'std::collections::hash_map::HashMap', 'name': 'insert' }, // BAD { 'path': 'std::collections::hash_set::HashSet', 'name': 'get_or_insert' }, { 'path': 'std::collections::hash_set::HashSet', 'name': 'get_or_insert_with' }, { 'path': 'std::collections::hash_set::HashSet', 'name': 'get_or_insert_owned' }, ``` We also do not want `HashSet::iter` to appear before `HashMap::insert`, which is what would happen if `path_lev` took priority over the appearance of any substring match. This is why the `sortResults` function has `path_lev` sandwiched between a `index < 0` check and a `index` comparison check: ``` { 'path': 'std::collections::hash_set::HashSet', 'name': 'insert' }, { 'path': 'std::collections::hash_set::HashSet', 'name': 'get_or_insert' }, { 'path': 'std::collections::hash_set::HashSet', 'name': 'get_or_insert_with' }, { 'path': 'std::collections::hash_set::HashSet', 'name': 'get_or_insert_owned' }, { 'path': 'std::collections::hash_set::HashSet', 'name': 'iter' }, // BAD { 'path': 'std::collections::hash_map::HashMap', 'name': 'insert' }, ``` The old code implemented a similar feature by manipulating the `lev` member based on whether a substring match was found and averaging in the path distance (`item.lev = name_lev + path_lev / 10`), so the path lev wound up acting like a tie breaker, but it gives slightly different results for `Vec::new`, [changing the test case](https://github.com/rust-lang/rust/pull/105796/files#diff-b346e2ef72a407915f438063c8c2c04f7a621df98923d441b41c0312211a5b21) because of the slight changes to ordering priority. </details> Based on https://github.com/rust-lang/rust/pull/103710#issuecomment-1296894296 Previews: * https://notriddle.com/notriddle-rustdoc-demos/rustdoc-search-stop-doing-demerits/std/index.html * https://notriddle.com/notriddle-rustdoc-demos/rustdoc-search-stop-doing-demerits-compiler/index.html
2023-01-18rustdoc: remove redundant rule `#settings .setting-line`Michael Howell-5/+1
Since the current version of settings.js always nests things below a div with ID `settings`, this rule always overrode the one above.
2023-01-18rustdoc: fix "?" keyboard command when radio button is focusedMichael Howell-1/+2
This extends the special case with checkbox settings to also cover radios.
2023-01-18rustdoc: put focus on the help link when opening it from keyboardMichael Howell-0/+3
This prevents some strange blur-event-related bugs with the "?" command by ensuring that the focus remains in the same spot when the settings area closes.
2023-01-18Rollup merge of #107014 - notriddle:notriddle/js-cleanup, r=GuillaumeGomezDylan DPC-9/+4
rustdoc: remove deprecated / unused code from main.js
2023-01-17rustdoc: stop using deprecated `window.event` when there's an `ev` paramMichael Howell-1/+1
2023-01-17rustdoc: remove function `handleClick` that's only used onceMichael Howell-8/+3
2023-01-17rustdoc: instead of `.setting-name { width: 100% }`, use default div CSSMichael Howell-5/+1
2023-01-17Rollup merge of #106869 - notriddle:notriddle/item-decl-pre-rust, ↵Matthias Krüger-16/+16
r=GuillaumeGomez rustdoc: remove redundant item kind class from `.item-decl > pre` This class originated in the very first commit of `rustdoc_ng`, and was used to add a color border around the item decl based on its kind. https://github.com/rust-lang/rust/blob/4fd061c426902b0904c65e64a3780b21f9ab3afb/src/rustdoc_ng/html/static/main.css#L102-L106 The item decl no longer has a border, and there aren't any kind-specific styles in modern rustdoc's rendering of this UI item. Most of this PR is updating test cases so that they use `item-decl` to find the `<pre>` tag instead of relying on the fact that the class name had `rust {kind}` in it while other `<pre>` tags only had class `rust`.
2023-01-16Move compiler input and ouput paths into sessionOli Scherer-1/+1
2023-01-15rustdoc: simplify some & ref erencesMatthias Krüger-3/+3
2023-01-14rustdoc: simplify JS search routine by not messing with lev distanceMichael Howell-50/+64
Since the sorting function accounts for an `index` field, there's not much reason to also be applying changes to the levenshtein distance. Instead, we can just not treat `lev` as a filter if there's already a non-sentinel value for `index`. This change gives slightly more weight to the index and path part, as search criteria, than it used to. This changes some of the test cases, but not in any obviously-"worse" way, and, in particular, substring matches are a bigger deal than levenshtein distances (we're assuming that a typo is less likely than someone just not typing the entire name). Based on https://github.com/rust-lang/rust/pull/103710#issuecomment-1296894296
2023-01-14rustdoc: remove redundant item kind class from `.item-decl > pre`Michael Howell-16/+16
This class originated in the very first commit of `rustdoc_ng`, and was used to add a color border around the item decl based on its kind. https://github.com/rust-lang/rust/blob/4fd061c426902b0904c65e64a3780b21f9ab3afb/src/rustdoc_ng/html/static/main.css#L102-L106 The item decl no longer has a border, and there aren't any kind-specific styles in modern rustdoc's rendering of this UI item. Most of this commit is updating test cases so that they use `item-decl` to find the `<pre>` tag instead of relying on the fact that the class name had `rust {kind}` in it while other `<pre>` tags only had class `rust`.
2023-01-14Rollup merge of #106855 - klensy:rd-s, r=notriddleMatthias Krüger-24/+28
rustdoc: few small cleanups
2023-01-14Rollup merge of #106828 - notriddle:notriddle/notable-trait-docblock, ↵Matthias Krüger-4/+8
r=GuillaumeGomez rustdoc: remove `docblock` class from notable trait popover This commit builds on b72de9be74dd5ac1d8b23d5ece03a7690274a14c, which removes the `docblock` class from the All Items page, and 9457380ac902db3febf92077c5b645db55998ad4, which removes the `docblock` class from the item decl. Fixes #92974
2023-01-14Rollup merge of #106819 - notriddle:notriddle/rm-h1-fqn, r=GuillaumeGomezYuki Okushi-8/+8
rustdoc: remove unnecessary DOM class `h1.fqn` 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-13rustdoc: remove `docblock` class from notable trait popoverMichael Howell-4/+8
This commit builds on b72de9be74dd5ac1d8b23d5ece03a7690274a14c, which removes the `docblock` class from the All Items page, and 9457380ac902db3febf92077c5b645db55998ad4, which removes the `docblock` class from the item decl. Fixes #92974
2023-01-13rustdoc: rename CSS rustdoc-toggle -> toggle and toggle -> settings-toggleMichael Howell-56/+56
This swaps things around so that the class that gets used more often has the shorter name.
2023-01-13rustdoc: remove unnecessary DOM class `h1.fqn`Michael Howell-8/+8
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-13CrateData: don't allocate String when Serialize, &str is enoughklensy-1/+1
2023-01-13Playground.crate_name String -> Symbolklensy-6/+5
2023-01-13fmt_type: don't alloc const String, use &str insteadklensy-1/+1
2023-01-13generate_macro_def_id_path: don't eagerly stringify Symbolsklensy-7/+12
2023-01-13IndexItem.name String -> Symbolklensy-5/+5
2023-01-13evade clonesklensy-4/+4
2023-01-11Change `src/test` to `tests` in source files, fix tidy and testsAlbert Larsan-1/+1
2023-01-11Rollup merge of #106690 - GuillaumeGomez:item-declaration-scrolling, r=notriddleYuki Okushi-0/+4
Fix scrolling for item declaration block Fixes https://github.com/rust-lang/rust/issues/105580. The `contain: layout` was the issue here and the bug was actually on both mobile and desktop. r? `@notriddle`
2023-01-11Rollup merge of #106628 - GuillaumeGomez:rm-itemid-primitive, r=notriddleYuki Okushi-20/+55
Remove unneeded ItemId::Primitive variant As I mentioned [here](https://github.com/rust-lang/rust/pull/106412#issuecomment-1371405115), I wondered if `ItemId::Primitive` was actually used for anything. Apparently, it seems so because removing it led to no changes as far as I and tests could see. r? `@notriddle`
2023-01-10Remove unneeded ItemId::Primitive variantGuillaume Gomez-20/+55
2023-01-10Fix scrolling for item declaration blockGuillaume Gomez-0/+4
2023-01-09rustdoc: merge common CSS for `a`Michael Howell-4/+1
2023-01-07Rollup merge of #106556 - notriddle:notriddle/margin-left-content-mobile, ↵Matthias Krüger-4/+0
r=GuillaumeGomez rustdoc: remove no-op mobile CSS `.content { margin-left: 0 }` This rule was added to override non-zero left margin on `.content`, which was removed in 135281ed1525db15edd8ebd092aa10aa40df2386 and the margin-left was put on the docblock.
2023-01-06Rollup merge of #106543 - notriddle:notriddle/source-sidebar-width-zero, ↵Michael Goulet-5/+1
r=GuillaumeGomez rustdoc: remove no-op CSS `.rustdoc.source .sidebar { width: 0 }` This CSS was added in dc2c9723343c985740be09919236a6e96c4e4433, before 6a5f8b1aef1417d7dc85b5d0a229d2db1930eb7c when the sidebars were merged. Now that they are merged, the source sidebar is being pushed off-screen anyway, so giving it zero width doesn't do much.
2023-01-06rustdoc: remove no-op mobile CSS `.content { margin-left: 0 }`Michael Howell-4/+0
This rule was added to override non-zero left margin on `.content`, which was removed in 135281ed1525db15edd8ebd092aa10aa40df2386 and the margin-left was put on the docblock.
2023-01-06Rollup merge of #106466 - clubby789:relative-module-fix, r=notriddleMatthias Krüger-41/+103
Fix rustdoc source code rendering for `#[path = "../path/to/mod.rs"]` links Fixes #103517 While generating the location for modules source HTML to be saved at, a `..` path component appeared to be translated to `/up/`. Additionally, while generating the navigation sidebar, `..` path components were ignored. This means that (as in the issue above), a *real* directory structure of: ``` sys/ unix/ mod.rs <-- contains #![path = "../unix/mod.rs] cmath.rs ``` was rendered as: ``` sys/ unix/ mod.rs unix/ cmath.rs <-- links to sys/unix/unix/cmath.rs.html, 404 ``` While the *files* were stored as ``` sys/ unix/ mod.rs.html up/ unix/ cmath.rs.html ```
2023-01-06rustdoc: remove no-op CSS `.rustdoc.source .sidebar { width: 0 }`Michael Howell-5/+1
This CSS was added in dc2c9723343c985740be09919236a6e96c4e4433, before 6a5f8b1aef1417d7dc85b5d0a229d2db1930eb7c when the sidebars were merged. Now that they are merged, the source sidebar is being pushed off-screen anyway, so giving it zero width doesn't do much.
2023-01-06Correctly render sidebar for relative module pathsclubby789-41/+103
2023-01-06Rollup merge of #106502 - notriddle:notriddle/user-select, r=GuillaumeGomezDylan DPC-2/+0
rustdoc: remove legacy user-select CSS According to [caniuse], the only supported browser that requires the vendor prefix, as defined in [RFC 1985], is Safari. * The last version of Chrome that required a vendor prefix was version 53. The current version is 108. * Firefox 68 is the last version that required a vendor prefix. The [current Firefox ESR] is version 102. * The current version of Safari for Mac and iOS still requires a prefix. * The last version of Edge that required a vendor frefix was 18. The current version of Edge is 108. * UCAndroid support is unknown, but if it still requires a vendor prefix, it's more likely to be `-webkit-` than `-moz-` or `-ms-`, since they would want to emulate iOS for compatibility. [caniuse]: https://caniuse.com/?search=user-select [RFC 1985]: https://rust-lang.github.io/rfcs/1985-tiered-browser-support.html [current Firefox ESR]: https://wiki.mozilla.org/Releases
2023-01-05rustdoc: remove legacy user-select CSSMichael Howell-2/+0
According to [caniuse], the only supported browser that requires the vendor prefix, as defined in [RFC 1985], is Safari. * The last version of Chrome that required a vendor prefix was version 53. The current version is 108. * Firefox 68 is the last version that required a vendor prefix. The [current Firefox ESR] is version 102. * The current version of Safari for Mac and iOS still requires a prefix. * The last version of Edge that required a vendor frefix was 18. The current version of Edge is 108. * UCAndroid support is unknown, but if it still requires a vendor prefix, it's more likely to be `-webkit-` than `-moz-` or `-ms-`, since they would want to emulate iOS for compatibility. [caniuse]: https://caniuse.com/?search=user-select [RFC 1985]: https://rust-lang.github.io/rfcs/1985-tiered-browser-support.html [current Firefox ESR]: https://wiki.mozilla.org/Releases