about summary refs log tree commit diff
path: root/src/librustdoc/html/render
AgeCommit message (Collapse)AuthorLines
2025-09-26Rollup merge of #147047 - notriddle:toolbar-index, r=GuillaumeGomezMatthias Krüger-3/+13
rustdoc: put the toolbar on the all item index
2025-09-25rustdoc: put the toolbar on the all item indexMichael Howell-3/+13
2025-09-25Rollup merge of #135771 - GuillaumeGomez:jump-to-def-perf, r=fmeaseMatthias Krüger-46/+78
[rustdoc] Add support for associated items in "jump to def" feature Fixes https://github.com/rust-lang/rust/issues/135485. r? ``@fmease``
2025-09-25Rollup merge of #116882 - fmease:rustdoc-generalized-priv-repr-heuristic, ↵Matthias Krüger-42/+146
r=rustdoc rustdoc: hide `#[repr]` if it isn't part of the public ABI > [!IMPORTANT] > Temporarily stacked on top of PR https://github.com/rust-lang/rust/pull/146527; only the last commit is relevant! Follow-up to rust-lang/rust#115439. Unblocks rust-lang/rust#116743, CC ``@dtolnay.`` Fixes rust-lang/rust#66401. Fixes rust-lang/rust#128364. Fixes rust-lang/rust#137440. Only display the representation `#[repr(REPR)]` (where `REPR` is not `Rust` or `transparent`) of a given type if none of its variants (incl. the synthetic variants of structs) are `#[doc(hidden)]` and all of its fields are public and not `#[doc(hidden)]` since it's likely not meant to be considered part of the public ABI otherwise. `--document-{private,hidden}-items` works as expected in this context, too. Moreover, we now also factor in the presence of `#[doc(hidden)]` when checking whether to show `repr(transparent)` or not.
2025-09-25rustdoc: hide `#[repr(...)]` if it isn't part of the public ABILeón Orell Valerian Liehr-21/+61
2025-09-25rustdoc: Fully escape link section and export nameLeón Orell Valerian Liehr-2/+2
Escape "special characters" (e.g., double quotes `"` and line breaks `\n`). Escape HTML. Lastly, add regression tests and clean up existing tests.
2025-09-25rustdoc: Slightly clean up attr renderingLeón Orell Valerian Liehr-97/+56
2025-09-21Port #[macro_export] to the new attribute parsing infrastructureJonathan Brouwer-10/+13
Co-authored-by: Anne Stijns <anstijns@gmail.com>
2025-09-17Remove ImplSubjectCameron Steffen-5/+5
2025-09-14rustdoc: Move HTML-specific attr rendering code into HTML rendering modLeón Orell Valerian Liehr-38/+143
These functions used to be shared with the JSON backend but nowadays they aren't.
2025-09-02squash fix `render_call_locations` panic when default span points at file ↵Janis-15/+37
outside of local_sources add test against crashing with --html-after-content file correctly add --html-after-content to env not args formatting fix for rustdoc-call-locations-after-content/rmake.rs Use local crate source file as default span in `render_call_locations` - avoids unwrapping the first file added to the source map as a local file in `href_from_span` move test to tests/rustdoc-gui, rename to scrape_examples_ice test link is correct use rustdocflags, rename path in example, track lock file factor out duplicate function calls use compile-flags to make sure the after.html file is actually included in the rustdoc call fix goml go-to path increment assert-count in sidebar-source-code.goml adjust crate-search width in search-result-display.goml renamed Bar in scrape_examples_ice test make crate name shorter ..
2025-08-30rustdoc-search: split function inverted index by input/outputMichael Howell-43/+212
With a patch applied to count the number of unifications, and running the query `Option<T>, (T -> U) -> Option<U>` before: performed unifyFunctionType on 17484 functions after: performed unifyFunctionType on 3055 functions
2025-08-28Create new `Item::is_fake_item` method as equivalent to check for ↵Guillaume Gomez-2/+2
`is_primitive`, `is_keyword` and `is_attribute` methods
2025-08-28Add new `doc(attribute = "...")` attributeGuillaume Gomez-4/+12
2025-08-24Auto merge of #137229 - GuillaumeGomez:expand-macro, r=lolbinarycatbors-12/+18
Add support for macro expansion in rustdoc source code pages This is what it looks like: ![Screenshot From 2025-02-18 18-08-51](https://github.com/user-attachments/assets/ce2b3806-6218-47df-94bf-e9e9ed40cd41) ![image](https://github.com/user-attachments/assets/891042db-8632-4dba-9343-e28570c058fe) You can test it [here](https://rustdoc.crud.net/imperio/macro-expansion/src/lib/lib.rs.html). In this case, I also enabled the `--generate-link-to-definition` to show that both options work well together. Note: <del>There is a bug currently in firefox where the line numbers are not displayed correctly if they're inside the "macro expansion" span: https://bugzilla.mozilla.org/show_bug.cgi?id=1949948<del> Found a workaround around this bug. r? `@notriddle`
2025-08-24rustdoc: render attributes in Field and Variants sectionsKarol Zwolak-3/+21
2025-08-23Rollup merge of #145782 - ↵Samuel Tardieu-69/+68
karolzwolak:rustdoc-consistent-attributes-rendering, r=GuillaumeGomez rustdoc: make attributes render consistently While working on rust-lang/rust#132304, I discovered that even standard attributes aren't consistently rendered. For some constructs/fields, attributes were missing entirely, and the attributes were only sometimes wrapped in a code-attribute divs so they appear greyed out. In short this PR: * makes attributes render inside code elements and inside divs with class `code-attribute` * renders attributes for macros, associated constants, and struct/union fields Attributes in `Fields` and `Variants` sections are still not rendered (see struct and enum screenshots), because I wasn't sure we want that. [Compirison of tests/rustdoc/attributes.rs](https://github.com/karolzwolak/rust/blob/90aa25a1c5dbae1e94099b1a2015dfb83783dbe0/tests/rustdoc/attributes.rs) Before (left) / after (right): <img width="279" height="97" alt="image" src="https://github.com/user-attachments/assets/baca4b75-f809-4a76-8ac1-e3aa6389aad4" /> <img width="363" height="112" alt="image" src="https://github.com/user-attachments/assets/14970fb0-6fe5-474f-983e-5a95e16175c5" /> <img width="368" height="492" alt="image" src="https://github.com/user-attachments/assets/f9a25583-10e3-49c7-961b-34f3587b552e" /> <img width="415" height="515" alt="image" src="https://github.com/user-attachments/assets/f2fe4aa0-c731-4f2f-a3c2-04e524a858d1" /> <img width="383" height="483" alt="image" src="https://github.com/user-attachments/assets/bccc1b6e-f236-4948-8557-f9b25cad8a07" /> <img width="402" height="528" alt="image" src="https://github.com/user-attachments/assets/2cea9250-37e1-439e-8010-0603905d0f52" /> <img width="372" height="485" alt="image" src="https://github.com/user-attachments/assets/cd49bc0a-90e1-4d08-af0f-084c42af1834" /> <img width="406" height="542" alt="image" src="https://github.com/user-attachments/assets/67fb4ac7-746b-4e20-9c80-97702a71def8" /> <img width="357" height="131" alt="image" src="https://github.com/user-attachments/assets/42769532-1e4d-486d-bdca-6ecc409554b9" /> <img width="366" height="161" alt="image" src="https://github.com/user-attachments/assets/0b4d01d4-dd8e-4467-8cfc-ad58200ba0d7" /> <img width="291" height="65" alt="image" src="https://github.com/user-attachments/assets/43f61335-8eff-491b-a297-1953d17bbfc0" /> <img width="259" height="57" alt="image" src="https://github.com/user-attachments/assets/598618a3-e52f-4a4e-b790-2c8d5f1b4c77" /> r? ``@GuillaumeGomez``
2025-08-23rustdoc: make attributes render consistentlyKarol Zwolak-69/+68
* 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-23Do macro expansion at AST level rather than HIRGuillaume Gomez-146/+20
2025-08-23Clean up computation of macro expansion span and correctly handle spans open ↵Guillaume Gomez-11/+32
inside expansion spans
2025-08-23Add new unstable `--generate-macro-expansion` rustdoc command line flagGuillaume Gomez-5/+7
2025-08-23Add support for macro expansion in rustdoc source code pagesGuillaume Gomez-7/+116
2025-08-21unbox raw pointers in type-based searchbinarycat-3/+6
2025-08-21make primitive:pointer work in type-based search.binarycat-2/+2
2025-08-15rustdoc-search: search backend with partitioned suffix treeMichael Howell-923/+1789
2025-08-14Revert "rustdoc search: prefer stable items in search results"Guillaume Gomez-12/+0
This reverts commit 1140e90074b0cbcfdea8535e4b51877e2838227e.
2025-08-14Revert "rustdoc: IndexItem::{stability -> is_unstable}"Guillaume Gomez-3/+8
This reverts commit 5e8ebd5ecd8546591a6707ac9e1a3b8a64c72f76.
2025-08-10rustdoc: Use `discr`s `Display` impl to render the value with the correct ↵Eval EXEC-5/+3
signedness
2025-08-10Ignore impl associated types in jump to def featureGuillaume Gomez-1/+7
2025-08-10Fix panic if an item does not have a bodyGuillaume Gomez-10/+22
2025-08-10Update to last rustc_hir Visitor changesGuillaume Gomez-6/+3
2025-08-10Better handling of paths in link to def featureGuillaume Gomez-27/+43
2025-08-10Add support for trait associated itemsGuillaume Gomez-30/+31
2025-08-09Rollup merge of #141658 - lolbinarycat:rustdoc-search-stability-rank-138067, ↵Stuart Cook-0/+7
r=GuillaumeGomez rustdoc search: prefer stable items in search results fixes https://github.com/rust-lang/rust/issues/138067 this does add a new field to the search index, but since we're only listing unstable items instead of adding a boolean flag to every item, it should only increase the search index size of sysroot crates, since those are the only ones using the `staged_api` feature, at least as far as the rust project is concerned.
2025-08-08rustdoc: IndexItem::{stability -> is_unstable}binarycat-10/+4
2025-07-31remove rustc_attr_data_structuresJana Dönszelmann-4/+2
2025-07-22rustdoc: avoid allocating a temp String for aliases in search indexbinarycat-3/+16
2025-07-20Rollup merge of #143988 - GuillaumeGomez:alias-inexact, r=lolbinarycatMatthias Krüger-1/+1
[rustdoc] Make aliases search support partial matching Fixes rust-lang/rust#140782. To make this work, I moved aliases into the `searchIndex` like any other item. It links to the "original" item with a new `original` field. No so great part is that we need to have some fields like `bitIndex` to be set on the alias to make the description load to work but I consider it minor enough to be ok. This PR voluntarily doesn't handle de-prioritization of aliases as ```@lolbinarycat``` wished to work on this so I'll leave them this part. :wink: cc ```@lolbinarycat```
2025-07-19Fix clippy lints in librustdocGuillaume Gomez-112/+98
2025-07-17Include ErrorGuaranteed in StableSince::Err.Camille GILLOT-1/+1
2025-07-17Improve path segment joining.Nicholas Nethercote-19/+21
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-16Make aliases search support partial matchingGuillaume Gomez-1/+1
2025-07-15rustdoc-json: Structured attributesAlona Enraght-Moony-5/+4
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-07-13update issue number for `const_trait_impl`Deadbeef-2/+2
2025-07-08Auto merge of #142869 - nnethercote:join_path-mini, r=camelidbors-2/+2
Use `join_with_double_colon` in `write_shared.rs`. For consistency. Also, it's faster because `join_with_double_colon` does a better job estimating the allocation size than `join` from `itertools`. r? `@camelid`
2025-07-03Auto merge of #143363 - jdonszelmann:rollup-7cv1kql, r=jdonszelmannbors-2/+2
Rollup of 6 pull requests Successful merges: - rust-lang/rust#134006 (setup typos check in CI) - rust-lang/rust#142876 (Port `#[target_feature]` to new attribute parsing infrastructure) - rust-lang/rust#143038 (avoid suggesting traits from private dependencies) - rust-lang/rust#143083 (Fix rustdoc not correctly showing attributes on re-exports) - rust-lang/rust#143283 (document optional jobs) - rust-lang/rust#143329 (minicore: use core's `diagnostic::on_unimplemented` messages) Failed merges: - rust-lang/rust#143237 (Port `#[no_implicit_prelude]` to the new attribute parsing infrastructure) r? `@ghost` `@rustbot` modify labels: rollup
2025-07-03setup CI and tidy to use typos for spellchecking and fix few typosklensy-2/+2
2025-06-29Lazy-ify some markdown renderingYotam Ofek-19/+16
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]