summary refs log tree commit diff
path: root/src/librustdoc/html/static
AgeCommit message (Collapse)AuthorLines
2020-12-24Auto merge of #79742 - GuillaumeGomez:move-tooltips-messages-out-of-html, ↵bors-13/+23
r=Nemo157 Move tooltips messages out of html First thing first: nothing in the output has changed. You still have the "i" on the left of code blocks examples when they have `ignore`, `compile_fail`, `should_panic` and `edition`. The behavior also remains the same: when you hover the "i", you have the corresponding message showing up. So now, why this PR then? I realized recently that we were actually generating those messages into the HTML every time whereas all messages are the same (except for the edition ones, I'll come back to it later). So instead of generating more content, I simply moved it inside the CSS thanks to pseudo elements (`::before` and `::after`). The message is now inside `::after` and we use the `::before` to have the small triangle on the left of the message. So now, we have less HTML generated which is seems pretty nice. So now, back to the `edition` change: the message is globally the same, but the "edition" itself can be different (2015 or 2018 currently, I expect 2021 to arrive not too far in the future). So the only difference for it is that I added a new attribute on the tooltip called `edition` which contains this information. Then, the `::after` uses it inside its `content` (you can get the content of an element's attribute by using `attr` and concat different strings by simply having them after the other). Don't hesitate if a part of my explanations isn't clear. r? `@jyn514`
2020-12-23Update HTML DOM attribute "edition" to "data-edition"Guillaume Gomez-1/+1
2020-12-15Rollup merge of #79796 - ↵Guillaume Gomez-3/+6
GuillaumeGomez:hide-associated-const-when-collapsing, r=jyn514 Hide associated constants too when collapsing implementation Fixes #71849. r? `@jyn514`
2020-12-15Rollup merge of #79379 - GuillaumeGomez:no-js-not-hidden, r=Nemo157Guillaume Gomez-0/+10
Show hidden elements by default when JS is disabled Fixes #79301. A lot of things are hidden by default which shouldn't when JS is disabled. This PR fixes it. Before: ![Screenshot from 2020-11-24 14-10-16](https://user-images.githubusercontent.com/3050060/100099361-a16d5580-2e5f-11eb-891b-a4c005aeb1d0.png) After: ![after](https://user-images.githubusercontent.com/3050060/100099382-a6caa000-2e5f-11eb-8190-14f330aff9a2.png) r? `@jyn514`
2020-12-14Rollup merge of #79936 - GuillaumeGomez:mobile-fix-item-name, r=Nemo157,jyn514Guillaume Gomez-1/+5
Fix item name display on mobile Fixes https://github.com/rust-lang/docs.rs/issues/1200 ![Screenshot_20201211-200931](https://user-images.githubusercontent.com/3050060/101944457-0c06eb00-3bed-11eb-8f63-a4d4fd3cbb56.jpg) ![Screenshot_20201211-195846](https://user-images.githubusercontent.com/3050060/101944459-0d381800-3bed-11eb-91ff-815a2af7ca72.jpg) cc `@jyn514` r? `@Nemo157`
2020-12-12rustdoc light theme: Fix CSS for selected buttonsCamelid-1/+1
The background was dark before, which made the text impossible to read. Now the background is white, which is how selected `div`s are rendered. As a result, the search results tabs now look identical to how they used to look (before #79896).
2020-12-11Fix main section position so that the search input remains clickableGuillaume Gomez-0/+4
2020-12-11Fix item name display on mobileGuillaume Gomez-1/+1
2020-12-10Make search results tab and help button focusable with keyboardGuillaume Gomez-19/+22
2020-12-09Rollup merge of #79862 - GuillaumeGomez:tab-lock, r=ManishearthTyler Mandry-16/+17
Remove tab-lock and replace it with ctrl+up/down arrows to switch between search result tabs Fixes https://github.com/rust-lang/rust/issues/65212 What took the longest time was to update the help popup in the end. r? `@Manishearth`
2020-12-09Remove tab-lock and replace it with ctrl+up/down arrows to switch between ↵Guillaume Gomez-16/+17
search result tabs
2020-12-09Hide associated constants too when collapsing implementationGuillaume Gomez-3/+6
2020-12-05Move tooltips messages to CSS instead of inside HTMLGuillaume Gomez-13/+23
2020-12-03Use `createElement` and `innerHTML` instead of `DOMParser`Camelid-5/+3
@GuillaumeGomez was concerned about browser compatibility.
2020-12-03Render Markdown in search resultsCamelid-2/+23
Previously Markdown documentation was not rendered to HTML for search results, which led to the output not being very readable, particularly for inline code. This PR fixes that by rendering Markdown to HTML with the help of pulldown-cmark (the library rustdoc uses to parse Markdown for the main text of documentation). However, the text for the title attribute (the text shown when you hover over an element) still uses the plain-text rendering since it is displayed in browsers as plain-text. Only these styles will be rendered; everything else is stripped away: * *italics* * **bold** * `inline code`
2020-12-01Auto merge of #78876 - GuillaumeGomez:better-setting-keyboard-ux, r=jyn514bors-55/+62
Make keyboard interactions in the settings menu more pleasant #78868 improved the keyboard interactions with the settings page. This PR goes a bit further by allowing more than just "space" to toggle the checkboxes. r? `@jyn514`
2020-11-24Rename "stability" CSS class to "item-info"Guillaume Gomez-23/+24
2020-11-24Show hidden elements by default when JS is disabledGuillaume Gomez-0/+10
2020-11-22Prevent feature information to be hidden if it's on the impl directlyGuillaume Gomez-2/+8
2020-11-18add [src] links to methods on a trait's pageNixon Enraght-Moony-5/+5
2020-11-14Add tests and improve rendering of features on traitsWim Looman-3/+7
2020-11-12Improve comment for getVirtualKey functionGuillaume Gomez-1/+1
2020-11-12Improve settings.js code by using 'onEachLazy' directly instead of looping ↵Guillaume Gomez-33/+22
through DOM iterators
2020-11-12Make keyboard interactions in the settings menu more pleasantGuillaume Gomez-26/+44
2020-11-12Auto merge of #78976 - GuillaumeGomez:rollup-endkih3, r=GuillaumeGomezbors-2/+5
Rollup of 5 pull requests Successful merges: - #78916 (extend const generics test suite) - #78921 (Improve the page title switch handling between search and doc) - #78933 (Don't print thread ids and names in `tracing` logs) - #78960 (Test default values for const parameters.) - #78971 (Update books) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2020-11-12Rollup merge of #78921 - GuillaumeGomez:search-result-title, r=jyn514Guillaume Gomez-2/+5
Improve the page title switch handling between search and doc The current behavior often "forgets" to update the page title when discarding/putting back the search results. This isn't optimal which is why I wrote this fix. r? ``@jyn514``
2020-11-12Auto merge of #78773 - GuillaumeGomez:theme-picker-shortcut, r=jyn514bors-0/+10
Add shortcut for theme picker menu Follow-up of #78584 Just like you can focus the search input by pressing "S", you can now access the theme picker menu by pressing "T" and navigate through the options only using the keyboard. cc `@notriddle` r? `@jyn514`
2020-11-10Improve the page title switch handling between search and docGuillaume Gomez-2/+5
2020-11-07Fix tab focus on restyled switchesMichael Howell-2/+3
Setting a checkbox to `display:none` makes it impossible to tab onto it, which makes the rustdoc settings page completely keyboard inaccessible.
2020-11-05Add shortcut for theme picker menuGuillaume Gomez-0/+10
2020-10-30Pull theme picker keyboard code into main.jsMichael Howell-1/+59
Most of the code in mod.rs should be code that really needs to have the list of available themes inlined into it.
2020-10-30Close the theme picker when Escape is pressedMichael Howell-8/+2
2020-10-28rustdoc: Provide a way to set the default settings from Rust codeIan Jackson-1/+23
rustdoc has various user-configurable preferences. These are recorded in web Local Storage (where available). But we want to provide a way to configure the default default, including for when web storage is not available. getSettingValue is the function responsible for looking up these settings. Here we make it fall back some in-DOM data, which ultimately comes from RenderOptions.default_settings. Using HTML data atrtributes is fairly convenient here, dsspite the need to transform between snake and kebab case to avoid the DOM converting kebab case to camel case (!) We cache the element and dataset lookup in a global variable, to ensure that getSettingValue remains fast. The DOM representation has to be in an element which precedes the inclusion of storage.js. That means it has to be in the <head> and we should not use an empty <div> as the container (although most browsers will accept that). An empty <script> element provides a convenient and harmless container object. <meta> would be another possibility but runs a greater risk of having unwanted behaviours on weird browsers. We trust the RenderOptions not to contain unhelpful setting names, which don't fit nicely into an HTML attribute. It's awkward to quote dataset keys. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2020-10-28rustdoc: js: Use getSettingValue for all rustdoc-* valuesIan Jackson-24/+25
Currently, storage.js and main.js have many open-coded calls to getCurrentValue for "rustdoc-" values, but these are settings and should be handled by getSettingValue. So make getSettingValue part of storage.js (where everyone can call it) and use it everywhere. No functional change yet. We are going to make getSettingValue do something more sophisticated in a moment. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2020-10-23Always store Rustdoc theme when it's changednasso-5/+6
2020-10-22Rollup merge of #78084 - GuillaumeGomez:improve-mobile-display, r=jyn514,Nemo157Yuki Okushi-0/+35
Greatly improve display for small mobile devices screens Fixes #78014. The biggest change being the "search bar". Instead of having everything on one line, I decided to move the search input on its own: ![Screenshot from 2020-10-18 21-54-26](https://user-images.githubusercontent.com/3050060/96378530-c863a800-118c-11eb-8e82-a43fce312b5b.png) Another change is that now, we "break words" in the listing so that they don't grow too big: ![Screenshot from 2020-10-18 21-57-17](https://user-images.githubusercontent.com/3050060/96378555-ffd25480-118c-11eb-8a71-8f116c7edd93.png) r? @jyn514
2020-10-19Add link to rustdoc book in rustdoc help popupGuillaume Gomez-5/+33
2020-10-18Greatly improve display for small mobile devices screensGuillaume Gomez-0/+35
2020-10-18Rollup merge of #78050 - GuillaumeGomez:small-css-cleanup, r=jyn514Yuki Okushi-5/+1
Small CSS cleanup r? @jyn514
2020-10-17Small CSS cleanupGuillaume Gomez-5/+1
2020-10-17Rollup merge of #78013 - GuillaumeGomez:fix-sidebar-scroll-mobile-devices, ↵Yuki Okushi-4/+0
r=jyn514 Fix sidebar scroll on mobile devices Fixes #77942. The issue was coming from the appearance/disappearance of the "wrapper" on the mobile devices web browsers, which triggers the "resize" event, calling the `hideSidebar` function is the JS code. r? @jyn514
2020-10-16Fix sidebar scroll on mobile devicesGuillaume Gomez-4/+0
2020-10-16Auto merge of #77809 - nasso:master, r=jyn514,guillaumegomezbors-25/+155
Add settings to rustdoc to use the system theme This PR adds new settings to `rustdoc` to use the operating system color scheme. ![click](https://user-images.githubusercontent.com/11479594/95668052-bf604e80-0b6e-11eb-8a17-473aaae510c9.gif) `rustdoc` actually had [basic support for this](https://github.com/rust-lang/rust/blob/b1af43bc63bc7417938df056f7f25d456cc11b0e/src/librustdoc/html/static/storage.js#L121), but the setting wasn't visible and couldn't be set back once the theme was explicitly set by the user. It also didn't update if the operating system theme preference changed while viewing a page. I'm using [this method](https://developer.mozilla.org/en-US/docs/Web/CSS/Media_Queries/Testing_media_queries#Receiving_query_notifications) to query and listen to changes to the `(prefers-color-scheme: dark)` media query. I kept the old method (based on `getComputedStyle`) as a fallback in case the user-agent doesn't support `window.matchMedia` (so like... [pretty much nobody](https://caniuse.com/?search=matchMedia)). Since there's now more than one official ""dark"" theme in `rustdoc` (and also to support custom/third-party themes), the preferred dark and light themes can be configured in the settings page (the defaults are just "dark" and "light"). This is also my very first "proper" PR to Rust! Please let me know if I did anything wrong :).
2020-10-15Set preferred-dark-theme to the last dark themenasso-0/+10
If the user doesn't have a preferred dark theme but is already using a dark theme, set the preferred dark theme to be that theme
2020-10-15Rollup merge of #77979 - GuillaumeGomez:hide-help-button, r=jyn514Guillaume Gomez-0/+8
Hide help button on mobile Addresses #77899. This PR is just a quick fix for now: we're still debating about whether or not we want to display this help popup and if so, how. I'll open an issue once this PR is merged to discuss about it. Before: ![Screenshot from 2020-10-15 17-56-39](https://user-images.githubusercontent.com/3050060/96155127-df499680-0f0f-11eb-8a13-77c537141f21.png) After: ![Screenshot from 2020-10-15 17-55-06](https://user-images.githubusercontent.com/3050060/96154957-ac070780-0f0f-11eb-9d90-7d8f79a6bf37.png) r? @jyn514
2020-10-15Hide help button on mobile devicesGuillaume Gomez-0/+8
2020-10-13Coding style fixesnasso-21/+18
2020-10-13Add a setting to use the system themenasso-21/+144
2020-10-13Rollup merge of #77699 - GuillaumeGomez:word-wrap, r=XAMPPRockyYuki Okushi-7/+3
Add word wrap for short descriptions Fixes #77652 ![Screenshot from 2020-10-08 13-26-18](https://user-images.githubusercontent.com/3050060/95452770-11845280-096a-11eb-80da-723da85261fa.png) cc @WaffleLapkin r? @jyn514
2020-10-12Add word-wrap rule for short descriptionsGuillaume Gomez-0/+3