about summary refs log tree commit diff
path: root/src/librustdoc
AgeCommit message (Collapse)AuthorLines
2020-10-28rustdoc: Use Vec::into_iter() rather than drain()Ian Jackson-2/+2
This allows removing a `mut` which is nicer. Suggested-by: @jyn514 Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2020-10-28Add a comment about non-panicking of splitn().next().unwrap()Ian Jackson-0/+1
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2020-10-28rustdoc: Fix some nitsIan Jackson-4/+4
* 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 --default-theme THEME optionIan Jackson-0/+21
This is a fairly simple special case of --default-eetting. We must set both "theme" and "use-system-theme". Providing it separately enables us to document a way to set the theme without expoosing the individual settings keywords, which are quite complex. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2020-10-28rustdoc: Provide a general --default-setting SETTING[=VALUE] optionIan Jackson-2/+26
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-2/+39
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-27Rollup merge of #78348 - jyn514:pub-crate, r=GuillaumeGomezYuki Okushi-10/+10
Make some functions private that don't have to be public r? @GuillaumeGomez
2020-10-25Make some functions private that don't have to be publicJoshua Nelson-10/+10
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-22Auto merge of #78212 - JohnTitor:rollup-j5r6xuy, r=JohnTitorbors-0/+35
Rollup of 10 pull requests Successful merges: - #77420 (Unify const-checking structured errors for `&mut` and `&raw mut`) - #77554 (Support signed integers and `char` in v0 mangling) - #77976 (Mark inout asm! operands as used in liveness pass) - #78009 (Haiku: explicitly set CMAKE_SYSTEM_NAME when cross-compiling) - #78084 (Greatly improve display for small mobile devices screens) - #78155 (Fix two small issues in compiler/rustc_lint/src/types.rs) - #78156 (Fixed build failure of `rustfmt`) - #78172 (Add test case for #77062) - #78188 (Add tracking issue number for pin_static_ref) - #78200 (Add `ControlFlow::is_{break,continue}` methods) Failed merges: r? `@ghost`
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-21Lift: take self by valueBastian Kauschke-4/+4
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-20Rollup merge of #78157 - GuillaumeGomez:remove-unused-type, r=jyn514Guillaume Gomez-9/+0
Remove unused type from librustdoc r? @jyn514
2020-10-20Remove unused type from librustdocGuillaume Gomez-9/+0
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 #77685 - jackh726:binder-map, r=lcnrbors-5/+9
Use rebind instead of Binder::bind when possible These are really only the easy places. I just searched for `Binder::bind` and replaced where it straightforward. r? `@lcnr` cc. `@nikomatsakis`
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 #77785 - GuillaumeGomez:remove-compiler-reexports, r=ollie27Dylan DPC-2/+9
Remove compiler-synthesized reexports when documenting Fixes #77567 r? @ollie27
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-17Rollup merge of #77827 - jyn514:stable-primitives, r=GuillaumeGomezYuki Okushi-3/+8
Don't link to nightly primitives on stable channel I am not sure how to test this. Closes https://github.com/rust-lang/rust/issues/77775 r? @GuillaumeGomez
2020-10-16Review commentsJack Huey-1/+1
2020-10-16map_bound_ref -> rebindJack Huey-10/+11
2020-10-16Use map_bound(_ref) instead of Binder::bind when possibleJack Huey-7/+10
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/+138
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-15Rollup merge of #77753 - GuillaumeGomez:check-html-comments, r=jyn514Yuki Okushi-53/+89
Check html comments Part of #67799. cc @ollie27 r? @jyn514
2020-10-14Handle multi-line HTML commentsGuillaume Gomez-24/+22
2020-10-14Rollup merge of #77897 - GuillaumeGomez:cleanup-passes-mod, r=jyn514Dylan DPC-170/+176
Move `Strip` into a separate rustdoc pass Just something which was bothering me lately. :) r? @jyn514
2020-10-14Rollup merge of #77817 - jyn514:const-since, r=petrochenkovDylan DPC-81/+61
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-13Add test-examples for Cfg::simplify_withWim Looman-0/+38
2020-10-13Clean up rustdoc passesGuillaume Gomez-170/+176
2020-10-13Add check for HTML commentsGuillaume Gomez-5/+29
2020-10-13Coding style fixesnasso-25/+22
2020-10-13Remove unnecessary refsnasso-10/+5