summaryrefslogtreecommitdiff
path: root/src/librustdoc/html/static/js
Commit message (Collapse)AuthorAgeFilesLines
* Rollup merge of #110371 - notriddle:notriddle/search-corrections, ↵Manish Goregaokar2023-05-032-197/+228
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | r=GuillaumeGomez rustdoc: restructure type search engine to pick-and-use IDs Fixes #110029 Preview: https://notriddle.com/rustdoc-demo-html-3/search-corrections/std/index.html?search=-%3E%20streaming ![image](https://user-images.githubusercontent.com/1593513/233494900-ae77d5b4-e395-41f8-bbac-53ee55bb4a76.png) This change makes it so, instead of mixing string distance with type unification, function signature search works by mapping names to IDs at the start, reporting to the user any cases where it had to make corrections, and then matches with IDs when going through the items. This only changes function searches. Name searches are left alone, and corrections are only done when there's a single item in the search query.
| * rustdoc-search: use more descriptive "x not found; y instead" messageMichael Howell2023-04-201-1/+1
| |
| * rustdoc-search: make type name correction choice deterministicMichael Howell2023-04-201-0/+3
| |
| * rustdoc-search: clean up `checkIfInGenerics` call at end of `checkType`Michael Howell2023-04-201-5/+1
| |
| * rustdoc-search: give longer notification for type correctionsMichael Howell2023-04-191-2/+7
| |
| * rustdoc: restructure type search engine to pick-and-use IDsMichael Howell2023-04-172-196/+223
| | | | | | | | | | | | | | | | | | | | | | | | This change makes it so, instead of mixing string distance with type unification, function signature search works by mapping names to IDs at the start, reporting to the user any cases where it had to make corrections, and then matches with IDs when going through the items. This only changes function searches. Name searches are left alone, and corrections are only done when there's a single item in the search query.
| * rustdoc-search: fix incorrect doc commentMichael Howell2023-04-171-1/+1
| |
* | Rollup merge of #110661 - notriddle:notriddle/settings-js-handlekey, ↵Matthias Krüger2023-04-231-18/+1
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | r=GuillaumeGomez rustdoc: clean up settings.css and settings.js `handleKey` was added in 9dc5dfb97504c538bc72f367a77bb9f714c30097 and 704050da2334c465784954d81c8990c4bc7a92c5 because the browser-native checkbox was `display: none`, breaking native keyboard accessibility. The native checkbox is now merely `appearance: none`, which does not turn off [behavior semantics], so JavaScript to reimplement it isn't needed any more. [behavior semantics]: https://w3c.github.io/csswg-drafts/css-ui/#appearance-semantics The other, one line change to settings.css is follow-up to #110205
| * | rustdoc: remove unneeded handleKey from settings.jsMichael Howell2023-04-211-18/+1
| |/ | | | | | | | | | | | | | | | | | | | | | | | | This code was added in 9dc5dfb97504c538bc72f367a77bb9f714c30097 and 704050da2334c465784954d81c8990c4bc7a92c5 because the browser- native checkbox was `display: none`, breaking native keyboard accessibility. The native checkbox is now merely `appearance: none`, which does not turn off [behavior semantics], so JavaScript to reimplement it isn't needed any more. [behavior semantics]: https://w3c.github.io/csswg-drafts/css-ui/#appearance-semantics
* | rustdoc: clean up redundant search hiding results codeMichael Howell2023-04-212-8/+1
| | | | | | | | | | | | | | * There's no need to call `history.replaceState` right before calling `searchState.hideResults`, which already does it. * There's no need to implement hiding search results when that is already implemented.
* | rustdoc: lift constant string manipulation out of loopMichael Howell2023-04-211-1/+1
| |
* | rustdoc: use Set for ignored crates, instead of string matchingMichael Howell2023-04-211-2/+4
|/
* Rollup merge of #110341 - notriddle:notriddle/main-js-replacestate, ↵Matthias Krüger2023-04-171-4/+2
|\ | | | | | | | | | | | | | | | | | | r=GuillaumeGomez rustdoc: stop passing a title to `replaceState` second argument As described on [MDN's replaceState page], this parameter is not currently used, and the empty string is "safe against future changes to the method." [MDN's replaceState page]: https://developer.mozilla.org/en-US/docs/Web/API/History/replaceState
| * rustdoc: stop passing a title to `replaceState` second argumentMichael Howell2023-04-151-4/+2
| | | | | | | | | | | | | | | | As described on [MDN's replaceState page], this parameter is not currently used, and the empty string is "safe against future changes to the method." [MDN's replaceState page]: https://developer.mozilla.org/en-US/docs/Web/API/History/replaceState
* | rustdoc-search: add support for nested genericsMichael Howell2023-04-141-11/+10
|/
* rustdoc-search: use ES6 Map for `Result` instead of ObjectMichael Howell2023-04-132-21/+40
|
* rustdoc-search: use ES6 `Set` for deduplication instead of `Object`Michael Howell2023-04-131-3/+3
|
* rustdoc-search: use ES6 `Map` for generic matching instead of `Object`Michael Howell2023-04-131-23/+14
|
* rustdoc-search: use ES6 `Map` for aliases instead of `Object`Michael Howell2023-04-131-11/+16
|
* rustdoc: use CSS `overscroll-behavior` instead of JavaScriptMichael Howell2023-04-122-55/+6
| | | | | | | | | | | | | | | | | Fixes the desktop scrolling weirdness mentioned in https://github.com/rust-lang/rust/pull/98775#issuecomment-1182575603 As described in the MDN page for this property: * The current Firefox ESR is 102, and the first Firefox version to support this feature is 59. * The current Chrome version 112, and the first version to support this is 63. * Edge is described as having a minor bug in `none` mode, but we use `contain` mode anyway, so it doesn't matter. * Safari 16, released September 2022, is the last browser to add this feature, and is also the oldest version we officially support.
* rustdoc: remove redundant expandSection code from main.jsMichael Howell2023-04-101-14/+5
| | | | | | | | | | | | | This functionality is already tested in `hash-item-expansion.goml`, and was implemented twice: * First, in code that ran at load time and at hash change: 917cdd295d2eed213c135d6f984c650f016ee3d6 * Later, the hash change event handler was itself run at load time, and the code handling both cases diverged in implementation, though their behavior still matches pretty well: f66a331335f3ac931afabca6f927a9d7dc17db3e
* Rollup merge of #110037 - notriddle:notriddle/theme-default, r=GuillaumeGomezNilstrieb2023-04-081-0/+1
|\ | | | | | | | | | | rustdoc: add test and bug fix for theme defaults Part of https://github.com/rust-lang/rust/issues/66181
| * rustdoc: add test and bug fix for theme defaultsMichael Howell2023-04-061-0/+1
| |
* | rustdoc: clean up JSMichael Howell2023-04-063-28/+9
|/ | | | | | | | * Stop checking `func` in `onEach`. It's always hard-coded right at the call site, so there's no point. * Use the ternary operator in a few spots where it makes sense. * No point in making `onEach` store `arr.length` in a variable if it's only used once anyway.
* rustdoc-search: update docs for comma in `?` help popoverMichael Howell2023-03-311-3/+1
|
* Rollup merge of #109633 - GuillaumeGomez:fix-go-to-only-setting, r=notriddleMatthias Krüger2023-03-271-5/+1
|\ | | | | | | | | | | | | | | | | | | Fix "Directly go to item in search if there is only one result" setting Part of #66181. The setting was actually broken, so I fixed it when I added the GUI test. r? `@notriddle`
| * Fix "Directly go to item in search if there is only one result" settingGuillaume Gomez2023-03-261-5/+1
| |
* | Rollup merge of #109542 - notriddle:notriddle/storage-js, r=GuillaumeGomezMatthias Krüger2023-03-252-61/+18
|\ \ | | | | | | | | | rustdoc: clean up `storage.js`
| * | rustdoc: remove old `content` hack for theme switchingMichael Howell2023-03-231-32/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is based on the compatibility data for `window.matchMedia` and `MediaQueryList`'s `EventTarget` implementation. https://developer.mozilla.org/en-US/docs/Web/API/MediaQueryList#browser_compatibility https://developer.mozilla.org/en-US/docs/Web/API/Window/matchMedia#browser_compatibility * EventTarget would require us to drop support for all Chrome versions before 39. However, we already require Chrome 49, because rustdoc requires [CSS variables]. * EventTarget would also limit us to Firefox 55, but since #106502 rustdoc only supports Firefox > 68. * EventTarget limits us to Mobile Safari version 14, but #102404 shows that our CSS is broken in Safari versions before 15.5. [CSS variables]: https://developer.mozilla.org/en-US/docs/Web/CSS/--*#browser_compatibility
| * | rustdoc: clean up `storage.js`Michael Howell2023-03-232-29/+13
| |/ | | | | | | | | | | This converts a few functions to more compact versions of themselves, and moves `RUSTDOC_MOBILE_BREAKPOINT` to main.js where it's actually used.
* | rustdoc: add support for type filters in arguments and genericsMichael Howell2023-03-201-53/+111
|/ | | | | | | This makes sense, since the search index has the information in it, and it's more useful for function signature searches since a function signature search's item type is, by definition, some type of function (there's more than one, but not very many).
* rustdoc: implement bag semantics for function parameter searchMichael Howell2023-03-191-26/+70
| | | | | | This tweak to the function signature search engine makes things so that, if a type is repeated in the search query, it'll only match if the function actually includes it that many times.
* Rollup merge of #109009 - notriddle:notriddle/edit-distance, r=GuillaumeGomezMatthias Krüger2023-03-121-149/+223
|\ | | | | | | | | | | | | | | | | | | | | | | rustdoc: use restricted Damerau-Levenshtein distance for search Based on https://github.com/rust-lang/rust/pull/108200, for the same rationale. > This replaces the existing Levenshtein algorithm with the Damerau-Levenshtein algorithm. This means that "ab" to "ba" is one change (a transposition) instead of two (a deletion and insertion). More specifically, this is a restricted implementation, in that "ca" to "abc" cannot be performed as "ca" → "ac" → "abc", as there is an insertion in the middle of a transposition. I believe that errors like that are sufficiently rare that it's not worth taking into account. Before this change, searching [`prinltn!`] listed `print!` first, followed by `println!`. With this change, `println!` matches more closely. [`prinltn!`]: https://doc.rust-lang.org/nightly/std/?search=prinltn!
| * rustdoc: collapse edit distance state into an objectMichael Howell2023-03-111-80/+86
| |
| * rustdoc: use restricted Damerau-Levenshtein distance for searchMichael Howell2023-03-101-147/+215
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Based on https://github.com/rust-lang/rust/pull/108200, for the same rationale. > This replaces the existing Levenshtein algorithm with the > Damerau-Levenshtein algorithm. This means that "ab" to "ba" is one change > (a transposition) instead of two (a deletion and insertion). More > specifically, this is a restricted implementation, in that "ca" to "abc" > cannot be performed as "ca" → "ac" → "abc", as there is an insertion in the > middle of a transposition. I believe that errors like that are sufficiently > rare that it's not worth taking into account. Before this change, searching `prinltn!` listed `print!` first, followed by `println!`. With this change, `println!` matches more closely.
* | Rollup merge of #107629 - pitaj:rustdoc-search-deprecated, r=jshaMatthias Krüger2023-03-111-4/+21
|\ \ | |/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | rustdoc: sort deprecated items lower in search closes #98759 ### Screenshots `i32::MAX` show sup above `std::i32::MAX` and `core::i32::MAX` ![image](https://user-images.githubusercontent.com/803701/216725619-40afb7b0-e984-4a2e-ab5b-a95b24736b0e.png) If just searching for `min`, the deprecated results show up far below other things: ![image](https://user-images.githubusercontent.com/803701/216725672-e4325d37-9bfe-47eb-a1fe-0e57092aa811.png) one page later ![image](https://user-images.githubusercontent.com/803701/216725932-cd1c4a42-d527-44fb-a4ab-5a6d243659cc.png) ~~And, as you can see, the "Deprecation planned" message shows up in the search results. The same is true for fully-deprecated items like `mem::uninitialized`: ![image](https://user-images.githubusercontent.com/803701/216726268-1657e77a-563f-45a0-85a7-3a0cf4d66d6f.png)~~ Edit: the deprecation message change was removed from this PR. Only the sorting is changed.
| * rustdoc: sort deprecated items lower in searchPeter Jaszkowiak2023-03-101-4/+21
| | | | | | | | | | serialize `q` (`itemPaths`) sparsely overall 4% reduction in search index size
* | Update src/librustdoc/html/static/js/storage.jsMichael Howell2023-03-081-1/+1
| | | | | | Co-authored-by: Guillaume Gomez <guillaume1.gomez@gmail.com>
* | Fix eslint errorsGuillaume Gomez2023-03-081-0/+1
| |
* | Only load one CSS theme by defaultMichael Howell2023-03-082-33/+52
| | | | | | | | | | | | | | To avoid generating a FOUC at startup, this commit uses `document.write` to load the stylesheet initially. Co-Authored-By: Guillaume Gomez <guillaume1.gomez@gmail.com>
* | Emit an error for unclosed genericGuillaume Gomez2023-03-031-1/+13
| |
* | Put backtick content from rustdoc search errors into a <code> elementsGuillaume Gomez2023-03-021-39/+91
| |
* | Rollup merge of #108143 - notriddle:notriddle/filter-exclamation-macro, ↵Dylan DPC2023-03-011-6/+26
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | r=GuillaumeGomez rustdoc: search by macro when query ends with `!` Related to #96399 Note: the `never` type alias is tested in [`/tests/rustdoc-js-std/alias-3.js`](https://github.com/notriddle/rust/blob/08ad401633037cc226b3806a3c5f48c2f34703bf/tests/rustdoc-js-std/alias-3.js) ## Before ![image](https://user-images.githubusercontent.com/1593513/219504192-54cc0753-ff97-4a37-ad4a-8ae915181325.png) ## After ![image](https://user-images.githubusercontent.com/1593513/219504251-589a7e11-1e7b-4b7b-879d-1b564080017c.png)
| * | Update search eBNF with `!` movedMichael Howell2023-02-251-2/+2
| | | | | | | | | Co-Authored-By: GuillaumeGomez <guillaume1.gomez@gmail.com>
| * | Correct eslint warningMichael Howell2023-02-161-1/+1
| | |
| * | rustdoc: search by macro when query ends with `!`Michael Howell2023-02-161-4/+24
| | | | | | | | | | | | Related to #96399
* | | Clean up JS files code a bitGuillaume Gomez2023-02-262-13/+7
|/ /
* | rustdoc: use a string with one-character codes for search index typesMichael Howell2023-02-131-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | $ wc -c search-index.old.js search-index.new.js 3940530 search-index.old.js 3843222 search-index.new.js ((3940530-3843222)/3940530)*100 = 2.47% $ wc -c search-index.old.js.gz search-index.new.js.gz 380251 search-index.old.js.gz 379434 search-index.new.js.gz ((380251-379434)/380251)*100 = 0.214%
* | Rollup merge of #107340 - notriddle:notriddle/simplify-doctest-tooltip, ↵Matthias Krüger2023-02-131-52/+60
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | r=GuillaumeGomez rustdoc: merge doctest tooltip with notable traits tooltip Fixes https://discord.com/channels/442252698964721669/443150878111694848/1066420140167680000 <details><summary>a user report where the tooltip arrow overlaps the text</summary> ![](https://cdn.discordapp.com/attachments/443150878111694848/1066420139530145812/this-example-is-not-tested-busted-rendering.png) </details> Fixes #91100 Preview: <https://notriddle.com/notriddle-rustdoc-demos/simplify-doctest-tooltip/std/vec/struct.Vec.html#indexing> Screenshot: ![image](https://user-images.githubusercontent.com/1593513/214975516-72667632-4609-49fa-8c37-e8d2ba1ba7dc.png)
| * | rustdoc: merge doctest tooltip with notable traits tooltipMichael Howell2023-01-271-52/+60
| | | | | | | | | | | | | | | | | | Fixes https://discord.com/channels/442252698964721669/443150878111694848/1066420140167680000 Fixes #91100