summary refs log tree commit diff
path: root/src/librustdoc/html
AgeCommit message (Collapse)AuthorLines
2020-11-17Add test to ensure that no DOS backline (\r\n) doesn't create extra backline ↵Guillaume Gomez-14/+27
in source rendering
2020-11-17Ensure that the source code display is working with DOS backlineGuillaume Gomez-0/+2
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-10Changed unwrap_or to unwrap_or_else in some places.Nicholas-Baron-1/+1
The discussion seems to have resolved that this lint is a bit "noisy" in that applying it in all places would result in a reduction in readability. A few of the trivial functions (like `Path::new`) are fine to leave outside of closures. The general rule seems to be that anything that is obviously an allocation (`Box`, `Vec`, `vec![]`) should be in a closure, even if it is a 0-sized allocation.
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-51/+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-30Add comment describing the Escape key weirdnessMichael Howell-2/+8
2020-10-30Add aria roles for theme picker menuMichael Howell-2/+2
2020-10-30Allow the theme picker to work with arrow keysMichael Howell-2/+46
This is mostly motivated by docs.rs. It's really weird when arrow keys work in the top dropdown menu, but don't work in other dropdown menus on the same page.
2020-10-30Close the theme picker when Escape is pressedMichael Howell-8/+2
2020-10-28rustdoc: Fix some nitsIan Jackson-1/+1
* Remove a needless comma in the Rust code * Replace double spaces after full stops with single spaces Requested-by: @GuillaumeGomez Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2020-10-28rustdoc: Provide a general --default-setting SETTING[=VALUE] optionIan Jackson-1/+1
We just plumb through what the user tells us. This is flagged as unstable, mostly because I don't understand the compatibility rules that rustdoc obeys for local storage data, and how error handling of invalid data works. We collect() the needed HashMap from Vec of Vecs of (key, value) pairs, so that there is a nice place to add new more-specific options. It would have been possible to use Extend::extend but doing it this way ensures that all the used inputs are (and will stay) right next to each other. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2020-10-28rustdoc: Provide a way to set the default settings from Rust codeIan Jackson-1/+34
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-23Rollup merge of #77920 - ayazhafiz:i/mut-ident-spacing, r=jyn514Yuki Okushi-1/+1
Avoid extraneous space between visibility kw and ident for statics Today, given a static like `static mut FOO: usize = 1`, rustdoc would emit `static mut FOO: usize = 1`, as it emits both the mutability kw with a space and reserves a space after the mutability kw. This patch fixes that misformatting. This patch also adds some tests for emit of other statics, as I could not find an existing test devoted to statics.
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-21Rollup merge of #78094 - camelid:rustdoc-fix-source-title, r=jyn514Yuki Okushi-7/+6
rustdoc: Show the correct source filename in page titles, without `.html` Previously the title would be lib.rs.html -- source if `lib.rs` was the actual source filename. Now the title is lib.rs - source
2020-10-20Apply some review suggestionsCamelid-5/+5
2020-10-19Add link to rustdoc book in rustdoc help popupGuillaume Gomez-5/+33
2020-10-18rustdoc: Show the correct source filename, without `.html`Camelid-9/+8
Previously the title would be lib.rs.html -- source if `lib.rs` was the actual source filename. Now the title is lib.rs – source (note the en dash).
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-17Auto merge of #76096 - pickfire:rustdoc-quote, r=jyn514bors-124/+131
Use double quote for rustdoc html r? `@GuillaumeGomez` Feels scary without escaping stuff when I looked at the code, probably susceptible to XSS. Follow up of https://github.com/rust-lang/rust/pull/75842
2020-10-17Fix some double quote that cause CI failureIvan Tham-3/+3
Co-authored-by: Oliver Middleton <olliemail27@gmail.com>
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-17Use double quote for rustdoc htmlIvan Tham-126/+133
2020-10-16Fix sidebar scroll on mobile devicesGuillaume Gomez-4/+0
2020-10-16Auto merge of #77809 - nasso:master, r=jyn514,guillaumegomezbors-42/+240
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-16Rollup merge of #77672 - Nemo157:simplify-cfg, r=jyn514Dylan DPC-33/+71
Simplify doc-cfg rendering based on the current context For sub-items on a page don't show cfg that has already been rendered on a parent item. At its simplest this means not showing anything that is shown in the portability message at the top of the page, but also for things like fields of an enum variant if that variant itself is cfg-gated then don't repeat those cfg on each field of the variant. This does not touch trait implementation rendering, as that is more complex and there are existing issues around how it deals with doc-cfg that need to be fixed first. ### Screenshots, left is current, right is new: ![image](https://user-images.githubusercontent.com/81079/95387261-c2e6a200-08f0-11eb-90d4-0a9734acd922.png) ![image](https://user-images.githubusercontent.com/81079/95387458-06411080-08f1-11eb-81f7-5dd7f37695dd.png) ![image](https://user-images.githubusercontent.com/81079/95387702-6637b700-08f1-11eb-82f4-46b6cd9b24f2.png) ![image](https://user-images.githubusercontent.com/81079/95387905-b9aa0500-08f1-11eb-8d95-8b618d31d419.png) ![image](https://user-images.githubusercontent.com/81079/95388300-5bc9ed00-08f2-11eb-9ac9-b92cbdb60b89.png) cc #43781
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-14Rollup merge of #77817 - jyn514:const-since, r=petrochenkovDylan DPC-23/+31
Switch rustdoc from `clean::Stability` to `rustc_attr::Stability` This gives greater type safety and is less work to maintain on the rustdoc end. It also makes rustdoc more consistent with rustc. Noticed this while working on https://github.com/rust-lang/rust/issues/76998. - Remove `clean::Stability` in favor of `rustc_attr::Stability` - Remove `impl Clean for Stability`; it's no longer necessary r? @GuillaumeGomez cc @petrochenkov
2020-10-13Avoid extraneous space between visibility kw and ident for staticsayazhafiz-1/+1
Today, given a static like `static mut FOO: usize = 1`, rustdoc would emit `static mut FOO: usize = 1`, as it emits both the mutability kw with a space and reserves a space after the mutability kw. This patch fixes that misformatting. This patch also adds some tests for emit of other statics, as I could not find an existing test devoted to statics.
2020-10-13Make portability log at debug levelWim Looman-2/+2
2020-10-13Coding style fixesnasso-25/+22
2020-10-13Remove unnecessary refsnasso-10/+5
2020-10-13Add a setting to use the system themenasso-36/+232
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
2020-10-11Move `PartialOrd` impl out of rustcJoshua Nelson-6/+6
Rustdoc's ordering requirements are probably not relevant to the rest of the compiler.
2020-10-11Switch rustdoc from `clean::Stability` to `rustc_attr::Stability`Joshua Nelson-21/+29
This gives greater type safety and is less work to maintain on the rustdoc end.
2020-10-09Simplify included import items handlingGuillaume Gomez-18/+17
2020-10-09Correctly handle "pub use" reexportsGuillaume Gomez-8/+10