about summary refs log tree commit diff
path: root/src/librustdoc/html/static
AgeCommit message (Collapse)AuthorLines
2021-03-11Auto merge of #82947 - GuillaumeGomez:fix-nojs-style-issues, r=Nemo157bors-1/+11
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: ![Screenshot from 2021-03-09 20-45-54](https://user-images.githubusercontent.com/3050060/110534652-9e048e00-811f-11eb-979e-6d85545edd65.png) After: ![Screenshot from 2021-03-09 21-01-32](https://user-images.githubusercontent.com/3050060/110534667-a1981500-811f-11eb-8a19-32f4d5381a2b.png) 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`
2021-03-10rustdoc: tweak the search index formatMichael Howell-19/+20
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.
2021-03-10Rollup merge of #82807 - notriddle:cleanup-js, r=jyn514Dylan DPC-10/+2
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.
2021-03-10Fix "run" button position in error indexGuillaume Gomez-1/+1
2021-03-09Fix typoGuillaume Gomez-1/+1
2021-03-09Fix CSS issues when javascript is disabledGuillaume Gomez-0/+10
2021-03-07Update Source Code Pro and include italicsTrevor Spiteri-3/+11
2021-03-05Use substrings instead of split to grab enum variant pathsMichael Howell-3/+3
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).
2021-03-05Remove redundant enableSearchInput functionMichael Howell-10/+2
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.
2021-03-05Use global variables instead of functions for DOM IDsGuillaume Gomez-16/+11
2021-03-05Clean up code around theme elementsGuillaume Gomez-11/+19
2021-03-05Remove theme.js file creation and move its code inside main.jsGuillaume Gomez-10/+69
2021-03-04Remove unused code from main.jsMichael Howell-20/+0
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
2021-03-04Rollup merge of #82315 - jsha:font-display-swap, r=GuillaumeGomezYuki Okushi-3/+11
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.
2021-03-02Use Arial as fallback font instead of sans-serif.Jacob Hoffman-Andrews-3/+3
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.
2021-03-02Improve page load performance in rustdoc.Jacob Hoffman-Andrews-0/+8
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.
2021-03-02Load rustdoc's JS search index on-demand.Jacob Hoffman-Andrews-42/+56
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.
2021-02-27Auto merge of #82511 - jsha:fix-bfcache2, r=GuillaumeGomezbors-6/+14
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
2021-02-26Rollup merge of #82549 - rust-lang:revert-82313-update-normalize-css, r=apirainoGuillaume Gomez-1/+1
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``
2021-02-26Rollup merge of #82545 - jsha:woff2, r=GuillaumeGomezGuillaume Gomez-2/+6
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.
2021-02-26Revert "Update normalize.css to 8.0.1"Guillaume Gomez-1/+1
2021-02-26Add optional woff2 versions of FiraSans.Jacob Hoffman-Andrews-2/+6
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.
2021-02-25Rollup merge of #82313 - jsha:update-normalize-css, r=GuillaumeGomezDylan DPC-1/+1
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> ![with-normalize-8 0 1](https://user-images.githubusercontent.com/220205/108581849-bd5c8800-72e4-11eb-9150-78c8d67ca37a.png) ![with-normalize-3 0 0](https://user-images.githubusercontent.com/220205/108581848-bcc3f180-72e4-11eb-8b45-0cd1415a51e5.png) ![diff](https://user-images.githubusercontent.com/220205/108581890-dfeea100-72e4-11eb-93c5-6284492f54a9.png) </details>
2021-02-24Fix back-forward cache in rustdoc frontend.Jacob Hoffman-Andrews-6/+14
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/
2021-02-23Rollup merge of #82234 - GuillaumeGomez:remove-query-param-on-esc, r=Nemo157Dylan DPC-1/+6
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```
2021-02-19Re-minify normalize.css.Jacob Hoffman-Andrews-349/+2
This bypasses tidy's complaints about tab indent. Also, this lets us remove comments while keeping the MIT license comment.
2021-02-19Update normalize.css to 8.0.1Jacob Hoffman-Andrews-232/+158
From https://github.com/necolas/normalize.css/releases/tag/8.0.1.
2021-02-19Replace normalize.css 3.0.0 with unminified version.Jacob Hoffman-Andrews-2/+423
This is in preparation to upgrade to 8.0.1, so the next commit can contain more meaningful diffs.
2021-02-17Remove query parameters when leaving search resultsGuillaume Gomez-1/+6
2021-02-15Fix ES5 errors (IE11)Guillaume Gomez-6/+12
2021-02-10Fix getCurrentValueOphir LOJKINE-1/+1
2021-02-10Catch errors on localStorage setting failureOphir LOJKINE-23/+8
Fixes https://github.com/rust-lang/rust/issues/81928 “Ask forgiveness not permission” : this makes the code both simpler and more robust
2021-02-02Better styling of "Switch result tab" shortcutSmitty-2/+2
2021-02-02Rollup merge of #81630 - GuillaumeGomez:overflow-sidebar-title-text, r=pickfireJonas Schievink-0/+8
Fix overflowing text on mobile when sidebar is displayed Fixes #81597. Before: ![Screenshot from 2021-02-01 17-21-15](https://user-images.githubusercontent.com/3050060/106486857-610b0300-64b2-11eb-96d3-12b939f5b661.png) After: ![Screenshot from 2021-02-01 17-20-59](https://user-images.githubusercontent.com/3050060/106486840-5cdee580-64b2-11eb-9492-4df27bb39e59.png) cc `@pickfire` r? `@Nemo157`
2021-02-01Fix overflowing text on mobile when sidebar is displayedGuillaume Gomez-0/+8
2021-02-01Rollup merge of #81592 - GuillaumeGomez:rustdoc-ui-fixes, r=Nemo157Jonas Schievink-11/+2
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...): ![Screenshot from 2021-01-31 12-58-46](https://user-images.githubusercontent.com/3050060/106384371-d56a7700-63ca-11eb-9e04-c06b40c2ab5e.png) 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: ![Screenshot from 2021-01-31 13-22-37](https://user-images.githubusercontent.com/3050060/106384413-021e8e80-63cb-11eb-8321-391a1f8a4c7e.png) The third and last commit fixes two bugs that you can see in this screenshot: ![Screenshot from 2021-01-31 13-41-05](https://user-images.githubusercontent.com/3050060/106384424-0cd92380-63cb-11eb-82de-76218286c3fb.png) 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: ![Screenshot from 2021-01-31 13-49-50](https://user-images.githubusercontent.com/3050060/106384466-4447d000-63cb-11eb-9330-a7cd29403905.png) cc ```@pickfire``` r? ```@Nemo157```
2021-01-31Improve resize handlingGuillaume Gomez-1/+1
2021-01-31Prevent search section to go over search inputGuillaume Gomez-1/+1
2021-01-31Remove unneeded explicit width from search resultsGuillaume Gomez-9/+0
2021-01-31Rollup merge of #81563 - pickfire:patch-6, r=GuillaumeGomezJonas Schievink-0/+4
Improve docblock readability on small screen Before ![image](https://user-images.githubusercontent.com/4687791/106363174-f77bdf00-6361-11eb-898f-d480b8460ab3.png) After ![image](https://user-images.githubusercontent.com/4687791/106363259-6bb68280-6362-11eb-85a1-ef9262681dd7.png) Too much space is wasted on the left side. I wanted to make that 0 but it breaks some part with error symbols. 0 ![image](https://user-images.githubusercontent.com/4687791/106363287-90aaf580-6362-11eb-88c1-62a8313988a7.png) After ![image](https://user-images.githubusercontent.com/4687791/106363276-825cd980-6362-11eb-86eb-6f4611b4ab99.png)
2021-01-31Remove extra trailing spacesIvan Tham-1/+1
2021-01-31Fix docblock short code missing end whitespacesIvan Tham-0/+3
2021-01-31Improve docblock readability on small screenIvan Tham-0/+4
2021-01-31Fix ascii art text wrapping in mobileIvan Tham-3/+1
Fix #81377
2021-01-28Rollup merge of #81379 - GuillaumeGomez:improve-urls, r=Nemo157Yuki Okushi-7/+17
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`````
2021-01-25Improve URL handling when clicking on a menu link while being on the search ↵Guillaume Gomez-7/+16
results and overall
2021-01-25Completely remove search query parameter when clearing search inputGuillaume Gomez-1/+2
2021-01-25Fix some bugs reported by eslintGuillaume Gomez-31/+33
2021-01-19Rollup merge of #81161 - GuillaumeGomez:remove-inline-script, r=Nemo157Guillaume Gomez-12/+27
Remove inline script tags Fixes #81133. cc ``@pietroalbini`` r? ``@Nemo157``
2021-01-19Rollup merge of #80382 - GuillaumeGomez:search-result-tab-picking, ↵Guillaume Gomez-0/+15
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`