about summary refs log tree commit diff
path: root/src/librustdoc/html
AgeCommit message (Collapse)AuthorLines
2021-05-20Remove `PrimitiveType::as_str`Joshua Nelson-3/+3
2021-05-20Remove `to_url_str`Joshua Nelson-2/+2
2021-05-20Reset "focusedByTab" field when doing another searchGuillaume Gomez-4/+5
2021-05-20rustdoc: add tooltips to some buttonsLiigo Zhuang-4/+4
2021-05-20Rollup merge of #85470 - GuillaumeGomez:fix-css-rules, r=jshaRalf Jung-9/+6
Fix invalid CSS rules for a:hover When hovering some links: ![Screenshot from 2021-05-19 15-00-31](https://user-images.githubusercontent.com/3050060/118823585-5f2a4b80-b8b9-11eb-8043-bb7759a178c7.png) ![Screenshot from 2021-05-19 15-00-29](https://user-images.githubusercontent.com/3050060/118823566-5b96c480-b8b9-11eb-8c4e-08e490752fbf.png) It is a side-effect from #84462. r? ```@jsha```
2021-05-20Rollup merge of #85169 - jsha:hoist-classes, r=GuillaumeGomezRalf Jung-15/+10
Add method-toggle to <details> for methods The makes the code for handling "auto-hide" settings more consistent. Demo at https://hoffman-andrews.com/rust/hoist-classes/std/string/struct.String.html Fixes #84829
2021-05-19rustdoc: render `<Self as X>::Y` type casts properlyJustus K-3/+6
2021-05-19Fix invalid CSS rules for a:hoverGuillaume Gomez-9/+6
2021-05-18Rollup merge of #85438 - GuillaumeGomez:fix-escape-handling, r=jshaJack Huey-2/+2
Fix escape handling Currently, when we press Escape while on the search results, nothing is happening, this PR fixes it. More information: it's because in case the element doesn't exist, `hasClass` will return `null`, which coerces into `false` with the `!` comparison operator. But even if it returned `false`, it would still be an issue because if the element doesn't exist, it means it's hidden so in this case it's just as good, hence the additional check I added. r? ``@jsha``
2021-05-18Rollup merge of #85396 - jsha:top-doc-font-sizes, r=GuillaumeGomezJack Huey-3/+7
rustdoc: restore header sizes The `<details>` toggle work changed the relationship from #main to the top-doc docblock so it was no longer a parent relationship but a great-grandparent relationship. This updates the CSS rules that set the heading sizes so they still apply. Fixes #85389 r? ``@camelid``
2021-05-18Add method-toggle to <details> for methods.Jacob Hoffman-Andrews-15/+10
The makes the code for handling "auto-hide" settings more consistent.
2021-05-18Rollup merge of #85407 - GuillaumeGomez:copy-path-display-improvement, r=jshaRalf Jung-13/+39
Improve display for "copy-path" button, making it more discreet As suggested by `@Nemo157` [here](https://github.com/rust-lang/rust/pull/85118#issuecomment-838887670): ![Screenshot from 2021-05-18 11-18-49](https://user-images.githubusercontent.com/3050060/118626882-899ddb00-b7cb-11eb-84c5-ef68dee5e351.png) ![Screenshot from 2021-05-18 11-15-06](https://user-images.githubusercontent.com/3050060/118626880-899ddb00-b7cb-11eb-95c1-2f3bacd22374.png) ![Screenshot from 2021-05-18 11-18-54](https://user-images.githubusercontent.com/3050060/118626885-8a367180-b7cb-11eb-870c-7acdf4259bef.png) ![Screenshot from 2021-05-18 11-15-00](https://user-images.githubusercontent.com/3050060/118626877-89054480-b7cb-11eb-9efc-9a0f153964ce.png) ![Screenshot from 2021-05-18 11-18-58](https://user-images.githubusercontent.com/3050060/118626888-8a367180-b7cb-11eb-91bb-47867cd0f2cc.png) ![Screenshot from 2021-05-18 11-19-00](https://user-images.githubusercontent.com/3050060/118626891-8acf0800-b7cb-11eb-9e3d-d2937b361524.png) r? `@jsha`
2021-05-18Rollup merge of #84462 - jsha:focus-search-results2, r=GuillaumeGomezRalf Jung-195/+178
rustdoc: use focus for search navigation Rather than keeping track of highlighted element inside the JS, take advantage of `.focus()` and the :focus CSS pseudo-class. This required wrapping each row of results in one big `<a>` tag (because anchors can be focused, but table rows cannot). That in turn required moving from a table layout to a div layout with float. This makes it so Ctrl+Enter opens links in new tabs, and using the arrow keys to navigate off the bottom of the page scrolls the rest of the page into view. It also simplifies the keyboard event handling. It eliminates the need for click handlers on the search results, and for tracking mouse movements. This changes the UI treatment of mouse hovering. A hovered element now gets a light grey background, but does not change the focus. It's possible to have two highlighted search results: one that is focused (via keyboard) and one that is hovered (via mouse). Pressing enter will activate the focused link; clicking will activate the hovered link. This matches up with how Firefox and Chrome handle suggestions in their URL bar, and avoids stray mouse movements changing the focus. Selecting tabs is now done with left/right arrows while any search result is focused. The visibility of results on each search tab is controlled with the "active" class, rather than by setting display: none directly. Note that the old code kept track of highlighted search element when tabbing back and forth. The new code doesn't. Demo at https://hoffman-andrews.com/rust/focus-search-results2/std/?search=fn Fixes #84384 Fixes #79962 Fixes #79872
2021-05-18Fix escape handling on search resultsGuillaume Gomez-2/+2
2021-05-18Rollup merge of #85280 - jsha:move-trait-toggles, r=GuillaumeGomezGuillaume Gomez-2/+7
Toggle-wrap items differently than top-doc. This makes sure things like trait methods get wrapped at the `<h3><code>` level rather than at the `.docblock` level. Also it ensures that only the actual top documentation gets the `.top-doc` class. Fixes #85167 Before: ![image](https://user-images.githubusercontent.com/220205/117743384-98790200-b1bb-11eb-8804-588530842514.png) https://doc.rust-lang.org/nightly/std/io/trait.Read.html#tymethod.read After: ![image](https://user-images.githubusercontent.com/220205/118410882-98a75080-b646-11eb-949d-ca688bab6923.png)
2021-05-18Improve display for "copy-path" button, making it more discreteGuillaume Gomez-13/+39
2021-05-16rustdoc: restore header sizesJacob Hoffman-Andrews-3/+7
2021-05-16Fix invalid input:disabled CSS selectorGuillaume Gomez-4/+4
2021-05-16Auto merge of #85304 - Stupremee:crates-in-sidebar-in-root, r=Nemo157bors-3/+14
rustdoc: Call `initSidebarItems` in root module of crate r? `@jsha` Resolves #85301
2021-05-15Call `initSidebarItems` in root module of crateJustus K-3/+14
2021-05-15Rollup merge of #85323 - GuillaumeGomez:fix-eslint-errors, r=jshaGuillaume Gomez-34/+32
Fix eslint errors I cherry-picked the two non-CI commits from #85285. r? ```@jsha```
2021-05-15Rollup merge of #85289 - GuillaumeGomez:fix-toggle-position-mobile, r=jshaGuillaume Gomez-192/+198
Fix toggle position on mobile Before: ![Screenshot from 2021-05-14 14-21-27](https://user-images.githubusercontent.com/3050060/118276475-fe210300-b4c7-11eb-94f8-4e2a4e10d91e.png) ![Screenshot from 2021-05-14 14-21-30](https://user-images.githubusercontent.com/3050060/118276479-feb99980-b4c7-11eb-85db-40e9df6e9abd.png) After: ![Screenshot from 2021-05-14 15-16-54](https://user-images.githubusercontent.com/3050060/118276494-0416e400-b4c8-11eb-9479-d447928cfa62.png) ![Screenshot from 2021-05-14 15-16-59](https://user-images.githubusercontent.com/3050060/118276498-0416e400-b4c8-11eb-99f6-894276c62dfc.png) r? ```@jsha```
2021-05-15Rollup merge of #85256 - GuillaumeGomez:fix-implementors-display, r=notriddleGuillaume Gomez-1/+1
Fix display for "implementors" section Just saw this problem when going through docs: ![Screenshot from 2021-05-13 15-20-52](https://user-images.githubusercontent.com/3050060/118131978-766fc180-b3ff-11eb-86a8-7f6d22afa675.png) This fix puts it back to normal: ![Screenshot from 2021-05-13 15-23-29](https://user-images.githubusercontent.com/3050060/118132006-7e2f6600-b3ff-11eb-9985-025a7b7c5216.png) You can see it on the `TryFrom` page for example. r? ```@Nemo157```
2021-05-15Minimize amount of fake `DefId`s used in rustdocJustus K-11/+9
2021-05-15Fix eslint errorsGuillaume Gomez-34/+32
2021-05-15chore: update comment in rustdoc.cssShinwoo Park-1/+1
2021-05-15chore: format codeShinwoo Park-3/+6
2021-05-15rustdoc: update static filesShinwoo Park-0/+10
2021-05-15rustdoc: add the license of Noto Sans KRShinwoo Park-0/+93
2021-05-15rustdoc: avoid legacy Korean fonts in WindowsShinwoo Park-1/+9
2021-05-14Unify toggle rules on smaller resolutionsGuillaume Gomez-6/+3
2021-05-14Move @media rules at the end so they override the other rulesGuillaume Gomez-193/+195
2021-05-14Fix toggle position on mobileGuillaume Gomez-1/+8
2021-05-13Toggle-wrap items differently than top-doc.Jacob Hoffman-Andrews-2/+7
This makes sure things like trait methods get wrapped at the `<h3><code>` level rather than at the `.docblock` level. Also it ensures that only the actual top documentation gets the `.top-doc` class.
2021-05-13rustdoc: use focus for search navigationJacob Hoffman-Andrews-195/+178
Rather than keeping track of highlighted element inside the JS, take advantage of `.focus()` and the :focus CSS pseudo-class. This required wrapping each row of results in one big <a> tag (because anchors can be focused, but table rows cannot). That in turn required moving from a table layout to a div layout with float. This makes it so Ctrl+Enter opens links in new tabs, and using the arrow keys to navigate off the bottom of the page scrolls the rest of the page into view. It also simplifies the keyboard event handling. It eliminates the need for click handlers on the search results, and for tracking mouse movements. This changes the UI treatment of mouse hovering. A hovered element now gets a light grey background, but does not change the focused element. It's possible to have two highlighted search results: one that is focused (via keyboard) and one that is hovered (via mouse). Pressing enter will activate the focused link; clicking will activate the hovered link. This matches up with how Firefox and Chrome handle suggestions in their URL bar, and avoids stray mouse movements changing the focus. Selecting tabs is now done with left/right arrows while any search result is focused. The visibility of results on each search tab is controlled with the "active" class, rather than by setting display: none directly. Note that the old code kept track of highlighted search element when tabbing back and forth. The new code doesn't.
2021-05-13Rollup merge of #85175 - GuillaumeGomez:rustdoc-cleanup, r=jshaGuillaume Gomez-274/+150
Rustdoc cleanup Part of https://github.com/rust-lang/rust/issues/83332. The goal of this PR is to remove a few unused things: * The "loading content" things are now unneeded. * Some toggle CSS rules were still there. * Some parts of the JS had a different indent, fixed it. r? `@jsha`
2021-05-13Fix display for "implementors" sectionGuillaume Gomez-1/+1
2021-05-12Rollup merge of #85174 - GuillaumeGomez:doc-code-block-border-radius, r=jshaGuillaume Gomez-2/+2
Fix border radius for doc code blocks in rustdoc In #85148, I made an invalid change on the border radius of the doc code blocks (look in the top left and bottom left corners of the code blocks). Before this fix: ![Screenshot from 2021-05-11 11-14-59](https://user-images.githubusercontent.com/3050060/117791459-a4f86b80-b24a-11eb-8ac3-facc719c799a.png) After this fix: ![Screenshot from 2021-05-11 11-05-29](https://user-images.githubusercontent.com/3050060/117791482-a9bd1f80-b24a-11eb-8c38-a01989595f5c.png) r? `@jsha`
2021-05-12Rollup merge of #85141 - GuillaumeGomez:maybe_collapsed_doc_value-doc, r=jshaGuillaume Gomez-2/+2
Update documentation for SharedContext::maybe_collapsed_doc_value Fixes #85120. The `doc-collapse` was removed, however, the main crate is always "collapsed", meaning that this function is still needed. I updated the documentation instead to avoid misleading readers. r? `@jsha`
2021-05-12Rollup merge of #85117 - jsha:bubble-bubble-toil-and-trouble, r=GuillaumeGomezGuillaume Gomez-128/+138
Move global click handlers to per-element ones. In rustdoc's main.js, we had an onclick handler for the whole document that would dispatch to handlers for various elements. This change attaches the handlers to the elements that trigger them, instead. This simplifies the code and avoids reimplementing the browser's bubbling functionality. As part of this change, change from a class to an id for help button. Move the handlers and associated code for highlighting source lines into source-script.js (and factor out a shared regex). Demo at https://hoffman-andrews.com/rust/bubble-bubble-toil-and-trouble/std/string/struct.String.html Note: this conflicts with / depends on #85074. Once that's merged I'll rebase this and resolve conflicts. Part of #83332. Thanks to `@Manishearth` for the [suggestion to not reimplement bubbling](https://github.com/rust-lang/rust/issues/83332#issuecomment-803497509). r? `@GuillaumeGomez`
2021-05-12Auto merge of #83813 - cbeuw:remap-std, r=michaelwoeristerbors-5/+15
Fix `--remap-path-prefix` not correctly remapping `rust-src` component paths and unify handling of path mapping with virtualized paths This PR fixes #73167 ("Binaries end up containing path to the rust-src component despite `--remap-path-prefix`") by preventing real local filesystem paths from reaching compilation output if the path is supposed to be remapped. `RealFileName::Named` introduced in #72767 is now renamed as `LocalPath`, because this variant wraps a (most likely) valid local filesystem path. `RealFileName::Devirtualized` is renamed as `Remapped` to be used for remapped path from a real path via `--remap-path-prefix` argument, as well as real path inferred from a virtualized (during compiler bootstrapping) `/rustc/...` path. The `local_path` field is now an `Option<PathBuf>`, as it will be set to `None` before serialisation, so it never reaches any build output. Attempting to serialise a non-`None` `local_path` will cause an assertion faliure. When a path is remapped, a `RealFileName::Remapped` variant is created. The original path is preserved in `local_path` field and the remapped path is saved in `virtual_name` field. Previously, the `local_path` is directly modified which goes against its purpose of "suitable for reading from the file system on the local host". `rustc_span::SourceFile`'s fields `unmapped_path` (introduced by #44940) and `name_was_remapped` (introduced by #41508 when `--remap-path-prefix` feature originally added) are removed, as these two pieces of information can be inferred from the `name` field: if it's anything other than a `FileName::Real(_)`, or if it is a `FileName::Real(RealFileName::LocalPath(_))`, then clearly `name_was_remapped` would've been false and `unmapped_path` would've been `None`. If it is a `FileName::Real(RealFileName::Remapped{local_path, virtual_name})`, then `name_was_remapped` would've been true and `unmapped_path` would've been `Some(local_path)`. cc `@eddyb` who implemented `/rustc/...` path devirtualisation
2021-05-12Fix indent in JS filesGuillaume Gomez-138/+140
2021-05-12Remove unused CSS rulesGuillaume Gomez-71/+2
2021-05-12Remove "loading content" which is now unnecessaryGuillaume Gomez-65/+8
2021-05-12Rollup merge of #85124 - jsha:trust-the-bool, r=GuillaumeGomezYuki Okushi-69/+64
rustdoc: remove explicit boolean comparisons. For boolean variables it's shorter and more readable to check the value directly, or negate it with `!`. In a couple of cases I reordered an if/else pair because it made the initial `if` statement simpler. An example of a style guide recommending this: https://airbnb.io/javascript/#comparison--shortcuts r? `@GuillaumeGomez`
2021-05-11Move global click handlers to per-element ones.Jacob Hoffman-Andrews-128/+138
In rustdoc's main.js, we had an onclick handler for the whole document that would dispatch to handlers for various elements. This change attaches the handlers to the elements that trigger them, instead. This simplfies the code and avoids reimplementing the browser's bubbling functionality. As part of this change, change from a class to an id for help button. Move the handlers and associated code for highlighting source lines into source-script.js (and factor out a shared regex).
2021-05-11rustdoc: remove explicit boolean comparisons.Jacob Hoffman-Andrews-69/+64
For boolean variables it's shorter and more readable to check the value directly, or negate it with `!`. In a couple of cases I reordered an if/else pair because it made the initial `if` statement simpler. Removed unused isType parameter from two functions.
2021-05-11Disable layout docs for type aliases for nowCamelid-2/+0
There are issues with computing layout for type aliases; see #85103. Once the issues are fixed, we should re-enable layout docs for them.
2021-05-11Add note to docs when layout cannot be computedCamelid-7/+26
This should prevent confusion about why generic types don't have layout docs.
2021-05-11Apply suggestions from code reviewCamelid-3/+4
Co-authored-by: Ivan Tham <pickfire@riseup.net>