about summary refs log tree commit diff
path: root/src/librustdoc/html/render/print_item.rs
AgeCommit message (Collapse)AuthorLines
2022-02-16Adopt let_else in even more placesest31-3/+1
2022-02-10Rollup merge of #93830 - camelid:cleanup-section-code, r=GuillaumeGomezMatthias Krüger-17/+15
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-09Refactor sidebar printing codeNoah Lev-1/+3
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-12/+8
2022-02-09rustdoc: Create enum for sections holding itemsNoah Lev-7/+7
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-15Fix missing dot separatorGuillaume Gomez-3/+7
2022-01-15Rollup merge of #92868 - pierwill:librustdoc-clippy, r=camelidMatthias Krüger-3/+3
librustdoc: Address some clippy lints
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-15/+12
Particularly when constructing file paths and fully qualified paths. This avoids a lot of allocations, speeding things up on almost all examples.
2022-01-13librustdoc: Address some clippy lintspierwill-3/+3
Also ignore clippy's "collapsible if..." lints.
2022-01-13Rollup merge of #91687 - euclio:tuple-variant-field-section, r=GuillaumeGomezMatthias Krüger-5/+14
rustdoc: do not emit tuple variant fields if none are documented Fixes #90824. Before: ![2021-12-15T22:26:41](https://user-images.githubusercontent.com/1372438/146302871-4d265433-b9aa-4e53-adfb-e7cb92107180.png) After: ![2021-12-15T22:27:01](https://user-images.githubusercontent.com/1372438/146302872-e39eda3d-2fb2-4fb9-aae7-2008e4e1b4dd.png)
2022-01-13Auto merge of #92526 - djc:rustdoc-askama, r=jshabors-12/+5
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 #92699 - camelid:private-fields, r=jshaMatthias Krüger-5/+3
rustdoc: Display "private fields" instead of "fields omitted" Also: * Always use `/* */` block comments * Use the same message everywhere, rather than sometimes prefixing with "some" When I first read rustdoc docs, I was confused why the fields were being omitted. It was only later that I realized it was because they were private. It's also always bothered me that rustdoc sometimes uses `//` and sometimes uses `/*` comments for these messages, so this change makes them all use `/*`. Technically, I think fields can be omitted if they are public but `doc(hidden)` too, but `doc(hidden)` is analogous to privacy. It's really just used to emulate "doc privacy" when -- because of technical limitations -- an item has to be public. So I think it's fine to include this under the category of "private fields". r? ```@jsha```
2022-01-11rustdoc: do not emit tuple variant fields if none are documentedAndy Russell-5/+14
2022-01-11Store a `Symbol` instead of an `Ident` in `VariantDef`/`FieldDef`Aaron Hill-2/+2
The field is also renamed from `ident` to `name. In most cases, we don't actually need the `Span`. A new `ident` method is added to `VariantDef` and `FieldDef`, which constructs the full `Ident` using `tcx.def_ident_span()`. This method is used in the cases where we actually need an `Ident`. This makes incremental compilation properly track changes to the `Span`, without all of the invalidations caused by storing a `Span` directly via an `Ident`.
2022-01-10Address feedbackDirkjan Ochtman-3/+1
2022-01-10Migrate rustdoc from Tera to AskamaDirkjan Ochtman-10/+5
See #84419.
2022-01-09Display "private fields" instead of "fields omitted"Noah Lev-5/+3
Also: * Always use `/* */` block comments * Use the same message everywhere, rather than sometimes prefixing with "some" When I first read rustdoc docs, I was confused why the fields were being omitted. It was only later that I realized it was because they were private. It's also always bothered me that rustdoc sometimes uses `//` and sometimes uses `/*` comments for these messages, so this change makes them all use `/*`. Technically, I think fields can be omitted if they are public but `doc(hidden)` too, but `doc(hidden)` is analogous to privacy. It's really just used to emulate "doc privacy" when -- because of technical limitations -- an item has to be public. So I think it's fine to include this under the category of "private fields".
2022-01-08Make source links look cleanerJacob Hoffman-Andrews-3/+3
Change from syntaxy-looking [src] to the plain word "source".
2021-12-15Remove unnecessary sigils around `Symbol::as_str()` calls.Nicholas Nethercote-6/+6
2021-12-15Remove `SymbolStr`.Nicholas Nethercote-3/+3
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-11Rollup merge of #91682 - camelid:alias-layout, r=jyn514Matthias Krüger-0/+1
rustdoc: Show type layout for type aliases Fixes #91265. At first, you might think, "Why not just click through to the aliased type?" But, if a type alias instantiates all of the generic parameters of the aliased type, then it can show layout info even though the aliased type cannot (because we can't compute layout for generic types). So, I think it's useful to show layout info for type aliases. This is a followup of 78d4b453ad2e19d44011b26fc55c949bff5dba3d (originally part of #83501).
2021-12-08rustdoc: Show type layout for type aliasesNoah Lev-0/+1
At first, you might think, "Why not just click through to the aliased type?" But, if a type alias instantiates all of the generic parameters of the aliased type, then it can show layout info even though the aliased type cannot (because we can't compute layout for generic types). So, I think it's useful to show layout info for type aliases. This is a followup of 78d4b453ad2e19d44011b26fc55c949bff5dba3d (originally part of #83501).
2021-12-04Make rustdoc headings black, and markdown blueJacob Hoffman-Andrews-1/+1
2021-12-02Auto merge of #91291 - GuillaumeGomez:const-deref-method, r=camelidbors-9/+44
Fix const deref methods display Fixes https://github.com/rust-lang/rust/issues/90855 (more information in the issue). r? `@camelid`
2021-12-01address reviewb-naber-1/+1
2021-12-01more fixed issuesb-naber-0/+7
2021-11-30Improve code by replacing &str with Symbol in render_stability_since_rawGuillaume Gomez-4/+4
2021-11-30Fix display for "const" deref methods in rustdocGuillaume Gomez-5/+40
2021-11-26Rename `Type::ResolvedPath` to `Type::Path`Noah Lev-12/+13
At last! The new name is shorter, simpler, and consistent with `hir::Ty`.
2021-11-25Stop re-exporting `Type::ResolvedPath`Noah Lev-13/+12
I would like to rename it to `Type::Path`, but then it can't be re-exported since the name would conflict with the `Path` struct. Usually enum variants are referred to using their qualified names in Rust (and parts of rustdoc already do that with `clean::Type`), so this is also more consistent with the language.
2021-11-24Remove `ResolvedPath.did`Noah Lev-4/+5
2021-11-20Rollup merge of #90089 - jsha:enum-fields-headings, r=camelid,GuillaumeGomezMatthias Krüger-13/+11
Improve display of enum variants Use h3 and h4 for the variant name and the "Fields" subheading. Remove the "of T" part of the "Fields" subheading. Remove border-bottom from "Fields" subheading. Move docblock below "Fields" listing. Fixes #90061 Demo: https://jacob.hoffman-andrews.com/rust/xmlparser-updated/xmlparser/enum.Token.html#variants https://jacob.hoffman-andrews.com/rust/fix-enum-variants/std/io/enum.ErrorKind.html#variants https://jacob.hoffman-andrews.com/rust/fix-enum-variants/std/result/enum.Result.html#variants r? ``@camelid``
2021-11-07rustdoc: Remove top-level wrappers for `ImplKind` methodsNoah Lev-1/+1
The `ImplKind` methods can just be used directly instead.
2021-11-07rustdoc: Refactor `Impl.{synthetic,blanket_impl}` into enumNoah Lev-1/+1
This change has two advantages: 1. It makes the possible states clearer, and it makes it impossible to construct invalid states, such as a blanket impl that is also an auto trait impl. 2. It shrinks the size of `Impl` a bit, since now there is only one field, rather than two.
2021-10-30Improve display of enum variantsJacob Hoffman-Andrews-13/+11
Use h3 and h4 for the variant name and the "Fields" subheading. Remove the "of T" part of the "Fields" subheading. Remove border-bottom from "Fields" subheading. Move docblock below "Fields" listing.
2021-10-27Auto merge of #90186 - jsha:fix-header-sizes, r=GuillaumeGomezbors-4/+4
Fix documentation header sizes And add a rustdoc-gui test confirming various header sizes. Split off from #90156. This fixes a regression in #89506 where the heading level of titles within Markdown was too high (h2) for docblocks under structs, unions, and enum impls. r? `@camelid` Demo: https://jacob.hoffman-andrews.com/rust/fix-header-sizes/std/string/struct.String.html#impl-Add%3C%26%27_%20str%3E Stable: https://doc.rust-lang.org/stable/std/string/struct.String.html#impl-Add%3C%26%27_%20str%3E Beta: https://doc.rust-lang.org/beta/std/string/struct.String.html#impl-Add%3C%26%27_%20str%3E
2021-10-27Rollup merge of #90154 - camelid:remove-getdefid, r=jyn514Matthias Krüger-2/+2
rustdoc: Remove `GetDefId` See the individual commit messages for details. r? `@jyn514`
2021-10-25Fix documentation header sizesJacob Hoffman-Andrews-4/+4
And add a rustdoc-gui test confirming various header sizes.
2021-10-25Fix clippy lints in librustdocGuillaume Gomez-6/+6
2021-10-23Rollup merge of #85833 - willcrichton:example-analyzer, r=jyn514Matthias Krüger-0/+1
Scrape code examples from examples/ directory for Rustdoc Adds support for the functionality described in https://github.com/rust-lang/rfcs/pull/3123 Matching changes to Cargo are here: https://github.com/rust-lang/cargo/pull/9525 Live demo here: https://willcrichton.net/example-analyzer/warp/trait.Filter.html#method.and
2021-10-22Rename `Type::def_id_full()` to `Type::def_id()`Noah Lev-2/+2
It should be preferred over `def_id_no_primitives()`, so it should have a shorter name. I also put it before `def_id_no_primitives()` so that it shows up first in the docs.
2021-10-22Replace `GetDefId` with inherent methodsNoah Lev-1/+1
Now that it's only implemented for `Type`, using inherent methods instead means that imports are no longer necessary. Also, `GetDefId` is only meant to be used with `Type`, so it shouldn't be a trait.
2021-10-18* Remove left margin on items declaration at the top of their documentation pageGuillaume Gomez-122/+153
* Rename "type-decl" into "item-decl" to reflect the change of usage
2021-10-08Add template for print_itemJacob Hoffman-Andrews-44/+63
Add print_item.html and the code in print_item.rs to use it.
2021-10-07Rollup merge of #89596 - GuillaumeGomez:implicit-doc-cfg, r=jyn514Guillaume Gomez-1/+1
Make cfg imply doc(cfg) This is a reopening of #79341, rebased and modified a bit (we made a lot of refactoring in rustdoc's types so they needed to be reflected in this PR as well): * `hidden_cfg` is now in the `Cache` instead of `DocContext` because `cfg` information isn't stored anymore on `clean::Attributes` type but instead computed on-demand, so we need this information in later parts of rustdoc. * I removed the `bool_to_options` feature (which makes the code a bit simpler to read for `SingleExt` trait implementation. * I updated the version for the feature. There is only one thing I couldn't figure out: [this comment](https://github.com/rust-lang/rust/pull/79341#discussion_r561855624) > I think I'll likely scrap the whole `SingleExt` extension trait as the diagnostics for 0 and >1 items should be different. How/why should they differ? EDIT: this part has been solved, the current code was fine, just needed a little simplification. cc `@Nemo157` r? `@jyn514` Original PR description: This is only active when the `doc_cfg` feature is active. The implicit cfg can be overridden via `#[doc(cfg(...))]`, so e.g. to hide a `#[cfg]` you can use something like: ```rust #[cfg(unix)] #[doc(cfg(all()))] pub struct Unix; ``` By adding `#![doc(cfg_hide(foobar))]` to the crate attributes the cfg `#[cfg(foobar)]` (and _only_ that _exact_ cfg) will not be implicitly treated as a `doc(cfg)` to render a message in the documentation.
2021-10-06Move highlighting logic from JS to RustWill Crichton-0/+1
Continue migrating JS functionality Cleanup Fix compile error Clean up the diff Set toggle font to sans-serif
2021-10-06Rollup merge of #89506 - yaymukund:docblock-headings, r=GuillaumeGomezManish Goregaokar-22/+22
librustdoc: Use correct heading levels. Closes #89309 This fixes the `<h#>` header tags throughout the docs to reflect a semantic hierarchy. - I ran a script to manually check that we don't have any files with multiple `<h1>` tags. - Also checked that we never incorrectly nest e.g. a `<h2>` under an `<h3>`. - I also spot-checked a bunch of pages (`trait.Read`, `enum.Ordering`, `primitive.isize`, `trait.Iterator`).