about summary refs log tree commit diff
path: root/src/librustdoc/html/render
AgeCommit message (Collapse)AuthorLines
2022-02-27Rollup merge of #94417 - GuillaumeGomez:fix-duplicated-impl-links, r=notriddleMatthias Krüger-7/+10
Fix duplicated impl links Fixes #78701. The problem is that the blanket impl has the same ID as the other impl, except that we don't derive IDs when we generate the sidebar. We now do. r? ``@notriddle``
2022-02-27Correctly generate links in the sidebar for implsGuillaume Gomez-7/+10
2022-02-22Prevent generation of infinite redirectionsGuillaume Gomez-26/+34
2022-02-20Rollup merge of #94002 - GuillaumeGomez:duplicated-sidebar-macro, r=notriddleMatthias Krüger-6/+11
rustdoc: Avoid duplicating macros in sidebar Fixes #93912. cc ``````@jsha`````` (for the GUI test) r? ``````@camelid``````
2022-02-17Rollup merge of #94011 - est31:let_else, r=lcnrMatthias Krüger-3/+1
Even more let_else adoptions Continuation of #89933, #91018, #91481, #93046, #93590.
2022-02-16Adopt let_else in even more placesest31-3/+1
2022-02-16Unify sidebar a bit more by generating a list using <ul> instead of <div> ↵Guillaume Gomez-121/+104
elements
2022-02-14Fix macro reexports duplicates in the sidebarGuillaume Gomez-6/+11
2022-02-10Rollup merge of #93830 - camelid:cleanup-section-code, r=GuillaumeGomezMatthias Krüger-81/+171
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-40/+48
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-22/+13
2022-02-09rustdoc: Create enum for sections holding itemsNoah Lev-37/+128
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-03rustdoc: clippy::complexity fixesMatthias Krüger-1/+1
clippy::map_flatten clippy::clone_on_copy clippy::useless_conversion clippy::needless_arbitrary_self_type
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-02-01librustdoc: render: use render_into instead of creating a temp stringMuhammad Falak R Wani-2/+1
Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com>
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-30Auto merge of #92711 - zredb:issue-90187-fix, r=notriddlebors-24/+34
rustdoc: Remove `def_id_no_primitives` Fixes #90187.
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-25Rollup merge of #93251 - jsha:theme-radio, r=GuillaumeGomezMatthias Krüger-40/+35
rustdoc settings: use radio buttons for theme 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. Demo: https://rustdoc.crud.net/jsha/theme-radio/settings.html r? ``@GuillaumeGomez`` New: ![image](https://user-images.githubusercontent.com/220205/150702647-4826d525-54fa-439a-b24c-6d5bca6f95bf.png) Old: ![image](https://user-images.githubusercontent.com/220205/150702669-6a4214ed-1dab-4fee-b1aa-59acfce3dbca.png)
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-23Rollup merge of #93229 - mark-i-m:noquiet, r=eddybMatthias Krüger-5/+7
Remove DiagnosticBuilder.quiet r? `@eddyb` cc https://github.com/rust-lang/rust/issues/69426 `@GuillaumeGomez` `@Manishearth`
2022-01-23Remove DiagnosticBuilder.quietmark-5/+7
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-21Remove a span from hir::ExprKind::MethodCallCameron Steffen-2/+2
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-35/+8
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-17Auto merge of #90986 - camsteffen:nested-filter, r=cjgillotbors-4/+5
Replace `NestedVisitorMap` with generic `NestedFilter` This is an attempt to make the `intravisit::Visitor` API simpler and "more const" with regard to nested visiting. With this change, `intravisit::Visitor` does not visit nested things by default, unless you specify `type NestedFilter = nested_filter::OnlyBodies` (or `All`). `nested_visit_map` returns `Self::Map` instead of `NestedVisitorMap<Self::Map>`. It panics by default (unreachable if `type NestedFilter` is omitted). One somewhat trixty thing here is that `nested_filter::{OnlyBodies, All}` live in `rustc_middle` so that they may have `type Map = map::Map` and so that `impl Visitor`s never need to specify `type Map` - it has a default of `Self::NestedFilter::Map`.
2022-01-17Correctly handle pure genericsGuillaume Gomez-4/+6
2022-01-17fix #90187: Replace all def_id_no_primitives with def_idzredb-1/+1
2022-01-17fix #90187zredb-6/+17
2022-01-17fix #90187zredb-13/+10
2022-01-17Rollup merge of #92937 - GuillaumeGomez:dot-separator, r=jshaMatthias Krüger-3/+7
rustdoc: Add missing dot separator Fixes #92901. ![Screenshot from 2022-01-15 17-47-18](https://user-images.githubusercontent.com/3050060/149631249-e2c0c3a4-9ed8-48e2-92cc-79a5bb347b35.png) r? ``@jsha``
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-16Replace NestedVisitorMap with NestedFilterCameron Steffen-4/+5
2022-01-15Fix missing dot separatorGuillaume Gomez-3/+7
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-8/+6
librustdoc: Address some clippy lints
2022-01-14Auto merge of #91948 - nnethercote:rustdoc-more-Symbols, r=GuillaumeGomezbors-78/+73
rustdoc: avoid many `Symbol` to `String` conversions. Particularly when constructing file paths and fully qualified paths. This avoids a lot of allocations, speeding things up on almost all examples. r? `@GuillaumeGomez`
2022-01-14Use UrlPartsBuilder and remove `join_with_slash`Noah Lev-14/+16
2022-01-14rustdoc: remove many unnecessary `.as_ref()` calls.Nicholas Nethercote-38/+29
2022-01-14rustdoc: avoid many `Symbol` to `String` conversions.Nicholas Nethercote-32/+34
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-14Rollup merge of #92854 - Urgau:better-rust-logo, r=GuillaumeGomezMatthias Krüger-1/+1
Use the updated Rust logo in rustdoc This pull-request use the updated Rust logo from https://github.com/rust-lang/rust-artwork/pull/9 and also change the logo format from PNG to SVG. | Before | After | | --- | --- | | ![Screenshot 2022-01-13 at 14-33-40 std - Rust](https://user-images.githubusercontent.com/3616612/149342697-7afe4c3e-2be5-444b-86f3-118712b4f7ae.png) | ![Screenshot 2022-01-13 at 14-33-15 std - Rust](https://user-images.githubusercontent.com/3616612/149342705-54ed27c6-0806-4c2d-baa1-4d65ed897e2b.png) | I also took the liberty to update the two PNG favicons with the SVG reducing their size by ~35% each. Fixes https://github.com/rust-lang/rust/issues/92831 r? ```@jsha```