about summary refs log tree commit diff
path: root/src/librustdoc/html/render/print_item.rs
AgeCommit message (Collapse)AuthorLines
2025-09-25rustdoc: Slightly clean up attr renderingLeón Orell Valerian Liehr-4/+4
2025-08-28Create new `Item::is_fake_item` method as equivalent to check for ↵Guillaume Gomez-1/+1
`is_primitive`, `is_keyword` and `is_attribute` methods
2025-08-28Add new `doc(attribute = "...")` attributeGuillaume Gomez-3/+6
2025-08-24rustdoc: render attributes in Field and Variants sectionsKarol Zwolak-3/+21
2025-08-23rustdoc: make attributes render consistentlyKarol Zwolak-51/+49
* make attributes render inside code elements and inside divs with class `code-attribute` * render attributes for macros, associated constants, and struct/union fields
2025-08-15rustdoc-search: search backend with partitioned suffix treeMichael Howell-0/+1
2025-08-10rustdoc: Use `discr`s `Display` impl to render the value with the correct ↵Eval EXEC-5/+3
signedness
2025-07-19Fix clippy lints in librustdocGuillaume Gomez-42/+38
2025-07-17Improve path segment joining.Nicholas Nethercote-4/+5
There are many places that join path segments with `::` to produce a string. A lot of these use `join("::")`. Many in rustdoc use `join_with_double_colon`, and a few use `.joined("..")`. One in Clippy uses `itertools::join`. A couple of them look for `kw::PathRoot` in the first segment, which can be important. This commit introduces `rustc_ast::join_path_{syms,ident}` to do the joining for everyone. `rustc_ast` is as good a location for these as any, being the earliest-running of the several crates with a `Path` type. Two functions are needed because `Ident` printing is more complex than simple `Symbol` printing. The commit also removes `join_with_double_colon`, and `estimate_item_path_byte_length` with it. There are still a handful of places that join strings with "::" that are unchanged. They are not that important: some of them are in tests, and some of them first split a path around "::" and then rejoin with "::". This fixes one test case where `{{root}}` shows up in an error message.
2025-07-15rustdoc-json: Structured attributesAlona Enraght-Moony-2/+1
Implements https://www.github.com/rust-lang/rust/issues/141358. This has 2 primary benefits: 1. For rustdoc-json consumers, they no longer need to parse strings of attributes, but it's there in a structured and normalized way. 2. For rustc contributors, the output of HIR pretty printing is no longer a versioned thing in the output. People can work on https://github.com/rust-lang/rust/issues/131229 without needing to bump `FORMAT_VERSION`. (Over time, as the attribute refractor continues, I expect we'll add new things to `rustdoc_json_types::Attribute`. But this can be done separately to the rustc changes).
2025-06-28Rollup merge of #142987 - lolbinarycat:rustdoc-non_exhaustive-enum-v-142599, ↵Matthias Krüger-0/+1
r=GuillaumeGomez rustdoc: show attributes on enum variants mostly for #[non_exhaustive] unsure if there's any attributes we should take care to *not* include, it could use `render_code_attribute` and `is_non_exhaustive` instead, if that is a concern. fixes rust-lang/rust#142599
2025-06-26rustdoc: show attributes on enum variantsbinarycat-0/+1
mostly for #[non_exhaustive]
2025-06-24rustdoc: Don't mark `#[target_feature]` functions as ⚠Alona Enraght-Moony-1/+2
Closes https://www.github.com/rust-lang/rust/issues/142952
2025-06-22Port `#[no_mangle]` to new attribute parsing infrastructureJonathan Brouwer-1/+1
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-05-30Auto merge of #141573 - nnethercote:rustdoc-alloc-cleanups, r=camelidbors-15/+26
rustdoc: cleanups relating to allocations These commits generally clean up the code a bit and also reduce allocation rates a bit. r? `@camelid`
2025-05-26Avoid some unnecessary cloning.Nicholas Nethercote-2/+2
2025-05-26Rename some methods.Nicholas Nethercote-13/+24
Most of the methods returning `impl Display` have `print` in their name. This commit renames a few that didn't follow that convention.
2025-05-25Update to new APIGuillaume Gomez-0/+1
2025-05-25Improve codeGuillaume Gomez-37/+39
2025-05-25Tweak attribute rendering depending on wether or not it is a type aliasGuillaume Gomez-17/+83
2025-05-25Rename the `document_*` argument/field into `is_type_alias`Guillaume Gomez-11/+11
2025-05-25Unify rendering of type aliases without ADT itemsGuillaume Gomez-134/+134
2025-05-25Rename `clean::Enum::variants` method into `non_stripped_variants`Guillaume Gomez-1/+1
2025-04-17Rollup merge of #139943 - fmease:rustdoc-ixcre-trait-aliases, r=GuillaumeGomezMatthias Krüger-2/+3
rustdoc: Support inlined cross-crate re-exported trait aliases Previously we'd just drop them. As a result of this PR, [`core::ptr::Thin`](https://doc.rust-lang.org/nightly/core/ptr/traitalias.Thin.html) will be admitted into the `std` façade! Also, render the where clause *after* the bounds / the `=`, not before them, as it should be. r? rustdoc
2025-04-17Support inlined cross-crate re-exported trait aliasesLeón Orell Valerian Liehr-2/+3
2025-04-15Avoid using `kw::Empty` when comparing names.Nicholas Nethercote-4/+7
2025-04-06Update rinja version in `generate-copyright`Guillaume Gomez-2/+2
2025-04-03Update to new rinja version (askama)Guillaume Gomez-5/+5
2025-03-06Manual, post-`clippy --fix` cleanupsYotam Ofek-9/+7
2025-03-06`x clippy src/librustdoc --fix`Yotam Ofek-4/+2
2025-03-04Adapt `librustdoc` to 2024 edition lifetieme capture rulesYotam Ofek-207/+120
Get rid of the `Captures` hack
2025-02-23return `impl fmt::Display` in more places instead of writing to stringsYotam Ofek-1528/+1699
2025-02-17librustdoc: more usages of `Joined::joined`Yotam Ofek-16/+12
2025-02-14librustdoc: make `item_path` formatting lazyYotam Ofek-5/+5
2025-02-14librustdoc: make `notable_traits_button` formatting lazyYotam Ofek-2/+1
2025-02-14librustdoc: make `bounds` formatting lazyYotam Ofek-23/+22
2025-02-14librustdoc: create `MaybeDisplay` helper for `Option<T: Display>` typesYotam Ofek-1/+1
2025-02-12Nuke `Buffer` abstraction from `librustdoc` 💣Yotam Ofek-257/+347
2025-02-05Auto merge of #136244 - yotamofek:pr/rustdoc-join-iter, r=GuillaumeGomezbors-31/+27
librustdoc: create a helper for separating elements of an iterator instead of implementing it multiple times This implements something similar to [`Itertools::format`](https://docs.rs/itertools/latest/itertools/trait.Itertools.html#method.format), but on `Fn`s returning iterators instead of directly on iterators, to allow implementing `Display` without the use of a `Cell` (to handle the possibility of `fmt` being called multiple times while receiving `&self`). ~This is WIP, I just want to get a perf run first to see if the regression I saw in #135494 is fixed~ This was originally part of #135494 , but originally caused a perf regression that was since fixed: https://github.com/rust-lang/rust/blob/7d5ae1863aa66847a4edf8d2ef9420717df65c5d/src/librustdoc/html/format.rs#L507
2025-02-04librustdoc: create a helper for separating elements of an iterator instead ↵Yotam Ofek-31/+27
of implementing it multiple times
2025-01-30fix(rustdoc): always use a channel when linking to doc.rust-lang.orgAlexis (Poliorcetics) Bourget-1/+1
2025-01-23Auto merge of #135494 - yotamofek:rustdoc-fmt-from_fn, r=fmeasebors-13/+13
Refactor `fmt::Display` impls in rustdoc This PR does a couple of things, with the intention of cleaning up and streamlining some of the `fmt::Display` impls in rustdoc: 1. Use the unstable [`fmt::from_fn`](https://github.com/rust-lang/rust/issues/117729) instead of open-coding it. 2. ~~Replace bespoke implementations of `Itertools::format` with the method itself.~~ 4. Some more minor cleanups - DRY, remove unnecessary calls to `Symbol::as_str()`, replace some `format!()` calls with lazier options The changes are mostly cosmetic but some of them might have a slight positive effect on performance.
2025-01-22rustdoc: use std's (unstable) `fmt::from_fn` instead of open-coding itYotam Ofek-13/+13
2025-01-22rustdoc: Finalize dyn compatibility renamingLeón Orell Valerian Liehr-2/+1
2025-01-18Remove more CSS classesGuillaume Gomez-17/+8
2025-01-17Handle reexports items list a bit differently since they cannot have ↵Guillaume Gomez-7/+5
documentation
2025-01-17Replace ul/li list with dl/dd/dt elementsGuillaume Gomez-19/+11
2025-01-14Add hir::HeaderSafety to make follow up commits simplerOli Scherer-1/+1
2024-12-25Improve rustdoc codeGuillaume Gomez-1/+1
2024-12-20Rollup merge of #134321 - dtolnay:docassocconst, r=fmeaseJacob Pratt-2/+4
Hide `= _` as associated constant value inside impl blocks Closes #134320. ### Before: <img src="https://github.com/user-attachments/assets/19d28811-45d2-4563-9726-f40c6af411c6" width="300">&nbsp;<img src="https://github.com/user-attachments/assets/1ecf8764-97ce-47f0-87fa-3b174d2fc578" width="300"> ### After: <img src="https://github.com/user-attachments/assets/6408c4ca-b1c4-42e4-884b-248833a4865f" width="300">&nbsp;<img src="https://github.com/user-attachments/assets/df2f6981-16f6-409f-8abb-73c0a4a71d6b" width="300"> r? `@fmease`