about summary refs log tree commit diff
path: root/src/librustdoc/html
AgeCommit message (Collapse)AuthorLines
2025-09-11Correctly handle literal search on pathsGuillaume Gomez-2/+4
2025-09-08mark `format_args_nl!` as `#[doc(hidden)]`cyrgani-1/+1
2025-09-04Auto merge of #145911 - notriddle:stringdex-tweak-3, r=GuillaumeGomezbors-161/+644
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-161/+644
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-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-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-31rustdoc-search: skip loading unneeded fnDataMichael Howell-12/+13
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-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-5/+26
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-24Auto merge of #137229 - GuillaumeGomez:expand-macro, r=lolbinarycatbors-61/+472
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-18/+14
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
2025-08-22Rollup merge of #145742 - ↵Jacob Pratt-43/+18
lolbinarycat:rustdoc-search-type-cleanup-continued, r=GuillaumeGomez rustdoc js: Even more typechecking improvments made another pass at eliminating typescript errors, this time mainly focused on adding fields to `window` that weren't declared before. r? `@notriddle`
2025-08-23Also support statements and patterns for macro expansionGuillaume Gomez-2/+18
2025-08-23Improve codeGuillaume Gomez-4/+2
2025-08-23Make macro expansion feature buttons accessibleGuillaume Gomez-10/+11
2025-08-23Do macro expansion at AST level rather than HIRGuillaume Gomez-147/+163
2025-08-23Clean up computation of macro expansion span and correctly handle spans open ↵Guillaume Gomez-28/+90
inside expansion spans
2025-08-23Go around firefox bugGuillaume Gomez-1/+7
2025-08-23Correctly handle multiple macro expansions on a same lineGuillaume Gomez-18/+49
2025-08-23Add new unstable `--generate-macro-expansion` rustdoc command line flagGuillaume Gomez-14/+23
2025-08-23Add support for macro expansion in rustdoc source code pagesGuillaume Gomez-63/+339
2025-08-22main.js: only call window.rustdocToggleSrcSidebar if it existsbinarycat-2/+1
2025-08-22typecheck: add nonnull around element known to existbinarycat-2/+1
2025-08-22typecheck tooltipBlurHandlerbinarycat-1/+3
2025-08-22typecheck window.CURRENT_TOOLTIP_ELEMENTbinarycat-32/+7
2025-08-21typecheck window.NOTABLE_TRAITSbinarycat-2/+2
2025-08-21typecheck window.rr_binarycat-2/+2
2025-08-21typecheck window.searchIndexbinarycat-2/+2
2025-08-21unbox raw pointers in type-based searchbinarycat-3/+6
2025-08-21add special formatting for displaying raw pointers in signaturesbinarycat-2/+22
2025-08-21rustdoc search: accept *mut T syntax for raw pointersbinarycat-30/+45
2025-08-21make primitive:pointer work in type-based search.binarycat-2/+2
2025-08-21Losslessly optimize PNG fileslumiscosity-0/+0
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-20Fix JS search scripts pathGuillaume Gomez-2/+2
2025-08-20Rollup merge of #140314 - lolbinarycat:rustdoc-js-scrape-examples-typecheck, ↵Jacob Pratt-11/+43
r=notriddle Rustdoc: typecheck scrape-examples.js more typechecking progress, this time we're mostly held back by the fact that `document.querySelectorAll` can't return nice types if its given a compound query (see the issue linked in a code comment). Additionally, it seems like the generated `data-locs` attribute has fields that are never used by anything? r? ```@notriddle```
2025-08-19Rollup merge of #145025 - lolbinarycat:ci-tidy-spellcheck, r=Kobzol许杰友 Jieyou Xu (Joe)-1/+1
run spellcheck as a tidy extra check in ci This is probably how it should've been done from the start. r? ``@Kobzol``
2025-08-16run spellcheck as a tidy extra check in cibinarycat-1/+1
2025-08-15rustdoc-search: search backend with partitioned suffix treeMichael Howell-4247/+8224
2025-08-15Rollup merge of #145389 - GuillaumeGomez:unstable-search, r=fmeaseStuart Cook-39/+2
[rustdoc] Revert "rustdoc search: prefer stable items in search results" Reverts https://github.com/rust-lang/rust/pull/141658 and reverts https://github.com/rust-lang/rust/pull/145349. Reopens https://github.com/rust-lang/rust/issues/138067. r? ```@fmease```
2025-08-14Revert "rustdoc search: prefer stable items in search results"Guillaume Gomez-36/+2
This reverts commit 1140e90074b0cbcfdea8535e4b51877e2838227e.
2025-08-14Revert "rustdoc: IndexItem::{stability -> is_unstable}"Guillaume Gomez-3/+8
This reverts commit 5e8ebd5ecd8546591a6707ac9e1a3b8a64c72f76.
2025-08-14Revert "rustdoc search: add performance note about searchIndexUnstable check"Guillaume Gomez-6/+0
This reverts commit fdbc8d08a63a3d34b7aebabb2f18a768462a98c4.
2025-08-14Revert "Correctly handle when there are no unstable items in the documented ↵Guillaume Gomez-3/+1
crate" This reverts commit cd79c7189db7b611f9199fd12ba56563afa18642.
2025-08-14rustdoc: Allow multiple references to a single footnoteTsukasa OI-9/+24
Multiple references to a single footnote is a part of GitHub Flavored Markdown syntax (although not explicitly documented as well as regular footnotes, it is implemented in GitHub's fork of CommonMark) and not prohibited by rustdoc. cf. <https://github.com/github/cmark-gfm/blob/587a12bb54d95ac37241377e6ddc93ea0e45439b/test/extensions.txt#L762-L780> However, using it makes multiple "sup" elements with the same "id" attribute, which is invalid per the HTML specification. Still, not only this is a valid GitHub Flavored Markdown syntax, this is helpful on certain cases and actually tested (accidentally) in tests/rustdoc/footnote-reference-in-footnote-def.rs. This commit keeps track of the number of references per footnote and gives unique ID to each reference. It also emits *all* back links from a footnote to its references as "↩" (return symbol) plus a numeric list in superscript. As a known limitation, it assumes that all references to a footnote are rendered (this is not always true if a dangling footnote has one or more references but considered a reasonable compromise). Also note that, this commit is designed so that no HTML changes will occur unless multiple references to a single footnote is actually used.