about summary refs log tree commit diff
path: root/src/librustdoc/html/render/mod.rs
AgeCommit message (Collapse)AuthorLines
2022-02-16Unify sidebar a bit more by generating a list using <ul> instead of <div> ↵Guillaume Gomez-121/+104
elements
2022-02-10Rollup merge of #93830 - camelid:cleanup-section-code, r=GuillaumeGomezMatthias Krüger-64/+156
Refactor sidebar printing code This is the refactoring parts of #92660, plus the trait aliases capitalization consistency fix. I think this will be necessary for #92658. r? `@GuillaumeGomez`
2022-02-09Title-case trait aliases section for consistencyNoah Lev-1/+1
2022-02-09Refactor sidebar printing codeNoah Lev-39/+45
The new code is much simpler and easier to understand. In fact, the old code actually had a subtle bug where it excluded a few item types, including trait aliases, from the sidebar, even though they are rendered on the page itself! Now, all sections should show up in the sidebar.
2022-02-09Deduplicate item sectionsNoah Lev-10/+5
2022-02-09rustdoc: Create enum for sections holding itemsNoah Lev-30/+121
2022-02-09Unify headings indent and remove useless anchorGuillaume Gomez-1/+1
2022-02-04Rollup merge of #93576 - jsha:fix-rustdoc-html, r=GuillaumeGomezMatthias Krüger-35/+27
Emit more valid HTML from rustdoc Previously, tidy-html5 (`tidy`) would complain about a few things in our HTML. The main thing is that `<summary>` tags can't contain `<div>`s. That's easily fixed by changing out the `<div>`s for `<span>`s with `display: block`. However, there's also a rule that `<span>`s can't contain heading elements. `<span>` permits only "phrasing content" https://developer.mozilla.org/en-US/docs/Web/HTML/Element/span, and `<h3>` (and friends) are "Flow content, heading content, palpable content". https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Heading_Elements We have a wrapping `<div>` that goes around each `<h3>`/`<h4>`, etc. We turn that into a `<section>` rather than a `<span>` because `<section>` permits "flow content". https://developer.mozilla.org/en-US/docs/Web/HTML/Element/section After this change we get only three warnings from tidy, run on struct.String.html: line 6 column 10790 - Warning: trimming empty <span> line 1 column 1118 - Warning: <link> proprietary attribute "disabled" line 1 column 1193 - Warning: <link> proprietary attribute "disabled" The empty `<span>` is a known issue - there's a span in front of the search box to work around a strange Safari issue. The `<link>` attributes are the non-default stylesheets. We can probably refactor theme application to avoid using this proprietary "disabled" attribute. We can suppress those warnings with flags to tidy, and get a run that returns 0 (success): ``` tidy -o /dev/null -quiet --drop-empty-elements no --warn-proprietary-attributes no build/x86_64-unknown-linux-gnu/doc/std/string/trait.ToString.html ``` Note: this requires the latest version of tidy-html5, built from https://github.com/htacg/tidy-html5. Older versions (including the default version on Ubuntu 21.10) think `<section>` can't occur inside `<summary>`. Demo: https://rustdoc.crud.net/jsha/fix-rustdoc-html/std/string/struct.String.html r? `@GuillaumeGomez`
2022-02-02Emit valid HTML from rustdocJacob Hoffman-Andrews-35/+27
Previously, tidy-html5 (`tidy`) would complain about a few things in our HTML. The main thing is that `<summary>` tags can't contain `<div>`s. That's easily fixed by changing out the `<div>`s for `<span>`s with `display: block`. However, there's also a rule that `<span>`s can't contain heading elements. `<span>` permits only "phrasing content" https://developer.mozilla.org/en-US/docs/Web/HTML/Element/span, and `<h3>` (and friends) are "Flow content, heading content, palpable content". https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Heading_Elements We have a wrapping `<div>` that goes around each `<h3>`/`<h4>`, etc. We turn that into a `<section>` rather than a `<span>` because `<section>` permits "flow content". https://developer.mozilla.org/en-US/docs/Web/HTML/Element/section After this change we get only three warnings from tidy, run on struct.String.html: line 6 column 10790 - Warning: trimming empty <span> line 1 column 1118 - Warning: <link> proprietary attribute "disabled" line 1 column 1193 - Warning: <link> proprietary attribute "disabled" The empty `<span>` is a known issue - there's a span in front of the search box to work around a strange Safari issue. The `<link>` attributes are the non-default stylesheets. We can probably refactor theme application to avoid using this proprietary "disabled" attribute.
2022-02-02Rollup merge of #93420 - jsha:adjust-settings-layout, r=GuillaumeGomezMatthias Krüger-1/+1
Improve wrapping on settings page Previously, the radio button choices for themes would wrap awkwardly on narrow screens. With this change, the group of choices will prefer bumping down to the next line together, leaving the setting name on its own line. Also fix some minor spacing issues: - Align the setting name vertically with the radio button choices. - Use margin instead of padding for most spacing choices. - Use no margin/padding on the right-hand side. Demo: https://rustdoc.crud.net/jsha/adjust-settings-layout/settings.html r? ``@GuillaumeGomez`` Before (narrow screen): ![image](https://user-images.githubusercontent.com/220205/151555533-7ab65216-d178-4dcc-8792-3c8fb9da8718.png) After (narrow screen): ![image](https://user-images.githubusercontent.com/220205/151555702-ad79af32-f84b-4ee4-ae7a-1a2a463c0f6f.png)
2022-01-31Improve wrapping on settings pageJacob Hoffman-Andrews-1/+1
Previously, the radio button choices for themes would wrap awkwardly on narrow screens. With this change, the group of choices will prefer bumping down to the next line together, leaving the setting name on its own line. Also fix some minor spacing issues: - Align the setting name vertically with the radio button choices. - Use margin instead of padding for most spacing choices. - Use no margin/padding on the right-hand side.
2022-01-30Rollup merge of #93391 - notriddle:notriddle/remove-srclink-tooltip, ↵Matthias Krüger-1/+1
r=jsha,GuillaumeGomez rustdoc: remove tooltip from source link This made more sense back when it was abbreviated, but now it seems redundant.
2022-01-27rustdoc: remove tooltip from source linkMichael Howell-1/+1
This made more sense back when it was abbreviated, but now it seems redundant.
2022-01-25Fix invalid extra dot after version if no sourceGuillaume Gomez-3/+4
2022-01-23rustdoc settings: use radio buttons for themeJacob Hoffman-Andrews-40/+35
This reduces the number of clicks required to change theme. Also, simplify the UI a bit (remove setting grouping), and add a "Back" link close to the settings icon.
2022-01-21rustdoc: Make some `pub` items crate-privateNoah Lev-1/+1
They don't need to be `pub`. Making them crate-private improves code clarity and `dead_code` linting.
2022-01-20Rollup merge of #91694 - euclio:stability-improvements, r=GuillaumeGomezMatthias Krüger-36/+55
rustdoc: decouple stability and const-stability This PR tweaks the stability rendering code to consider stability and const-stability separately. This fixes two issues: - Stabilities that match the enclosing item are now always omitted, even if the item has const-stability as well (#90552) - Const-stable unstable functions will now have their (const-) stability rendered. Fixes #90552.
2022-01-18Simplify and unify rustdoc sidebar stylesJacob Hoffman-Andrews-25/+6
This switches to just use size, weight, and spacing to distinguish headings in the sidebar. We no longer use boxes, horizontal bars, or centering to distinguish headings. This makes it much easier to understand the hierarchy of headings, and reduces visual noise. I also refactored how the mobile topbar works. Previously, we tried to shift around elements from the sidebar to make the topbar. Now, the topbar gets its own elements, which can be styled on their own. This makes styling and reasoning about those elements simpler. Because the heading font sizes are bigger, increase the sidebar width slightly. As a very minor change, removed version from the "All types" page. It's now only on the crate page.
2022-01-18Rollup merge of #92629 - jsha:theme-picker-local-only-2, r=GuillaumeGomezMatthias Krüger-0/+6
Pick themes on settings page, not every page This hides the paintbrush icon on most pages by default, in preference for the settings on the settings page. When loading from a local file, and not in mobile view, continue to show the theme picker. That's because some browsers limit access to localStorage from file:/// URLs, so choosing a theme from settings.html doesn't take effect. Fixes #84539 Part of #59840 r? `@GuillaumeGomez` Demo: https://rustdoc.crud.net/jsha/theme-picker-local-only-2/std/io/trait.Read.html
2022-01-17Rollup merge of #92795 - jsha:link-to-top, r=GuillaumeGomezMatthias Krüger-1/+1
Link sidebar "location" heading to top of page This makes it easy, when you are scrolled far down in a page, to jump back to the top. Demo: https://rustdoc.crud.net/jsha/link-to-top/std/string/struct.String.html r? ``@GuillaumeGomez``
2022-01-14Add support for "always theme" in settingJacob Hoffman-Andrews-0/+6
2022-01-15Rollup merge of #92868 - pierwill:librustdoc-clippy, r=camelidMatthias Krüger-5/+3
librustdoc: Address some clippy lints
2022-01-14rustdoc: avoid many `Symbol` to `String` conversions.Nicholas Nethercote-3/+4
Particularly when constructing file paths and fully qualified paths. This avoids a lot of allocations, speeding things up on almost all examples.
2022-01-14Link sidebar "location" heading to top of pageJacob Hoffman-Andrews-1/+1
This makes it easy, when you are scrolled far down in a page, to jump back to the top.
2022-01-13librustdoc: Address some clippy lintspierwill-5/+3
Also ignore clippy's "collapsible if..." lints.
2022-01-13rustdoc: decouple stability and const-stabilityAndy Russell-36/+55
2022-01-13Auto merge of #92526 - djc:rustdoc-askama, r=jshabors-1/+0
Migrate rustdoc from Tera to Askama See #84419. Should probably get a benchmarking run to verify if it has the intended effect on rustdoc performance. cc `@jsha` `@jyn514.`
2022-01-12Rollup merge of #92742 - GuillaumeGomez:missing-suffix-sidebar-items, ↵Matthias Krüger-1/+5
r=notriddle Add missing suffix for sidebar-items script path Fixes https://github.com/rust-lang/docs.rs/issues/1590. r? ```@syphar```
2022-01-10Add missing suffix for sidebar-items script pathGuillaume Gomez-1/+5
2022-01-10Migrate rustdoc from Tera to AskamaDirkjan Ochtman-1/+0
See #84419.
2022-01-10Rollup merge of #92602 - jsha:source-link-2, r=GuillaumeGomezMatthias Krüger-5/+9
Make source links look cleaner Change from syntaxy-looking [src] to the plain word "source". Change the syntaxy-looking `[-]` at the top of the page to say "collapse". Reduce opacity of rightside content. Part of #59851 r? `@GuillaumeGomez` Demo: https://rustdoc.crud.net/jsha/source-link-2/std/string/struct.String.html [Discussed on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/display.20of.20source.20link).
2022-01-08Remove useless collapse toggle on "all items" pageGuillaume Gomez-8/+0
2022-01-08Make source links look cleanerJacob Hoffman-Andrews-5/+9
Change from syntaxy-looking [src] to the plain word "source".
2021-12-31Rollup merge of #91480 - jsha:fewer-colors, r=GuillaumeGomezMatthias Krüger-1/+1
rustdoc: use smaller number of colors to distinguish items This reduces visual distractions when reading method signatures. As discussed in https://github.com/rust-lang/rust/issues/59845#issuecomment-974757191, this categorizes items into one of six colors (down from thirteen): - method, function (ochre `#AD7C37`) - trait, trait alias (dark slate blue `#6E4FC9`) - enum, struct, type alias, union, primitive (maroon `#AD378A`) - static, module, keyword, associated type, foreign type (steel blue `#3873AD`) - macro (green `#068000`) - generic params, self, Self (unmarked black `#000000`) I slightly tweaked the actual color values so they'd have the same lightness (previously the trait color stood out much more than the others). And I made the color for links in general consistently use steel blue (previously there was a slightly different color for "search-failed"). The ayu and dark themes have been updated according to the same logic. I haven't changed any of the color values in those themes, just their assignment to types. Demo: https://rustdoc.crud.net/jsha/fewer-colors/std/string/struct.String.html https://rustdoc.crud.net/jsha/fewer-colors/std/vec/struct.Vec.html https://rustdoc.crud.net/jsha/fewer-colors/std/io/trait.Read.html https://rustdoc.crud.net/jsha/fewer-colors/std/iter/trait.Iterator.html
2021-12-27Rename `rustdoc::html::render::cache` to `search_index`Noah Lev-1/+1
The old name wasn't very clear, while the new one makes it clear that this is the code responsible for creating the search index.
2021-12-19Auto merge of #92099 - matthiaskrgr:rollup-4gwv67m, r=matthiaskrgrbors-2/+2
Rollup of 7 pull requests Successful merges: - #91141 (Revert "Temporarily rename int_roundings functions to avoid conflicts") - #91984 (Remove `in_band_lifetimes` from `rustc_middle`) - #92028 (Sync portable-simd to fix libcore build for AVX-512 enabled targets) - #92042 (Enable `#[thread_local]` for all windows-msvc targets) - #92071 (Update example code for Vec::splice to change the length) - #92077 (rustdoc: Remove unused `collapsed` field) - #92081 (rustdoc: Remove unnecessary `need_backline` function) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-12-19Auto merge of #91957 - nnethercote:rm-SymbolStr, r=oli-obkbors-5/+5
Remove `SymbolStr` This was originally proposed in https://github.com/rust-lang/rust/pull/74554#discussion_r466203544. As well as removing the icky `SymbolStr` type, it allows the removal of a lot of `&` and `*` occurrences. Best reviewed one commit at a time. r? `@oli-obk`
2021-12-18Remove `collapsed` fieldJoshua Nelson-2/+2
`render/context` always runs after `run_global_context`, so it was always set to `true`. This is a holdover from when rustdoc allowed configuring passes, but the `collapse-docs` pass was removed ages ago, and the ability to configure passes is about to be removed.
2021-12-17Auto merge of #91812 - camelid:assoc-const-lazy, r=GuillaumeGomezbors-12/+4
rustdoc: Pretty-print assoc const defaults on-demand This should improve performance, clean up the code, and help pave the way for #83035.
2021-12-15Remove unnecessary sigils around `Symbol::as_str()` calls.Nicholas Nethercote-4/+4
2021-12-15Remove `SymbolStr`.Nicholas Nethercote-1/+1
By changing `as_str()` to take `&self` instead of `self`, we can just return `&str`. We're still lying about lifetimes, but it's a smaller lie than before, where `SymbolStr` contained a (fake) `&'static str`!
2021-12-14fix clippy::single_char_pattern perf findingsMatthias Krüger-1/+1
2021-12-11rustdoc: Remove unused `_default` parameterNoah Lev-12/+4
It can always be re-added later if we decide to display associated const default values.
2021-12-11rustdoc: Pretty-print assoc const defaults on-demandNoah Lev-1/+1
This should improve performance, clean up the code, and help pave the way for #83035.
2021-12-10Split CSS classes for "typedef" vs "associatedtype".Jacob Hoffman-Andrews-1/+1
2021-12-02Auto merge of #91291 - GuillaumeGomez:const-deref-method, r=camelidbors-16/+33
Fix const deref methods display Fixes https://github.com/rust-lang/rust/issues/90855 (more information in the issue). r? `@camelid`
2021-11-30Return ConstStability instead of &ConstStability in Item::const_stabilityGuillaume Gomez-2/+2
2021-11-30Improve code by replacing &str with Symbol in render_stability_since_rawGuillaume Gomez-11/+7
2021-11-30Fix display for "const" deref methods in rustdocGuillaume Gomez-9/+30
2021-11-29Only show notable traits if both types are the sameMichael Howell-1/+8
Checking only their DefId doesn't work because all slices have the same fake DefId. Fixes #91347