| Age | Commit message (Collapse) | Author | Lines |
|
Fix nojs style issues
There are two issues fixed here:
1. The position of "{version}" and "[src]" spans.
2. The position of attributes (on top of functions)
Please note that these issues only happen if you have disabled javascript.
Before:

After:

In the last commit, I added a test to enforce the attributes position. I need to think how to enforce it for the spans but that can comes later on.
r? `@Nemo157`
|
|
This essentially switches search-index.js from a "array of struct"
to a "struct of array" format, like this:
{
"doc": "Crate documentation",
"t": [ 1, 1, 2, 3, ... ],
"n": [ "Something", "SomethingElse", "whatever", "do_stuff", ... ],
"q": [ "a::b", "", "", "", ... ],
"d": [ "A Struct That Does Something", "Another Struct", "a function", "another function", ... ],
"i": [ 0, 0, 1, 1, ... ],
"f": [ null, null, [], [], ... ],
"p": ...,
"a": ...
}
So `{ty: 1, name: "Something", path: "a::b", desc: "A Struct That Does Something", parent_idx: 0, search_type: null}` is the first item.
This makes the uncompressed version smaller, but it really shows on the
compressed version:
notriddle:rust$ wc -c new-search-index1.52.0.js
2622427 new-search-index1.52.0.js
notriddle:rust$ wc -c old-search-index1.52.0.js
2725046 old-search-index1.52.0.js
notriddle:rust$ gzip new-search-index1.52.0.js
notriddle:rust$ gzip old-search-index1.52.0.js
notriddle:rust$ wc -c new-search-index1.52.0.js.gz
239385 new-search-index1.52.0.js.gz
notriddle:rust$ wc -c old-search-index1.52.0.js.gz
296328 old-search-index1.52.0.js.gz
notriddle:rust$
That's a 4% improvement on the uncompressed version (fewer `[]`),
and 20% improvement after gzipping it, thanks to putting like-typed
data next to each other. Any compression algorithm based on a sliding
window will probably show this kind of improvement.
|
|
rustdoc: Remove redundant enableSearchInput function
enableSearchInput was called from two places:
- setupSearchLoader
- addSearchOptions, which is itself called from setupSearchLoader only
This commit can safely get rid of the addSearchOptions calls entirely, and since the setupSearchLoader call is immediately preceded by other method calls on search_input, there's no need to check if it's set.
|
|
|
|
|
|
|
|
|
|
Both versions are about equally readable, but this version avoids scanning
the entire path and building an intermediate array (`split()` in Rust is
a lazy iterator, but not in JavaScript).
|
|
enableSearchInput was called from two places:
- setupSearchLoader
- addSearchOptions, which is itself called from setupSearchLoader only
This commit can safely get rid of the addSearchOptions calls entirely,
and since the setupSearchLoader call is immediately preceded by other
method calls on search_input, there's no need to check if it's set.
|
|
|
|
|
|
|
|
It looks like `lev_distance` was used in a very old version of the function,
since it was written but never read, and Blame reports that it was added
before the `checkGenerics` function header itself.
`convertHTMLToPlaintext` is was removed by 768d5e950953738a54480e530341964838d29da2
|
|
Improve page load performance in rustdoc
Add an explicit height to icons (which already had an explicit width) to allow browsers to lay out the page more accurately before the icons have been loaded. https://web.dev/optimize-cls/.
Add min-width: 115px to the crate search dropdown. When the HTML first loads, this dropdown includes only the text "All crates." Later, JS loads the items underneath it, some of which are wider. That causes the dropdown to get wider, causing a distracting reflow. This sets a min-width based on the size that the dropdown eventually becomes based on the crates on doc.rust-lang.org, reducing page movement during load.
Add font-display: swap. Per https://web.dev/font-display/, this prevents "flash of invisible text" during load by using a system font until the custom font is available. I've noticed this flash of invisible text occasionally when reading Rust docs. Note that users without cached fonts will see text, and then see it reflow. For `docs.rust-lang.org`, [setting caching headers will help a lot](https://github.com/rust-lang/simpleinfra/issues/62).
Generated output at https://jacob.hoffman-andrews.com/rust/flow-improvements/std/string/struct.String.html.
|
|
On most platforms and browsers, `sans-serif` is equivalent to Arial.
However, on Firefox on Ubuntu (and possibly other Linuxes), `sans-serif`
is DejaVu Sans, a much wider font. This creates a larger shift in text
when the custom fonts finally load. Arial is a web-safe font, and
specifying it explicitly gives us more cross-platform consistency, as
well as reducing the layout shift that happens when fonts load.
|
|
Add font-display: swap. Per https://web.dev/font-display/, this prevents
"flash of invisible text" during load by using a system font until the
custom font is available. I've noticed this flash of invisible text
occasionally when reading Rust docs.
Add an explicit height to icons (which already had an explicit width)
to allow browsers to lay out the page more accurately before the icons
have been loaded. https://web.dev/optimize-cls/.
Add min-width: 115px to the crate search dropdown. When the HTML first
loads, this dropdown includes only the text "All crates." Later, JS
loads the items underneath it, some of which are wider. That causes
the dropdown to get wider, causing a distracting reflow. This sets a
min-width based on the size that the dropdown eventually becomes based
on the crates on doc.rust-lang.org, reducing page movement during load.
|
|
Instead of being loaded on every page, the JS search index is now
loaded when either (a) there is a `?search=` param, or (b) the search
input is focused.
This saves both CPU and bandwidth. As of Feb 2021,
https://doc.rust-lang.org/search-index1.50.0.js is 273,838 bytes
gzipped or 2,544,939 bytes uncompressed. Evaluating it takes 445 ms
of CPU time in Chrome 88 on a i7-10710U CPU (out of a total ~2,100
ms page reload).
Generate separate JS file with crate names.
This is much smaller than the full search index, and is used in the "hot
path" to draw the page. In particular it's used to crate the dropdown
for the search bar, and to append a list of crates to the sidebar (on
some pages).
Skip early search that can bypass 500ms timeout.
This was occurring when someone had typed some text during the load of
search-index.js. Their query was usually not ready to execute, and the
search itself is fairly expensive, delaying the overall load, which
delayed the input / keyup events, which delayed eventually executing the
query.
|
|
Fix back-forward cache in rustdoc frontend
Rustdoc's frontend set a no-op unload handler, specifically to disable
Firefox's back-forward cache because it caused a bug. It's nice to
allow the back-forward cache because it permits faster navigations.
This change addresses the issues that were caused by back-forward cache.
https://developer.mozilla.org/en-US/docs/Mozilla/Firefox/Releases/1.5/Using_Firefox_1.5_caching
https://web.dev/bfcache/
Demo: https://jacob.hoffman-andrews.com/rust/fix-bfcache/std/string/struct.String.html
Related: #72272
|
|
Revert "Update normalize.css to 8.0.1"
Reverts rust-lang/rust#82313
Fixes #82548
Fixes #82542
``@jsha:`` I'm reverting until we can come up with a new version which is fully working.
r? ``@jyn514``
|
|
rustdoc: add optional woff2 versions of FiraSans.
For browsers that support woff2 (most modern ones:
https://caniuse.com/woff2), this offers a reduction in download size
for these two fonts from 362k to 257k (32% reduction). It decreases the
total page size for `struct.String.html` (counting all subresources) by
about 2.5%.
If this is interesting, I'm happy to apply the same treatment to the
other fonts, but these two are the biggest.
|
|
|
|
For browsers that support woff2 (most modern ones:
https://caniuse.com/woff2), this offers a reduction in download size
for these two fonts from 362k to 257k (32% reduction). It decreases the
total page size for `struct.String.html` (counting all subresources) by
about 2.5%.
If this is interesting, I'm happy to apply the same treatment to the
other fonts, but these two are the biggest.
|
|
Update normalize.css to 8.0.1
From From https://github.com/necolas/normalize.css/releases/tag/8.0.1.
The old version was 3.0.0, from 2014. The new version is from 2018.
I noticed when looking at frontend performance for rustdoc that this file was out of date. The URL in the 3.0.0 license header now resolves to an incorrect destination. And generally it seems good to be up-to-date.
Before-and-after images, plus diff, under details. TL;DR: Nothing changes except a slight adjustment to line height.
<details>



</details>
|
|
Rustdoc's frontend set a no-op unload handler, specifically to disable
Firefox's back-forward cache because it caused a bug. It's nice to
allow the back-forward cache because it permits faster navigations.
This change addresses the issues that were caused by back-forward cache.
https://developer.mozilla.org/en-US/docs/Mozilla/Firefox/Releases/1.5/Using_Firefox_1.5_caching
https://web.dev/bfcache/
|
|
Remove query parameters when skipping search results
Fixes #81330.
This PR changes the following: when pressing ESC and that no other "action" was performed (understand: no closing the search result, or hiding a menu or something along the line), then we discard the URL query parameters (the `?whatever=dsjfs`). What do you think about this change ```@rust-lang/rustdoc``` ?
EDIT: finally we're simply removing the query parameter when we're skipping the search results.
r? ```@Nemo157```
|
|
This bypasses tidy's complaints about tab indent. Also, this lets us
remove comments while keeping the MIT license comment.
|
|
From https://github.com/necolas/normalize.css/releases/tag/8.0.1.
|
|
This is in preparation to upgrade to 8.0.1, so the next commit
can contain more meaningful diffs.
|
|
|
|
|
|
|
|
Fixes https://github.com/rust-lang/rust/issues/81928
“Ask forgiveness not permission” : this makes the code both simpler and more robust
|
|
|
|
Fix overflowing text on mobile when sidebar is displayed
Fixes #81597.
Before:

After:

cc `@pickfire`
r? `@Nemo157`
|
|
|
|
Rustdoc UI fixes
The first commit fixes this bug (I couldn't figure out why we were setting the width manually and it works as expected without so...):

The second commit fixes a small bug. On tablets or computer with very little width, the search section goes "over" the search input, making it impossible to click on the search input:

The third and last commit fixes two bugs that you can see in this screenshot:

The wheel is going over the search input and the search tab is going under the search results text. The bug was fixed by simply switching to "mobile mode" at a bigger width:

cc ```@pickfire```
r? ```@Nemo157```
|
|
|
|
|
|
|
|
Improve docblock readability on small screen
Before

After

Too much space is wasted on the left side. I wanted to make that 0 but it breaks some part with error symbols.
0

After

|
|
|
|
|
|
|
|
Fix #81377
|
|
Improve URLs handling
Fixes #81330.
Explanations: before this PR, when emptying the search input, we still had `?search=` in the URL, which wasn't very nice. Now, if the search is empty, we drop the `?search=` part.
Also, I realized while working on this PR that when we clicked on a menu link when we were on the search results, the search parameters would look like: `?search=#the-anchor`, which was super weird. Now, it looks like this: `?search=the-search#the-anchor`.
Also, I didn't use the `Url` very nice API because it's not available in any IE version (sadness...).
cc `````@lzutao`````
r? `````@Nemo157`````
|
|
results and overall
|
|
|
|
|
|
Remove inline script tags
Fixes #81133.
cc ``@pietroalbini``
r? ``@Nemo157``
|
|
r=Nemo157,pickfire
Improve search result tab handling
Fixes #80378.
If the current search result tab is empty, it picks the first non-empty one. If all are empty, the current one doesn't change. It can be tested with "-> string" (where only the "returned elements" tab is not empty).
r? `@jyn514`
|