summary refs log tree commit diff
path: root/src/librustdoc/html/render/mod.rs
AgeCommit message (Collapse)AuthorLines
2022-10-27Rollup merge of #103432 - jsha:box-is-not-notable, r=GuillaumeGomezYuki Okushi-0/+9
rustdoc: don't mark Box<T> as Iterator, Read, etc Because Box<T> has pass-through implementations, rustdoc was giving it the "Notable Traits" treatment for Iterator, Read, Write, and Future, even when the type of T was unspecified. Pin had the same problem, but just for Future. Fixes #100320
2022-10-23rustdoc: don't mark Box<T> as Iterator, Read, etcJacob Hoffman-Andrews-0/+9
Because Box<T> has pass-through implementations, rustdoc was giving it the "Notable Traits" treatment for Iterator, Read, Write, and Future, even when the type of T was unspecified. Pin had the same problem, but just for Future.
2022-10-18rustdoc: remove class name `location` from sidebar sibling navMichael Howell-1/+1
This change tweaks the CSS to apply most of its styles to `.sidebar h2`, cleaning up a few redundant rules from `.mobile-topbar .location` and restoring useful navigation aids in mobile mode.
2022-10-15rustdoc: remove unused HTML class `sidebar-title`Michael Howell-7/+1
Since 6a5f8b1aef1417d7dc85b5d0a229d2db1930eb7c, this class is no longer styled.
2022-10-10Remove outdated commentMichael Howell-1/+0
2022-10-10rustdoc: remove unneeded `<div>` wrapper from sidebar DOMMichael Howell-16/+7
When this was added, the sidebar had a bit more complex style. It can be removed, now.
2022-10-05rustdoc: remove unused CSS class `in-band`Michael Howell-8/+2
Since a7c25b29575c17434406b69773f8c2961af343b3 removed `in-band` from code headers, the only remaining uses of the `in-band` class are: https://github.com/rust-lang/rust/blob/02cd79afb8080fce8c8ce35533c54d8ecf8f390e/src/librustdoc/html/render/write_shared.rs#L520-L521 https://github.com/rust-lang/rust/blob/02cd79afb8080fce8c8ce35533c54d8ecf8f390e/src/librustdoc/html/templates/print_item.html#L2-L3 https://github.com/rust-lang/rust/blob/02cd79afb8080fce8c8ce35533c54d8ecf8f390e/src/librustdoc/html/render/context.rs#L637-L638 https://github.com/rust-lang/rust/blob/02cd79afb8080fce8c8ce35533c54d8ecf8f390e/src/librustdoc/html/render/mod.rs#L368-L369 https://github.com/rust-lang/rust/blob/02cd79afb8080fce8c8ce35533c54d8ecf8f390e/src/librustdoc/html/render/mod.rs#L401-L402 https://github.com/rust-lang/rust/blob/02cd79afb8080fce8c8ce35533c54d8ecf8f390e/src/librustdoc/html/static/js/main.js#L525 Since all of these uses are nested below `h1.fqn`, we can get rid of it, and the support code that was used for when `in-band` was part of item rendering.
2022-09-27rustdoc: remove `clean::TraitWithExtraInfo`Michael Howell-3/+8
Instead, it gathers the extra info later, when it's actually requested.
2022-09-25rustdoc: clean up `.out-of-band`/`.in-band` CSSMichael Howell-1/+1
* Remove the `float: right` fallback from the main header, which hasn't been needed since IE11 support was dropped. * Remove `in-band` from low-level headers, which hasn't been needed since `.rightside` switched to `float: right` in 593d6d1cb15c55c88319470dabb40126c7b7f1e2 * Remove unreachable `.in-band > code, .in-band > .code-header` CSS, since the `in-band` class was attached to the `code-header` itself, not nested directly below it. * Use `rem` instead of `em` for code header margins. * This results in a slight change in spacing around impls and item-info, but since it makes it more consistent with the way methods are presented, it's probably fine.
2022-09-23Rollup merge of #102158 - notriddle:notriddle/stab-p, r=GuillaumeGomezMatthias Krüger-9/+4
rustdoc: clean up CSS/DOM for deprecation warnings Preview: https://notriddle.com/notriddle-rustdoc-test/stab-p/std/macro.try.html
2022-09-22rustdoc: clean up CSS/DOM for deprecation warningsMichael Howell-9/+4
2022-09-22Improve some AllTypes fields nameGuillaume Gomez-10/+12
2022-09-20Unify generation of section on "All items" page with all other pagesGuillaume Gomez-18/+18
2022-09-20Generate sidebar elements for the "All items" pageGuillaume Gomez-18/+70
2022-09-16rustdoc: clean up CSS for All Items and All Crates listsMichael Howell-18/+17
This reduces the amount of CSS, and makes these two pages more consistent (which, necessarily, means changing them a bit).
2022-09-03more clippy::perf fixesMatthias Krüger-2/+2
2022-09-01Rollup merge of #101245 - GuillaumeGomez:remove-unneeded-where-whitespace, ↵Matthias Krüger-6/+6
r=notriddle Remove unneeded where whitespace It fixes these two bugs: ![Screenshot from 2022-08-31 18-14-40](https://user-images.githubusercontent.com/3050060/187727950-94657419-abfa-454c-9d27-004280fbcb45.png) ![Screenshot from 2022-08-31 18-14-49](https://user-images.githubusercontent.com/3050060/187727956-21d1b39d-62d7-4e7b-8f6f-631ceda67a19.png) It's a relic from a very old time (this commit: https://github.com/rust-lang/rust/commit/bfd01b7f40ae2cbfe9acbc1d10e79ffe16870df8). You can test the result [here](https://rustdoc.crud.net/imperio/remove-unneeded-where-whitespace/lib2/struct.WhereWhitespace.html). cc `````````@jsha````````` r? `````````@notriddle`````````
2022-08-31Remove unneeded extra whitespace before where clauseGuillaume Gomez-6/+6
2022-08-31Rollup merge of #101204 - aDotInTheVoid:async-resugar-in-clean, r=GuillaumeGomezRalf Jung-1/+1
rustdoc: Resugar async fn return type in `clean`, not `html` This way it also happens for json output. Fixes #101199 r? ``@GuillaumeGomez``
2022-08-31Print only blanket implementations on reference primitive typeGuillaume Gomez-62/+118
2022-08-30Clean up render_assoc_items_inner a bitGuillaume Gomez-54/+52
2022-08-30rustdoc: Resugar async fn return type in `clean`, not `html`Nixon Enraght-Moony-1/+1
This way it also happens for json output. Fixes #101199
2022-08-26Rollup merge of #101006 - GuillaumeGomez:doc-cfg-reexport, r=notriddleGuillaume Gomez-1/+8
Fix doc cfg on reexports Fixes #83428. The problem was that the newly inlined item cfg propagation was not working since its real parent is different than its current one. For the implementation, I decided to put it directly into `CfgPropagation` instead of inside `inline.rs` because I thought it would be simpler to maintain and to not forget if new kind of items are added if it's all done in one place. r? `@notriddle`
2022-08-25Fix missing cfg propagation for reexportsGuillaume Gomez-1/+8
2022-08-24Remove the extra DOM level if there is only one child in rightside elementsGuillaume Gomez-11/+34
2022-08-24Unify rightside renderingGuillaume Gomez-7/+3
2022-08-21Auto merge of #100645 - notriddle:notriddle/rustdoc-diet-plan, r=GuillaumeGomezbors-2/+2
rustdoc: strategic boxing to reduce the size of ItemKind and Type The `Type` change redesigns `QPath` to box the entire data structure instead of boxing `self_type` and the `trait_`. This reduces the size of several `ItemKind` variants, leaving `Impl` as the biggest variant. The `ItemKind` change boxes that variant's payload.
2022-08-20Rollup merge of #100718 - GuillaumeGomez:fix-item-info, r=jshaMatthias Krüger-4/+8
[rustdoc] Fix item info display Fixes #100369. The solution I came up with was simply to wrap the "text part" of the `item-info` into another span so that `flex` wouldn't mess with it. Live demo is [here](https://rustdoc.crud.net/imperio/fix-item-info/foo/struct.ItemInfo.html). r? ``@jsha``
2022-08-18rustdoc: count deref and non-deref as same set of used methodsMichael Howell-6/+11
2022-08-18Fix item-info displayGuillaume Gomez-4/+8
2022-08-16rustdoc: factor Type::QPath out into its own boxMichael Howell-2/+2
This reduces the size of Type.
2022-08-13make clean::Item::span return option instead of dummy spanMichael Goulet-1/+1
2022-08-11Rollup merge of #99337 - jsha:simplify-highlight, r=GuillaumeGomezMatthias Krüger-2/+1
rustdoc: simplify highlight.rs Split render_with_highlighting, which took many optional parameters, into three functions for specific purposes, which each take a smaller number of mostly required parameters. Remove some plumbing to pass through an "edition" parameter, which was used solely to avoid highlighting some 2021 Edition keywords in non-2021 code. I've tested a build of std docs before and after, and this does not change the generated HTML at all. Followup from https://github.com/rust-lang/rust/pull/91264#discussion_r901151101 r? ```@GuillaumeGomez```
2022-08-09rustdoc: simplify highlight.rsJacob Hoffman-Andrews-2/+1
Split render_with_highlighting, which took many optional parameters, into three functions for specific purposes, which each take a smaller number of mostly required parameters. Remove some plumbing to pass through an "edition" parameter, which was used solely to avoid highlighting some 2021 Edition keywords in non-2021 code.
2022-08-07Don't document impossible to call default trait items on implsMichael Goulet-0/+9
2022-07-29Box TypedefItem, ImplItem, AssocTypeItem variants of ItemKindest31-2/+2
This reduces ItemKind size from 224 bytes to 160 bytes.
2022-07-22Make some clean::Trait fields computation on demandGuillaume Gomez-1/+1
2022-07-08add opt in attribute for stable-in-unstable itemsJane Lusby-1/+1
2022-07-07Rollup merge of #99017 - GuillaumeGomez:rustdoc-ending-enum, r=notriddleMatthias Krüger-4/+4
Replace boolean argument for print_where_clause with an enum to make code more clear As you suggested ``@notriddle.`` Just not sure if the naming seems good to you? r? ``@notriddle``
2022-07-07Replace boolean argument for print_where_clause with an enum to make code ↵Guillaume Gomez-4/+4
more clear
2022-07-07Rollup merge of #98973 - GuillaumeGomez:inherent-impl-anchors, r=notriddleDylan DPC-4/+16
Remove (unused) inherent impl anchors This is something `@notriddle` realized a few days ago: we have unused anchors in the DOM. This PR removes them. You can test it [here](https://rustdoc.crud.net/imperio/inherent-impl-anchors/foo/index.html). r? `@notriddle`
2022-07-06Don't generate anchors on inherent impl methodsGuillaume Gomez-4/+16
2022-07-05Fix link generation in the sidebar for implsGuillaume Gomez-15/+12
2022-07-05rustdoc: Add more semantic information to impl idspierwill-25/+8
Instead of generating `#impl`, `#impl-1`, etc., generate IDs like `#impl-Foo<M>`. Co-authored-by: Noah Lev <camelidcamel@gmail.com>
2022-07-04Rollup merge of #98814 - fmease:minimal-fix-for-issue-97933, r=GuillaumeGomezMatthias Krüger-1/+3
rustdoc: Censor certain complex unevaluated const exprs Fixes #97933. This is more of a hotfix for the aforementioned issue. By that, I mean that my proposed patch is not the best solution but one that does not change as much existing code. It treats symptoms rather than the root cause. This PR “censors” certain complex unevaluated constant expressions like `match`es, blocks, function calls, struct literals etc. by pretty-printing them as `_` / `{ _ }` (number and string literals, paths and `()` are still printed as one would expect). Resorting to this placeholder is preferable to printing the full expression verbatim since they can be quite large and verbose resulting in an unreadable mess in the generated documentation. Further, mindlessly printing the const would leak private and `doc(hidden)` struct fields (#97933), at least in the current stable & nightly implementations which rely on `span_to_snippet` (!) and `rustc_hir_pretty::id_to_string`. The censoring of _verbose_ expressions is probably going to stay longer term. However, in regards to private and `doc(hidden)` struct fields, I have a more proper fix in mind which I have already partially implemented locally and for which I am going to open a separate PR sometime soon. For that, I was already in contact with `@GuillaumeGomez.` The proper fix involves rustdoc not falling back on pretty-printing unevaluated consts so easily (what this PR is concerned about) and instead preferring to print evaluated consts which contain more information allowing it to selectively hide private and `doc(hidden)` fields, create hyperlinks etc. generally making the output more granular and precise (compared to the brutal `_` placeholder). Unfortunately, I was a bit too late and the issue just hit stable (1.62). Should this be backported to beta or even a potential 1.62.1? r? `@GuillaumeGomez`
2022-07-04rustdoc: censor certain complex unevaluated const exprsLeón Orell Valerian Liehr-1/+3
2022-06-27Put back, fix ()-output optimizationMichael Howell-0/+1
2022-06-24rustdoc: reference function signature types from the `p` arrayMichael Howell-37/+44
This reduces the size of the function signature index, because it's common to have many functions that operate on the same types. $ wc -c search-index-old.js search-index-new.js 5224374 search-index-old.js 3932314 search-index-new.js By my math, this reduces the uncompressed size of the search index by 32%. On compressed signatures, the wins are less drastic, a mere 8%: $ wc -c search-index-old.js.gz search-index-new.js.gz 404532 search-index-old.js.gz 371635 search-index-new.js.gz
2022-06-20Improve loading of crates.js and sidebar-items.jsJacob Hoffman-Andrews-18/+1
Now that the "All Crates" dropdown is only rendered on the search results page, there is no need to load crates.js on most pages. Load it only on crate pages. Also, add the `defer` attribute so it does not block page rendering. For sidebar-items.js, move the script tag to `<head>`. Since it already has the defer attribute it won't block loading. The defer attribute does preserve ordering between scripts, so instead of the callback on load, it can set a global variable on load, which is slightly simpler. Also, since it is required to finish rendering the page, beginning its load earlier is better. Remove generation and handling of sidebar-vars. Everything there can be computed with information available in JS via other means. Remove the "other" wrapper in the sidebar. It was unnecessary. Remove excess script fields
2022-06-06Rollup merge of #90905 - GuillaumeGomez:empty-impl-blocks, r=jshaMatthias Krüger-0/+7
Add empty impl blocks if they have documentation Fixes https://github.com/rust-lang/rust/issues/90866. The update for the test script is needed to count the number of impl blocks we have with only the struct. To be noted that with https://github.com/rust-lang/rust/pull/89676 merged, it wouldn't be needed (I don't know what is the status of it btw. cc ```@Mark-Simulacrum).``` It looks like this: ![Screenshot from 2021-11-14 16-51-28](https://user-images.githubusercontent.com/3050060/141689100-e57123c0-bf50-4c42-adf5-d991e169a0e4.png) cc ```@jyn514``` r? ```@camelid```