Michael Howell
54ef3a4786
rustdoc-search: update docs for comma in ? help popover
2023-03-31 10:18:44 -07:00
Matthias Krüger
b39db705f5
Rollup merge of #109633 - GuillaumeGomez:fix-go-to-only-setting, r=notriddle
...
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`
2023-03-27 08:46:53 +02:00
Guillaume Gomez
28982a1e47
Fix "Directly go to item in search if there is only one result" setting
2023-03-26 17:50:09 +02:00
Matthias Krüger
8c8305843b
Rollup merge of #109542 - notriddle:notriddle/storage-js, r=GuillaumeGomez
...
rustdoc: clean up `storage.js`
2023-03-25 03:37:11 +01:00
Matthias Krüger
eb46afb216
Rollup merge of #108629 - notriddle:notriddle/item-type-advanced, r=GuillaumeGomez
...
rustdoc: add support for type filters in arguments and generics
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).
2023-03-24 01:22:03 +01:00
Michael Howell
95ef91c573
rustdoc: remove old content hack for theme switching
...
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
2023-03-23 14:25:43 -07:00
Michael Howell
ba3d6055ad
rustdoc: clean up storage.js
...
This converts a few functions to more compact versions of
themselves, and moves `RUSTDOC_MOBILE_BREAKPOINT` to main.js where
it's actually used.
2023-03-23 14:19:50 -07:00
Michael Howell
9852980594
rustdoc: remove redundant .content prefix from span/a colors
...
Reverts a1d4ebe496 , as well as
fixing the problem it solved with links losing their color.
2023-03-21 15:39:21 -07:00
Michael Howell
e600c0ba0e
rustdoc: add support for type filters in arguments and generics
...
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).
2023-03-20 22:41:57 -07:00
Michael Howell
5451fe7d7c
rustdoc: implement bag semantics for function parameter search
...
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.
2023-03-19 18:19:24 -07:00
Matthias Krüger
afe257554c
Rollup merge of #109009 - notriddle:notriddle/edit-distance, r=GuillaumeGomez
...
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 !
2023-03-12 20:44:50 +01:00
Michael Howell
ce795d9ca8
rustdoc: collapse edit distance state into an object
2023-03-11 20:39:15 -07:00
Matthias Krüger
8596751f3b
Rollup merge of #107629 - pitaj:rustdoc-search-deprecated, r=jsha
...
rustdoc: sort deprecated items lower in search
closes #98759
### Screenshots
`i32::MAX` show sup above `std::i32::MAX` and `core::i32::MAX`

If just searching for `min`, the deprecated results show up far below other things:

one page later

~~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`:
~~
Edit: the deprecation message change was removed from this PR. Only the sorting is changed.
2023-03-11 12:55:41 +01:00
Michael Howell
dfd9e5e3fa
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.
2023-03-10 19:47:08 -07:00
bors
6dfaa14366
Auto merge of #104527 - ferrocene:pa-more-licenses, r=pnkfelix
...
Add more license annotations
This PR updates the `.reuse/dep5` file to include more accurate licensing data for everything in the repository (*excluding* submodules and dependencies). Some decisions were made in this PR:
* The standard copyright attribution for files maintained by us is "The Rust Project Developers (see https://thanks.rust-lang.org )", to avoid having to maintain an in-tree `AUTHORS` file.
* For files that have specific licensing terms, we added the terms to the `.reuse/dep5` rather than adding SPDX comments in the files themselves.
* REUSE picks up any comment/text line with `Copyright` on it, so I had to sprinkle around `REUSE-IgnoreStart` and `REUSE-IgnoreEnd` comments.
The rendered `COPYRIGHT` file is available at https://gist.github.com/pietroalbini/efb81103f69596d39758114f3f6a8688 .
r? `@pnkfelix`
2023-03-11 01:17:23 +00:00
Peter Jaszkowiak
d2e4b59e60
rustdoc: sort deprecated items lower in search
...
serialize `q` (`itemPaths`) sparsely
overall 4% reduction in search index size
2023-03-10 12:20:38 -07:00
Pietro Albini
89867e8b45
avoid reuse tripping over copyright notices
2023-03-09 12:24:43 +01:00
Michael Howell
255fdb398e
Update src/librustdoc/html/static/js/storage.js
...
Co-authored-by: Guillaume Gomez <guillaume1.gomez@gmail.com>
2023-03-08 12:49:35 -07:00
Guillaume Gomez
5db516b809
Fix eslint errors
2023-03-08 12:49:34 -07:00
Michael Howell
f916681d8d
Only load one CSS theme by default
...
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>
2023-03-08 12:49:34 -07:00
Guillaume Gomez
51e976948d
Emit an error for unclosed generic
2023-03-03 20:49:25 +01:00
Guillaume Gomez
4e560d7d0b
Put backtick content from rustdoc search errors into a <code> elements
2023-03-02 12:59:04 +01:00
Dylan DPC
f03e5345aa
Rollup merge of #108143 - notriddle:notriddle/filter-exclamation-macro, 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`](08ad401633/tests/rustdoc-js-std/alias-3.js )
## Before

## After

2023-03-01 23:40:18 +05:30
Guillaume Gomez
27db688203
Clean up JS files code a bit
2023-02-26 20:58:36 +01:00
Michael Howell
96e6fb6c57
Update search eBNF with ! moved
...
Co-Authored-By: GuillaumeGomez <guillaume1.gomez@gmail.com>
2023-02-25 08:20:53 -07:00
Dylan DPC
4165de40f8
Rollup merge of #107783 - notriddle:notriddle/item-table-ul, r=GuillaumeGomez
...
rustdoc: simplify DOM for `.item-table`
This switches from using `<div>` to the more semantic `<ul>`, and using class names that rhyme with the classes the search results table uses.
2023-02-19 13:03:41 +05:30
Michael Howell
d963318c1d
Correct eslint warning
2023-02-16 19:22:03 -07:00
Michael Howell
4de9c6d491
rustdoc: search by macro when query ends with !
...
Related to #96399
2023-02-16 18:16:09 -07:00
Michael Howell
a7b69ddea9
rustdoc: use a string with one-character codes for search index types
...
$ 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%
2023-02-13 14:27:00 -07:00
Matthias Krüger
3054759fa8
Rollup merge of #107340 - notriddle:notriddle/simplify-doctest-tooltip, 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>

</details>
Fixes #91100
Preview: <https://notriddle.com/notriddle-rustdoc-demos/simplify-doctest-tooltip/std/vec/struct.Vec.html#indexing >
Screenshot:

2023-02-13 11:34:56 +01:00
Matthias Krüger
1d4397ba70
Rollup merge of #107964 - notriddle:notriddle/title-line-height, r=GuillaumeGomez
...
rustdoc: use tighter line height in h1 and h2
This keeps the line height for body text the same, as required by WCAG, but for headers, it makes sense to have wrapped lines be a bit tighter packed.
## Before

## After

2023-02-12 22:29:50 +01:00
Matthias Krüger
76c47fb904
Rollup merge of #107930 - GuillaumeGomez:js-func-improvement, r=notriddle
...
Improve JS function itemTypeFromName code a bit
Very small code improvement replacing a `for` loop with `findIndex` method.
r? ````@notriddle````
2023-02-12 22:29:48 +01:00
Michael Howell
b0df355f80
rustdoc: use tighter line height in h1 and h2
2023-02-12 12:30:57 -07:00
Guillaume Gomez
d505c5abe4
Improve JS function itemTypeFromName code a bit
2023-02-11 18:03:21 +01:00
Dylan DPC
9af90ffa3c
Rollup merge of #107490 - notriddle:notriddle/rm-sidebar-tooltip, r=GuillaumeGomez
...
rustdoc: remove inconsistently-present sidebar tooltips
Discussed in https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/Inconsistent.20sidebar.20tooltips/near/323565625
2023-02-11 11:15:55 +05:30
Michael Howell
8cb5be96c4
rustdoc: use [svgo] to shrink wheel.svg
...
[svgo]: https://github.com/svg/svgo
$ du -bs src/librustdoc/html/static/images/wheel.svg wheel-old.svg
2972 src/librustdoc/html/static/images/wheel.svg
3764 wheel-old.svg
100*((2972-3764)/3764) = -21.04%
2023-02-08 14:17:19 -07:00
Michael Howell
894c98652c
rustdoc: simplify DOM for .item-table
...
This switches from using `<div>` to the more semantic `<ul>`, and
using class names that rhyme with the classes the search results
table uses.
2023-02-07 19:00:42 -07:00
Dylan DPC
fc791cb209
Rollup merge of #107669 - notriddle:notriddle/ayu-smaller, r=GuillaumeGomez
...
rustdoc: combine duplicate rules in ayu CSS
2023-02-06 19:54:14 +05:30
bors
7c3f0d6f30
Auto merge of #107141 - notriddle:notriddle/max-lev-distance-2023, r=GuillaumeGomez
...
rustdoc: compute maximum Levenshtein distance based on the query
Preview: https://notriddle.com/notriddle-rustdoc-demos/search-lev-distance-2023/std/index.html?search=regex
The heuristic is pretty close to the name resolver, maxLevDistance = `Math.floor(queryLen / 3)`.
Fixes #103357
Fixes #82131
Similar to https://github.com/rust-lang/rust/pull/103710 , but following the suggestion in https://github.com/rust-lang/rust/pull/103710#issuecomment-1296360267 to use `floor` instead of `ceil`, and unblocked now that https://github.com/rust-lang/rust/pull/105796 made it so that setting the max lev distance to `0` doesn't cause substring matches to be removed.
2023-02-06 02:09:00 +00:00
Roland Strasser
71a147df1f
rustdoc: trait bound formatting
...
rustdoc: fix item-spacer
rustdoc: use proper comment style
rustdoc: change formatting where clauses for traits
rustdoc: remove semicolon from provided methods
update provided methods formatting
2023-02-04 19:10:04 +01:00
Michael Howell
b1c4911b2a
rustdoc: combine duplicate rules in ayu CSS
2023-02-04 10:14:51 -07:00
Michael Howell
784665d4ce
Replace nbsp in all rustdoc code blocks
...
Co-Authored-By: David Tolnay <dtolnay@gmail.com>
2023-02-03 08:15:44 -07:00
Matthias Krüger
75ea3a9948
Rollup merge of #107531 - GuillaumeGomez:inline-images-in-css, r=notriddle
...
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-02 06:52:15 +01:00
Guillaume Gomez
63f82db958
Inline CSS background images directly into the CSS
2023-02-01 11:51:02 +01:00
Guillaume Gomez
9e0bfe0fb0
Rollup merge of #107527 - notriddle:notriddle/wcagcontrast, r=GuillaumeGomez
...
rustdoc: stop making unstable items transparent
Fixes #93393
2023-01-31 23:38:54 +01:00
Guillaume Gomez
f0e4a1c9cb
Rollup merge of #107491 - notriddle:notriddle/setting-check, r=GuillaumeGomez
...
rustdoc: remove unused CSS from `.setting-check`
These rules were needed for the mobile-style switches, but those were removed in 0f3ae6218e
2023-01-31 23:38:53 +01:00
Guillaume Gomez
233b319a37
Rollup merge of #107354 - tspiteri:source-serif-4.005, r=GuillaumeGomez
...
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-31 23:38:50 +01:00
Michael Howell
f75b350467
rustdoc: stop making unstable items transparent
...
Fixes #93393
2023-01-31 11:27:09 -07:00
Michael Howell
3a20cbf9fc
rustdoc: remove inconsistently-present sidebar tooltips
...
Discussed in
https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/Inconsistent.20sidebar.20tooltips/near/323565625
2023-01-31 10:12:13 -07:00
Guillaume Gomez
0a1f14a0e6
Clean up eslint annotations and remove unused JS function
2023-01-31 11:21:29 +01:00