about summary refs log tree commit diff
path: root/src/librustdoc
AgeCommit message (Collapse)AuthorLines
2025-09-12Don't store defaultness for inherent impl itemsCameron Steffen-2/+5
2025-09-12Split AssocContainer::{InherentImpl,TraitImpl}Cameron Steffen-29/+24
2025-09-12Rename AssocItemContainer -> AssocContainerCameron Steffen-14/+14
2025-09-12Rollup merge of #146448 - GuillaumeGomez:fix-literal-search-paths, ↵Stuart Cook-2/+4
r=lolbinarycat [rustdoc] Correctly handle literal search on paths Fixes https://github.com/rust-lang/rust/issues/146129. cc ```@notriddle``` r? ```@lolbinarycat```
2025-09-12Rollup merge of #146413 - GuillaumeGomez:rustdoc-bare-urls, r=lolbinarycatStuart Cook-18/+39
Improve suggestion in case a bare URL is surrounded by brackets Fixes https://github.com/rust-lang/rust/issues/146162. With this change, output looks like this: ``` | 1 | //! [https://github.com] | ^^^^^^^^^^^^^^^^^^^^ help: use an automatic link instead: `<https://github.com>` | = note: bare URLs are not automatically turned into clickable links = note: `#[warn(rustdoc::bare_urls)]` on by default ``` cc ```@fmease``` r? ```@lolbinarycat```
2025-09-11Correctly handle literal search on pathsGuillaume Gomez-2/+4
2025-09-10Rollup merge of #146340 - fmease:frontmatter-containment, r=fee1-dead,UrgauMatthias Krüger-16/+24
Strip frontmatter in fewer places * Stop stripping frontmatter in `proc_macro::Literal::from_str` (RUST-146132) * Stop stripping frontmatter in expr-ctxt (but not item-ctxt!) `include`s (RUST-145945) * Stop stripping shebang (!) in `proc_macro::Literal::from_str` * Not a breaking change because it did compare spans already to ensure there wasn't extra whitespace or comments (`Literal::from_str("#!\n0")` already yields `Err(_)` thankfully!) * Stop stripping frontmatter+shebang inside some rustdoc code where it doesn't make any observable difference (see self review comments) * (Stop stripping frontmatter+shebang inside internal test code) Fixes https://github.com/rust-lang/rust/issues/145945. Fixes https://github.com/rust-lang/rust/issues/146132. r? fee1-dead
2025-09-10Simplify code for `find_raw_urls`Guillaume Gomez-17/+11
2025-09-10Improve suggestion in case a bare URL is surrounded by bracketsGuillaume Gomez-13/+40
2025-09-09Strip frontmatter in fewer placesLeón Orell Valerian Liehr-16/+24
2025-09-08mark `format_args_nl!` as `#[doc(hidden)]`cyrgani-2/+1
2025-09-04Auto merge of #145911 - notriddle:stringdex-tweak-3, r=GuillaumeGomezbors-162/+645
rustdoc-search: yet another stringdex optimization attempt This one's uses a different tactic. It shouldn't significantly increase the amount of downloaded index data, but still reduces the amount of disk usage. This one works by changing the suffix-only node representation to omit some data that's needed for checking. Since those nodes make up the bulk of the tree, it reduces the data they store, but also requires validating the match by fetching the name itself (but the names list is pretty small, and when I tried it with wordnet "indexing" it was about the same). r? `@GuillaumeGomez`
2025-09-03rustdoc-search: yet another stringdex optimization attemptMichael Howell-162/+645
This one's uses a different tactic. It shouldn't significantly increase the amount of downloaded index data, but still reduces the amount of disk usage. This one works by changing the suffix-only node representation to omit some data that's needed for checking. Since those nodes make up the bulk of the tree, it reduces the data they store, but also requires validating the match by fetching the name itself (but the names list is pretty small, and when I tried it with wordnet "indexing" it was about the same).
2025-09-04Rollup merge of #146161 - GuillaumeGomez:loaded-paths-scraped-examples, ↵Stuart Cook-6/+4
r=lolbinarycat [rustdoc] Uncomment code to add scraped rustdoc examples in loaded paths Since the bug was fixed in https://github.com/rust-lang/rust/pull/146091, we can now uncomment the code. :) r? lolbinarycat
2025-09-04Rollup merge of #146150 - weihanglo:rustdoc-emit, r=aDotInTheVoidStuart Cook-2/+9
fix(rustdoc): match rustc `--emit` precedence Resolves rust-lang/rust#141664 This changes rustdoc's `--emit` to allow only one instance of each type, regardless of the actual data that `--emit` carries. This matches rustc's `--emit` behavior. As of the writing, only `dep-info` emit type carries extra data.
2025-09-03Uncomment code to add scraped rustdoc examples in loaded pathsGuillaume Gomez-6/+4
2025-09-03fix(rustdoc): match rustc `--emit` precedenceWeihang Lo-2/+9
Change rustdoc's `--emit` to allow only one instance of each type, regardless of the actual data that `--emit` carries. This matches rustc's `--emit` behavior. As of the writing, only `dep-info` emit type carries extra data. See <https://github.com/rust-lang/rust/issues/141664>
2025-09-02Rollup merge of #146117 - GuillaumeGomez:fix-search-index-generation, ↵Guillaume Gomez-55/+41
r=notriddle Fix search index generation Fixes this issue: ``` error: couldn't generate documentation: failed to read column from disk: data consumer error: missing field `unknown number` at line 1 column 8 | = note: failed to create or modify "build/x86_64-unknown-linux-gnu/test/rustdoc-gui/doc/search.index/entry/": failed to read column from disk: data consumer error: missing field `unknown number` at line 1 column 8 warning: `theme_css` (lib doc) generated 1 warning error: could not document `theme_css` ``` The problem was that a conversion was forgotten for the `ItemType` enum. Thanks a lot to `@janis-bhm!` r? `@lolbinarycat`
2025-09-02Rollup merge of #146102 - fmease:rm-dead-eff-code-iii, r=fee1-deadGuillaume Gomez-6/+4
Remove dead code stemming from an old effects desugaring CC https://github.com/rust-lang/rust/pull/132374, https://github.com/rust-lang/rust/pull/133443. r? fee1-dead
2025-09-02Rollup merge of #146091 - janis-bhm:rustdoc-default-span-with-simple-test, ↵Guillaume Gomez-15/+37
r=GuillaumeGomez fix rustdoc `render_call_locations` panicking because of default span `DUMMY_SP` pointing at non local-source file fixes https://github.com/rust-lang/rust/issues/144752 related to/builds on https://github.com/rust-lang/rust/pull/145008 bevy still crashes in the same way as rust-lang/rust#144752 when building docs on nightly, and from what I can tell the cause seems to be the following (copied from zulip [#t-rustdoc > docs on nightly with example scrapes crash](https://rust-lang.zulipchat.com/#narrow/channel/266220-t-rustdoc/topic/docs.20on.20nightly.20with.20example.20scrapes.20crash)): > render_call_locations tries to [find](https://github.com/rust-lang/rust/blob/84a17470220e7adf249b18d7c0178dfbede89462/src/librustdoc/html/render/mod.rs#L2816) the source span of a call to add as an example, but the example files are never actually in the source map from what I can tell, and so it falls back to the default span, which points at the first file in the source map. > Now, the issue that guillaume mentions [here](https://github.com/rust-lang/rust/pull/145008) adds new files to the source map in order to get them into the dep info, and that leads to some files, namely docs-rs/trait-tags.html in the case of bevy because it's added with --html-after-content, being added before any source files, so then the default span points at them, and when href_from_span tries to find the [source file](https://github.com/rust-lang/rust/blob/84a17470220e7adf249b18d7c0178dfbede89462/src/librustdoc/html/render/context.rs#L368) corresponding to the span, the file doesn't belong to local_sources, and it short circuits. > This can be fixed by just not using DUMMY_SP as the default span and calculating, for example, the crates root source file as the span, because I'm not entirely sure what the href from that span is actually used for; it's not what links to the example in the end. > I think the proper way of fixing this would be to make sure the example files are part of the local_sources or at least the source map, but I don't know nearly enough about rust internals to be able to figure out how to fix that. I've included a test that's mostly copied from rust-lang/rust#145008's test with the addition of `--html-after-content after.html` in the `RUSTDOCFLAGS`, which panics on master in conjunction with the `-Zrustdoc-scrape-examples` cargo flag. cc `@GuillaumeGomez`
2025-09-02Rollup merge of #146070 - notriddle:skip-loading-function-data, r=GuillaumeGomezGuillaume Gomez-12/+13
rustdoc-search: skip loading unneeded fnData Fixes rust-lang/rust#146063 (probably) Based on the test I ran, it seems like most of the CPU time is being spent loading function signature data. This PR should avoid that. https://notriddle.com/rustdoc-html-demo-12/skip-loading-function-data/doc/std/index.html
2025-09-02Make it impossible to forget a conversion for the rustdoc `ItemType` enumGuillaume Gomez-55/+40
2025-09-02Fix `unknown number` error when generating search indexGuillaume Gomez-2/+3
2025-09-02Revert introduction of `[workspace.dependencies]`.Nicholas Nethercote-5/+5
This was done in #145740 and #145947. It is causing problems for people using r-a on anything that uses the rustc-dev rustup package, e.g. Miri, clippy. This repository has lots of submodules and subtrees and various different projects are carved out of pieces of it. It seems like `[workspace.dependencies]` will just be more trouble than it's worth.
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-09-01Remove dead code stemming from an old effects desugaringLeón Orell Valerian Liehr-6/+4
2025-08-31rustdoc-search: skip loading unneeded fnDataMichael Howell-12/+13
2025-08-31Auto merge of #146038 - notriddle:polarity, r=GuillaumeGomezbors-72/+267
rustdoc-search: split function inverted index by input/output Fixes rust-lang/rust#146015 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 preview: https://notriddle.com/rustdoc-html-demo-12/polarity/doc/std/index.html https://notriddle.com/rustdoc-html-demo-12/polarity/compiler-doc/rustc_hir/index.html
2025-08-30rustdoc-search: improve concurrency at type searchMichael Howell-9/+15
2025-08-30rustdoc-search: split function inverted index by input/outputMichael Howell-67/+256
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-29Rollup merge of #146000 - GuillaumeGomez:rustdoc-error-improvement, r=notriddleTrevor Gross-1/+3
Improve librustdoc error when a file creation/modification failed The message before looks like this: ``` failed to create or modify "/build/x86_64-unknown-linux-gnu/test/rustdoc-gui/doc/search.index/entry/" ``` And with this change it looks like this: ``` failed to create or modify "/build/x86_64-unknown-linux-gnu/test/rustdoc-gui/doc/search.index/entry/": failed to read column from disk: data consumer error: missing field `unknown number` at line 1 column 8 ``` r? ``````@lolbinarycat``````
2025-08-29Rollup merge of #145756 - okaneco:stabilize_char_boundary, r=scottmcmTrevor Gross-1/+1
str: Stabilize `round_char_boundary` feature Closes https://github.com/rust-lang/rust/issues/93743 FCP completed https://github.com/rust-lang/rust/issues/93743#issuecomment-3168382171
2025-08-29Improve librustdoc error when a file creation/modification failedGuillaume Gomez-1/+3
2025-08-29Rollup merge of #145947 - nnethercote:workspace-members-2, r=KobzolStuart Cook-3/+3
Add more to the `[workspace.dependencies]` section in the top-level `Cargo.toml` Following on from rust-lang/rust#145740. r? `@Kobzol`
2025-08-28Create new `Item::is_fake_item` method as equivalent to check for ↵Guillaume Gomez-2/+13
`is_primitive`, `is_keyword` and `is_attribute` methods
2025-08-28Add new `doc(attribute = "...")` attributeGuillaume Gomez-23/+86
2025-08-28Add `indexmap` to `[workspace.dependencies]`.Nicholas Nethercote-1/+1
2025-08-28Add `tempfile` to `[workspace.dependencies]`.Nicholas Nethercote-1/+1
2025-08-28Add `serde_json` to `[workspace.dependencies]`.Nicholas Nethercote-1/+1
2025-08-27Auto merge of #145851 - lolbinarycat:rustdoc-optimize, r=GuillaumeGomezbors-17/+17
rustdoc: a few micro-optimizations targeted at build_impl Unsure if these will be anything substantial, but the first one at least should git rid of quite a few branches, second one unsure if it's worth it. r? `@GuillaumeGomez`
2025-08-27Add `itertools` to `[workspace.dependencies]`.Nicholas Nethercote-1/+1
2025-08-27Add `tracing` to `[workspace.dependencies]`.Nicholas Nethercote-1/+1
2025-08-26Rollup merge of #145596 - lumiscosity:optimize-png-files, r=davidtwcoGuillaume Gomez-0/+0
Losslessly optimize PNG files Losslessly optimizes all of the PNG files in the repo. Done with: ``` oxipng -o max -a -s oxipng -o max --zopfli -a -s ```
2025-08-26Rollup merge of #145535 - lolbinarycat:rustdoc-invalid_html_tags-svg-145529, ↵Stuart Cook-169/+381
r=GuillaumeGomez make rustdoc::invalid_html_tags more robust best reviewed a commit at a time. I kept finding more edge case so I ended up having to make quite significant changes to the parser in order to make it preserve state across events and handle multiline attributes correctly. fixes rust-lang/rust#145529
2025-08-25rustdoc(opt): build_impl: check document_private earlierbinarycat-17/+17
2025-08-24Auto merge of #137229 - GuillaumeGomez:expand-macro, r=lolbinarycatbors-92/+557
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-4/+22
2025-08-23Rollup merge of #145782 - ↵Samuel Tardieu-70/+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-23Improve code and add test with macro coming from another file from the same ↵Guillaume Gomez-35/+23
crate
2025-08-23rustdoc: make attributes render consistentlyKarol Zwolak-70/+68
* make attributes render inside code elements and inside divs with class `code-attribute` * render attributes for macros, associated constants, and struct/union fields