about summary refs log tree commit diff
path: root/src/librustdoc/html/static/js
AgeCommit message (Collapse)AuthorLines
2022-10-18rustdoc: remove class name `location` from sidebar sibling navMichael Howell-1/+1
This change tweaks the CSS to apply most of its styles to `.sidebar h2`, cleaning up a few redundant rules from `.mobile-topbar .location` and restoring useful navigation aids in mobile mode.
2022-10-17rustdoc: change mobile breakpoint to match CSSMichael Howell-3/+3
Since it's possible to have a 700.5px viewport width, the JS needs to not switch to mobile mode in such a setup.
2022-10-17rustdoc: remove CSS `@media (min-width: 701px)`Michael Howell-1/+1
The two rules within it can and should be done without the separate media query: * There ain't no rule saying a viewport can't be `700.5px` wide, since hardware pixels can be finer than CSS pixels. * The rule for the first example-wrap child should probably apply on mobile. * The rule for the source sidebar is overriden by the mobile rule setting `max-width: 100vw`, so it can be merged with the rest of the styles.
2022-10-17rustdoc: factor JS mobile scroll lock into its own functionMichael Howell-41/+28
https://github.com/rust-lang/rust/pull/98775#issuecomment-1172728308
2022-10-16Rollup merge of #103060 - notriddle:notridddle/help-page, r=GuillaumeGomezMatthias Krüger-23/+62
rustdoc: make the help button a link to a page This allows you to open the help section in a new browser tab, which is a pretty reasonable thing to want for a documentation page. Preview: http://notriddle.com/notriddle-rustdoc-demos/help-page/std/index.html
2022-10-15rustdoc: make help button a no-op when on help pageMichael Howell-0/+15
2022-10-15rustdoc: fix Ctrl-Click on help and settings linksMichael Howell-1/+8
2022-10-15rustdoc: make the help button a link to a pageMichael Howell-23/+40
This allows you to open the help section in a new browser tab, which is a pretty reasonable thing to want for a documentation page.
2022-10-15Fix display of settings pageGuillaume Gomez-1/+3
2022-10-11rustdoc: remove unused classes from sidebarMichael Howell-5/+3
Since 98f05a0282625a5fda6e90ebf3b05a4bd7608f65 removed separate colors from the currently-selected item, there's no need to have item classes on sidebar links.
2022-10-10rustdoc: remove unneeded `<div>` wrapper from sidebar DOMMichael Howell-15/+11
When this was added, the sidebar had a bit more complex style. It can be removed, now.
2022-10-08rustdoc: remove mobile topbar from source pages instead of hiding itMichael Howell-6/+8
2022-10-05rustdoc: remove unused CSS class `in-band`Michael Howell-1/+1
Since a7c25b29575c17434406b69773f8c2961af343b3 removed `in-band` from code headers, the only remaining uses of the `in-band` class are: https://github.com/rust-lang/rust/blob/02cd79afb8080fce8c8ce35533c54d8ecf8f390e/src/librustdoc/html/render/write_shared.rs#L520-L521 https://github.com/rust-lang/rust/blob/02cd79afb8080fce8c8ce35533c54d8ecf8f390e/src/librustdoc/html/templates/print_item.html#L2-L3 https://github.com/rust-lang/rust/blob/02cd79afb8080fce8c8ce35533c54d8ecf8f390e/src/librustdoc/html/render/context.rs#L637-L638 https://github.com/rust-lang/rust/blob/02cd79afb8080fce8c8ce35533c54d8ecf8f390e/src/librustdoc/html/render/mod.rs#L368-L369 https://github.com/rust-lang/rust/blob/02cd79afb8080fce8c8ce35533c54d8ecf8f390e/src/librustdoc/html/render/mod.rs#L401-L402 https://github.com/rust-lang/rust/blob/02cd79afb8080fce8c8ce35533c54d8ecf8f390e/src/librustdoc/html/static/js/main.js#L525 Since all of these uses are nested below `h1.fqn`, we can get rid of it, and the support code that was used for when `in-band` was part of item rendering.
2022-09-26rustdoc: give `.line-number` / `.line-numbers` meaningful namesMichael Howell-6/+6
2022-09-25rustdoc: clean up `.out-of-band`/`.in-band` CSSMichael Howell-1/+0
* Remove the `float: right` fallback from the main header, which hasn't been needed since IE11 support was dropped. * Remove `in-band` from low-level headers, which hasn't been needed since `.rightside` switched to `float: right` in 593d6d1cb15c55c88319470dabb40126c7b7f1e2 * Remove unreachable `.in-band > code, .in-band > .code-header` CSS, since the `in-band` class was attached to the `code-header` itself, not nested directly below it. * Use `rem` instead of `em` for code header margins. * This results in a slight change in spacing around impls and item-info, but since it makes it more consistent with the way methods are presented, it's probably fine.
2022-09-21rustdoc: dynamically show-hide line numbers on code examplesMichael Howell-11/+37
2022-09-09rustdoc: simplify the codeblock tooltipMichael Howell-21/+2
This commit moves the tooltip into example-wrap, simplifying allowing several overly-complex things to be fixed: * The mousover javascript can be removed, because hovering example-wrap can style the tooltip inside. * The sibling selecor can be removed, because hovering the tooltip also hovers the wrapper, which can hover the codeblock itself. * The relative positioning of the `<li>` tag, which was added in e861efd9f9ca45c1048a256812dfe8faffbb1367 to fix the positioning of the code tooltip, can now be removed, because example-wrap itself already has relative positioning.
2022-08-26rustdoc: remove empty extern_crates and type="text/javascript" on scriptMichael Howell-3/+3
Like #101023, this removes an attribute with a default value.
2022-08-10Improve crate selection on rustdoc search results pageFrank Steffahn-22/+9
Resolves all of issue #93240 Reproduces a similar change as #99086, but with improvements In particular, this PR inlcludes: * redesigning the crate-search selector so the background color matches its surroundings * decrease the font of the dropdown menu to a reaonable size * add a hover effect * make the color of the arrow theme-dependent, using a surrounding div, with :after pseudo-element that can then be transformed using CSS filters to approximate the desired color * fix the text "in" to match the title font * remove the "for xyz" in the "Results for xyz in [All crates]" title when searching for search term "xyz"; you can already see what you're searching for as it's typed in the search bar! * in line with #99086, handle super-long crate names appropriately without a long <select> element escaping the screen area; the improvement is that we also keep the title within a single line now; uses some flex layout shenanigans... * the margins / paddings are adjusted so the selected label of the <select> fits within the rest of that title nicely; also some inconsistency in the way that Firefox renders a <select> with "appearance: none" (roughly 4px more padding left and right of the text than e.g. Chrome) is worked around, and it now produces a result that looks (essentially) identical to Chrome * the color of the help menu and settings menu border in light theme is made to match with the color of the corresponding buttons, like they do (match) in the ayu theme * the casing of "All crates" changes to "all crates" * the new tests from #99086 are temporarily disabled, until they can be adapted later
2022-08-10Auto merge of #100346 - matthiaskrgr:rollup-6rljn4p, r=matthiaskrgrbors-7/+59
Rollup of 14 pull requests Successful merges: - #98775 (rustdoc: improve scroll locking in the rustdoc mobile sidebars) - #99479 (rustdoc-json: Remove doc FIXME for Import::id and explain) - #100040 (Error on broken pipe but do not backtrace or ICE) - #100072 (linker-plugin-lto.md: Correct the name of example c file) - #100098 (Some "this expression has a field"-related fixes) - #100226 (Do not manually craft a span pointing inside a multibyte character.) - #100240 (Fail gracefully when const pattern is not structural match.) - #100256 (Add some high-level docs to `FnCtxt` and `ItemCtxt`) - #100261 (Set tainted errors bit before emitting coerce suggestions.) - #100275 (also update anyhow in codegen_cranelift) - #100281 (Remove more Clean trait implementations) - #100314 (Mention `unit-test` in MIR opt test README) - #100319 (Remove more Clean trait implementations) - #100323 ([rustdoc] Don't render impl blocks with doc comment if they only contain private items by default) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-08-10Rollup merge of #98775 - notriddle:notriddle/mobile-sidebar-scroll-lock, r=jshaMatthias Krüger-7/+59
rustdoc: improve scroll locking in the rustdoc mobile sidebars This PR prevents the main content area from scrolling while the mobile sidebar is open on documentation pages (porting the scroll locking behavior from the source sidebar to the regular sidebar), and also fixes some bad behavior where opening a "mobile" sidebar, and growing the viewport so that the "desktop" mode without scroll locking is activated, could potentially leave the page stuck. This does not affect the behavior on larger screens. Only small ones, where the sidebar covers up the main content. Split out from #98772
2022-08-04rustdoc: use a more compact encoding for implementors/trait.*.jsMichael Howell-4/+10
The exact amount that this reduces the size of an implementors file depends on whether most of the impls are synthetic or not. For `Send`, it reduces the file from 128K to 116K, while for `Clone` it went from 64K to 52K.
2022-08-03Rollup merge of #100083 - notriddle:notriddle/source-files-js, r=GuillaumeGomezMatthias Krüger-7/+11
rustdoc: use a more compact encoding for source-files.js This reduces the compiler-doc file from 40K to 36K, a 10% reduction in size.
2022-08-02Replace `* -> vec` with `-> vec` in docsNoah Lev-1/+1
Rustdoc's current syntax is `-> vec`.
2022-08-02rustdoc: use a more compact encoding for source-files.jsMichael Howell-7/+11
This reduces the compiler-doc file from 40K to 36K, a 10% reduction in size.
2022-07-17Fix auto-expand of trees in source code page sidebarGuillaume Gomez-1/+1
2022-07-14Correctly handle crate level page on docs.rs as wellGuillaume Gomez-17/+14
2022-07-05rustdoc: improve scroll locking in the rustdoc mobile sidebarsMichael Howell-7/+59
This commit ports the scroll locking behavior from the source sidebar to the regular sidebar, and also fixes some bad behavior where opening a "mobile" sidebar, and growing the viewport so that the "desktop" mode without scroll locking is activated, could potentially leave the page stuck. This does not affect the behavior on larger screens. Only small ones, where the sidebar covers up the main content.
2022-07-05Rollup merge of #98776 - notriddle:notriddle/mobile-sidebar-auto-close, ↵Dylan DPC-2/+14
r=GuillaumeGomez rustdoc: improve click behavior of the source code mobile full-screen "sidebar" On desktop, if you open the source code sidebar, it stays open even when you move from page to page. It used to do the same thing on mobile, but I think that's stupid. Since the file list fills the entire screen on mobile, and you can't really do anything with the currently selected file other than dismiss the "sidebar" to look at it, it's safe to assume that anybody who clicks a file in that list probably wants the list to go away so they can see it. Split out separately from #98772
2022-07-04Rollup merge of #98774 - notriddle:notriddle/source-code-sidebar-button, ↵Matthias Krüger-3/+3
r=GuillaumeGomez rustdoc: make source sidebar toggle a real button This fixes tab focus, so that you can open and close the sidebar from keyboard. This should cause no visible change in appearance at all. The only way you'd know anything different is if you tried to use keyboard controls to open the source code file navigation sidebar. Separated out from #98772
2022-07-02rustdoc: make source sidebar toggle a real buttonMichael Howell-3/+3
This fixes tab focus, so that you can open and close the sidebar from keyboard.
2022-07-01Improve click behavior of the source code mobile full-screen "sidebar"Michael Howell-2/+14
On desktop, if you open the source code sidebar, it stays open even when you move from page to page. It used to do the same thing on mobile, but I think that's stupid. Since the file list fills the entire screen on mobile, and you can't really do anything with the currently selected file other than dismiss the "sidebar" to look at it, it's safe to assume that anybody who clicks a file in that list probably wants the list to go away so they can see it.
2022-07-01rustdoc cleanup: remove unused functionMichael Howell-1/+1
2022-07-01rustdoc: use <details> tag for the source code sidebarMichael Howell-18/+11
This fixes the extremely poor accessibility of the old system, making it possible to navigate the sidebar by keyboard, and also implicitly gives the sidebar items the correct ARIA roles.
2022-06-30Rollup merge of #98709 - GuillaumeGomez:rm-decl-for-old-browsers, r=Dylan-DPCMatthias Krüger-34/+0
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-30Rollup merge of #98671 - GuillaumeGomez:source-sidebar-fixes, r=notriddleMatthias Krüger-0/+15
Fix source sidebar bugs This PR fixes the following two bugs: ![Screenshot from 2022-06-29 14-39-58](https://user-images.githubusercontent.com/3050060/176449070-3e3762da-2bfe-4acf-8eb0-34f6eb4c94ed.png) ![Screenshot from 2022-06-29 15-05-09](https://user-images.githubusercontent.com/3050060/176449073-b164820b-bd71-4b1a-990c-bba4e5fce196.png) I added regression tests to prevent them to happen again. I think we should backport it to beta as well. You can test it [here](https://rustdoc.crud.net/imperio/source-sidebar-fixes/src/std/lib.rs.html). cc ```@jsha``` r? ```@notriddle```
2022-06-30Fix scroll when source sidebar is open on mobileGuillaume Gomez-0/+15
2022-06-30Remove unneeded methods declaration for old web browsersGuillaume Gomez-34/+0
2022-06-29Rollup merge of #98646 - notriddle:notriddle/main.js, r=GuillaumeGomezMatthias Krüger-2/+6
rustdoc: fix bugs in main.js popover help and settings
2022-06-28rustdoc: make keyboard commands work when checkboxes are selectedMichael Howell-1/+2
2022-06-28rustdoc: fix keyboard shortcuts bug in settings menuMichael Howell-1/+1
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-28rustdoc: fix help menu popover togglingMichael Howell-0/+3
2022-06-28Auto merge of #98475 - notriddle:notriddle/index-fn-signatures, r=GuillaumeGomezbors-35/+187
rustdoc: reference function signature types from the `p` array This reduces the size of the function signature index, because it's common to have many functions that operate on the same types. $ wc -c search-index-old.js search-index-new.js 5224374 search-index-old.js 3932314 search-index-new.js By my math, this reduces the uncompressed size of the search index by 32%. On compressed signatures, the wins are less drastic, a mere 8%: $ wc -c search-index-old.js.gz search-index-new.js.gz 404532 search-index-old.js.gz 371635 search-index-new.js.gz
2022-06-27Add comments, fixes for `0` sentinelMichael Howell-4/+9
2022-06-27Update src/librustdoc/html/static/js/externs.jsMichael Howell-1/+1
Co-authored-by: Guillaume Gomez <guillaume1.gomez@gmail.com>
2022-06-27Put back, fix ()-output optimizationMichael Howell-1/+1
2022-06-27Add documentationMichael Howell-1/+87
2022-06-26Rollup merge of #98297 - GuillaumeGomez:help-pocket-menu, r=notriddleMatthias Krüger-102/+115
Transform help popup into a pocket menu Just like we moved the settings menu into a "pocket menu", it's doing the same to the help popup. You can test it [here](https://rustdoc.crud.net/imperio/help-pocket-menu/doc/foo/index.html) and here is a screenshot: ![Screenshot from 2022-06-20 20-58-29](https://user-images.githubusercontent.com/3050060/174663718-538e9d11-3bf9-48b2-8909-f9bfe75af135.png) r? ``````````@jsha``````````
2022-06-24rustdoc: reference function signature types from the `p` arrayMichael Howell-35/+96
This reduces the size of the function signature index, because it's common to have many functions that operate on the same types. $ wc -c search-index-old.js search-index-new.js 5224374 search-index-old.js 3932314 search-index-new.js By my math, this reduces the uncompressed size of the search index by 32%. On compressed signatures, the wins are less drastic, a mere 8%: $ wc -c search-index-old.js.gz search-index-new.js.gz 404532 search-index-old.js.gz 371635 search-index-new.js.gz
2022-06-23Rollup merge of #98310 - jsha:defer-source-sidebar, r=GuillaumeGomezMichael Goulet-8/+13
rustdoc: optimize loading of source sidebar The source sidebar has a setting to remember whether it should be open or closed. Previously, this setting was handled in source-script.js, which is loaded with `defer`, meaning it is often run after the document is rendered. Since CSS renders the source sidebar as closed by default, changing this after the initial render results in a relayout. Instead, handle the setting in storage.js, which is the first script to load and is the only script that blocks render. This avoids a relayout and means navigating between files with the sidebar open is faster. Demo: https://rustdoc.crud.net/jsha/defer-source-sidebar/src/alloc/ffi/c_str.rs.html r? ````@GuillaumeGomez````