Commit Graph

56 Commits

Author SHA1 Message Date
Guillaume Gomez
b98fb490b8 Correctly handle crate level page on docs.rs as well 2022-07-14 20:26:45 +02:00
Matthias Krüger
f916c7fbb9
Rollup merge of #98709 - GuillaumeGomez:rm-decl-for-old-browsers, r=Dylan-DPC
Remove unneeded methods declaration for old web browsers

All these methods were not defined for IE mostly. But since we don't support it anymore, no need to keep them around.

cc ```@jsha```
r? ```@notriddle```
2022-06-30 19:55:56 +02:00
Guillaume Gomez
be580a0120 Remove unneeded methods declaration for old web browsers 2022-06-30 13:23:13 +02:00
Michael Howell
f5f42a8cba rustdoc: make keyboard commands work when checkboxes are selected 2022-06-28 17:29:55 -07:00
Michael Howell
cb8a7388fa rustdoc: fix keyboard shortcuts bug in settings menu
This commit fixes the keyboard shorts code to call localStorage every time a
key is pressed. This matters because you're supposed to be able to change a
setting and have it immediately take effect.
2022-06-28 17:29:37 -07:00
Michael Howell
cec6988a07 rustdoc: fix help menu popover toggling 2022-06-28 16:02:44 -07:00
Guillaume Gomez
e4b2b41290 Merge all popover hide functions into one 2022-06-23 00:22:25 +02:00
Guillaume Gomez
cc4f804829 Move help popup into a pocket menu as well 2022-06-23 00:22:25 +02:00
Jacob Hoffman-Andrews
27dcebeb3e Improve loading of crates.js and sidebar-items.js
Now that the "All Crates" dropdown is only rendered on the search results page,
there is no need to load crates.js on most pages. Load it only on crate pages.
Also, add the `defer` attribute so it does not block page rendering.

For sidebar-items.js, move the script tag to `<head>`. Since it already has the
defer attribute it won't block loading. The defer attribute does preserve
ordering between scripts, so instead of the callback on load, it can set a
global variable on load, which is slightly simpler. Also, since it is required
to finish rendering the page, beginning its load earlier is better.

Remove generation and handling of sidebar-vars. Everything there can be computed
with information available in JS via other means.

Remove the "other" wrapper in the sidebar. It was unnecessary.

Remove excess script fields
2022-06-20 11:12:55 -07:00
Guillaume Gomez
116eec247a Add "no-confusing-arrow" eslint check 2022-06-06 13:57:54 +02:00
Guillaume Gomez
334f12c28e Add "eqeqeq" eslint rule 2022-05-27 22:30:19 +02:00
Guillaume Gomez
6c7156d488 Add new eslint rule "space-before-function-paren" 2022-05-25 13:55:09 +02:00
Guillaume Gomez
5d84c0c569 Add new eslint rule about brace style 2022-05-15 13:59:51 +02:00
Guillaume Gomez
e8762757c3 Remove theme picker button 2022-05-14 17:21:52 +02:00
Guillaume Gomez
14897180ae Enforce quote rule for JS source code 2022-05-07 20:50:55 +02:00
Folyd
a8ede1248d Change eslint rules from configuration comments to configuration files 2022-05-07 11:47:30 +08:00
Guillaume Gomez
bcfb95afd3
Rollup merge of #96754 - notriddle:notriddle/impl-dups, r=GuillaumeGomez
rustdoc: ensure HTML/JS side implementors don't have dups

Fixes #94641

Rendered:

- https://notriddle.com/notriddle-rustdoc-test/impl-dups/std/iter/trait.Iterator.html
- https://notriddle.com/notriddle-rustdoc-test/impl-dups/core/iter/trait.Iterator.html
2022-05-06 20:05:43 +02:00
Michael Goulet
7cdad77536
Rollup merge of #96741 - GuillaumeGomez:improve-settings-loading-strategy, r=jsha
Improve settings loading strategy

I learned about this thanks to ```@jsha``` who suggested this approach:

It improves the settings loading strategy by loading CSS and JS at the same time to prevent the style to be applied afterwards on slow connections.

r? ```@jsha```
2022-05-05 19:34:25 -07:00
Michael Goulet
292eefe753
Rollup merge of #96704 - GuillaumeGomez:rotation-animation, r=jsha
Add rotation animation on settings button when loading

As discussed, I added an animation when the settings JS file is loading (I voluntarily made the timeout at the end of the `settings.js` super long so we can see what the animation looks like):

https://user-images.githubusercontent.com/3050060/166693243-816a08b7-5e39-4142-acd3-686ad9950d8e.mp4

r? ````@jsha````
2022-05-05 19:34:24 -07:00
Michael Howell
20010d7597 rustdoc: ensure HTML/JS side implementors don't have dups 2022-05-05 17:45:33 -07:00
Guillaume Gomez
87b6326d67 Improve settings loading strategy by loading CSS and JS at the same time to prevent the style to be applied afterwards on slow connections 2022-05-05 20:19:40 +02:00
Guillaume Gomez
13b45aa6c6 Add rotation animation on settings button when loading 2022-05-05 11:08:15 +02:00
Guillaume Gomez
1e204ddb3b Use "strict" mode in JS scripts 2022-05-05 11:07:14 +02:00
Folyd
67ebeea7a0 Move callback to the () => {} syntax.
Fix lint

Fix main.js

Restore anonymous functions

Fix

Fix more
2022-05-04 11:10:48 +08:00
Guillaume Gomez
73688e4021 * Add documentation for settings page rendering functions.
* Improve code.
* Fix some documentation argument types.
* Make settings order the same as before this PR.
* Change timeout to 0 so that browser will render it as fast as possible.
2022-05-01 21:22:38 +02:00
Guillaume Gomez
9625ed8be7 Move settings into full JS 2022-04-30 13:12:41 +02:00
Guillaume Gomez
4e0be6ddeb Remove dead code in main.js 2022-04-26 20:59:33 +02:00
Guillaume Gomez
016334a3ad Migrate main.js to ES6 2022-04-26 20:59:32 +02:00
Guillaume Gomez
a5216cf67d Unify inherent impl blocks by wrapping them into a div 2022-03-08 23:12:11 +01:00
Jacob Hoffman-Andrews
e27ebb5dff Linkify sidebar headings for sibling items
Also adjust CSS so this doesn't produce excess padding/margin.
2022-02-05 22:11:27 -08:00
Matthias Krüger
f2721fab23
Rollup merge of #92735 - GuillaumeGomez:crate-filter-url-param, r=jsha
Add crate filter parameter in URL

Fixes #92621.

r? `@jsha`
2022-02-04 14:58:56 +01:00
Guillaume Gomez
cfa677666c Add filter-crate URL parameter 2022-02-03 22:59:33 +01:00
Jacob Hoffman-Andrews
a998a37476 rustdoc: small fixes to mobile navigation
- Make sure the mobile-topbar doesn't overflow its height if the user
  sets a bigger font.

- Make sure the sidebar can be scrolled all the way to the bottom by
  shortening it to accommodate the mobile-topbar.

- Make the item name in the mobile-topbar clickable to go to the top of
  the page.

- Remove excess padding sidebar in mobile mode.
2022-01-29 17:13:14 -08:00
Jacob Hoffman-Andrews
6a5f8b1aef Simplify and unify rustdoc sidebar styles
This switches to just use size, weight, and spacing to distinguish
headings in the sidebar. We no longer use boxes, horizontal bars, or
centering to distinguish headings. This makes it much easier to
understand the hierarchy of headings, and reduces visual noise.

I also refactored how the mobile topbar works. Previously, we tried to
shift around elements from the sidebar to make the topbar. Now, the
topbar gets its own elements, which can be styled on their own. This
makes styling and reasoning about those elements simpler.

Because the heading font sizes are bigger, increase the sidebar width
slightly.

As a very minor change, removed version from the "All types" page. It's
now only on the crate page.
2022-01-18 10:43:14 -08:00
Matthias Krüger
deee6f770f
Rollup merge of #92830 - jsha:style-cleanups, r=GuillaumeGomez
Rustdoc style cleanups

 - Make "since" version numbers grey again (regressed in #92602).
 - Remove unneeded selectors for when crate filter dropdown is a
   sibling of search-input.
 - Crate filter dropdown doesn't need to be 100% width on mobile.
 - Only build crate filter dropdown when there is more than one crate.
 - Remove unused addCrateDropdown

 Demo: https://rustdoc.crud.net/jsha/style-cleanups/std/string/struct.String.html

 r? `@GuillaumeGomez`
2022-01-18 04:42:02 +01:00
Matthias Krüger
cc2339ce83
Rollup merge of #92803 - jsha:hide-sidebar, r=GuillaumeGomez
Hide mobile sidebar on some clicks

When the user clicks outside the sidebar, the sidebar should close. Also, when the user clicks an internal link in the sidebar, it should close.

Fixes #92682

Demo: https://rustdoc.crud.net/jsha/hide-sidebar/std/string/struct.String.html
2022-01-18 04:42:00 +01:00
Jacob Hoffman-Andrews
b71f1fb002 Hide mobile sidebar on some clicks
When the user clicks outside the sidebar, the sidebar should close.
Also, when the user clicks an internal link in the sidebar, it should
close.
2022-01-17 12:01:35 -08:00
Jacob Hoffman-Andrews
43b9268592 Rustdoc style cleanups
- Make "since" version numbers grey again (regressed in #92602).
 - Remove unneeded selectors for when crate filter dropdown is a
   sibling of search-input.
 - Crate filter dropdown doesn't need to be 100% width on mobile.
 - Only build crate filter dropdown when there is more than one crate.
 - Remove unused addCrateDropdown.
2022-01-17 11:45:28 -08:00
Jacob Hoffman-Andrews
c4b994ff80 Pick themes on settings page, not every page
This hides the paintbrush icon on most pages by default, in preference
for the settings on the settings page.  When loading from a local file,
and not in mobile view, continue to show the theme picker. That's
because some browsers limit access to localStorage from file:/// URLs,
so choosing a theme from settings.html doesn't take effect.
2022-01-14 18:20:15 -08:00
Guillaume Gomez
26edfc9e31 Create CSS class instead of using inline style for search results 2022-01-06 15:12:01 +01:00
Jacob Hoffman-Andrews
7ba086c6db Add some JSDoc comments to rustdoc JS
This follows the Closure Compiler dialect of JSDoc, so we
can use it to do some basic type checking. We don't plan to
compile with Closure Compiler, just use it to check types. See
https://github.com/google/closure-compiler/wiki/ for details.
2021-12-22 14:20:04 -08:00
Guillaume Gomez
d7e998dd14 Rename ID "main" into "main-content" 2021-12-02 14:17:20 +01:00
cynecx
135281ed15 rustdoc: use flexbox to layout sidebar and main content 2021-11-29 11:07:16 +01:00
Jacob Hoffman-Andrews
d9afca5808 Consistentize the system for image URLs in CSS. 2021-11-24 19:41:48 -08:00
Jacob Hoffman-Andrews
f0683f98fa Move themes and version into rustdoc-vars
We had been injecting the list of themes and the rustdoc version into
main.js by rewriting it at doc generation time. By avoiding this
rewrite, we can make it easier to edit main.js without regenerating all
the docs.

Added a more convenient accessor for rustdoc-vars.

Changed storage.js to not rely on resourcesSuffix. It could in theory
use rustdoc-vars, but because rustdoc-vars is at the end of the HTML,
it's not available when storage.js runs (very early in page load).
2021-11-24 19:41:47 -08:00
Jacob Hoffman-Andrews
04cb0dc8a9 Fix clicking on anchors inside summary tags. 2021-11-24 10:46:55 -08:00
Jacob Hoffman-Andrews
7f35556a25 Add GUI test for clicking on non-toggle summary 2021-11-22 01:17:20 -08:00
Jacob Hoffman-Andrews
9aef9a2324 Inhibit clicks on summary's children
A byproduct of using `<details>` and `<summary>` to show/hide detailed
documentation was that clicking any part of a method heading (or impl
heading) would show or hide the documentation. This was not super
noticeable because clicking a link inside the method heading would
navigate to that link. But clicking any unlinked black text in a method
heading would trigger the behavior.

That behavior was somewhat unexpected, and means that if you try to click
a type name in a method heading, but miss by a few pixels, you get a
confusing surprise.

This change inhibits that behavior by putting an event listener on most
summaries that cancels the event unless the event target was the summary
itself. In practice, that means it cancels the event unless the target
was the "[+]" / "[-]", because the rest of the heading is wrapped inside
a `<div>`, which is the target for anything that doesn't have a more
specific target.
2021-11-21 00:53:29 -08:00
Guillaume Gomez
aa17e1c47f Fix missing bottom border for headings in sidebar 2021-11-04 20:07:24 +01:00
Jacob Hoffman-Andrews
a4fe76ff7c Hide search bar in noscript.css
Also, remove the highlighting of the search bar in disabled state. This
reduces flicker when loading a page.
2021-10-31 12:41:06 -07:00