about summary refs log tree commit diff
path: root/src/librustdoc/html
AgeCommit message (Collapse)AuthorLines
2025-06-19avoid intermediately collecting into vectorsYotam Ofek-8/+4
2025-06-19one less pathbuf allocationYotam Ofek-2/+2
2025-06-18`Result::expect` instead of `match` and `panic!`Yotam Ofek-6/+2
2025-06-17Rollup merge of #142618 - GuillaumeGomez:eslint-no-console, r=lolbinarycatJacob Pratt-0/+2
Lint about `console` calls in rustdoc JS As discussed [here](https://github.com/rust-lang/rust/pull/142100#discussion_r2151764395), this PR enforces that `console` is not used in rustdoc JS by default. cc `@lolbinarycat`
2025-06-17Lint about `console` calls in rustdoc JSGuillaume Gomez-0/+2
2025-06-16rustdoc: make srcIndex no longer a global variablebinarycat-28/+11
this is one-time initialization data, it can just be a function parameter. we also move the json parsing into createSrcSidebar to save a few bytes.
2025-06-16rustdoc: add ways of collapsing all impl blocksbinarycat-6/+22
either shift+click the Summary button, or use the `_` key. this collapses everything, including (inherent) impl blocks. no need for a special "expand all impl blocks" method, as impl blocks are expanded during regular "expand all". doing "expand all" -> "collapse all" will always result in only impl blocks being expaned. some of the html is split up a bit awkwardly to try to avoid introducing new whitespaces nodes, which could affect display. Co-authored-by: Guillaume Gomez <guillaume1.gomez@gmail.com>
2025-06-16Add comment to prevent having code other than `initSearch` at the end of ↵Guillaume Gomez-0/+4
`search.js`
2025-06-14Auto merge of #142335 - nnethercote:rustdoc-json-allocations, r=aDotInTheVoidbors-2/+2
rustdoc_json: reduce allocations These commits reduce the number of allocations done for rustdoc_json, mostly by avoiding unnecessary clones. Best reviewed one commit at a time. r? `@aDotInTheVoid`
2025-06-14Fix random failure when JS code is executed when the whole file was not read yetGuillaume Gomez-37/+37
2025-06-11Avoid more clones in rustdoc JSON output.Nicholas Nethercote-1/+1
By making `JsonRenderer::item` take `&clean::Item` instead of a `clean::Item`. This required also changing `FromClean` and `IntoJson` methods to take references, which required a lot of follow-on sigil wrangling that is mostly tedious.
2025-06-10rustdoc search: prefer stable items in search resultsbinarycat-3/+38
fixes https://github.com/rust-lang/rust/issues/138067
2025-06-10Give more information into extracted doctest informationGuillaume Gomez-1/+2
2025-06-10Simplify `JsonRenderer`.Nicholas Nethercote-1/+1
- It doesn't need to be cloneable. - Some of the `Rc`s and `RefCell`s aren't doing anything. - `after_krate` can consume `self`.
2025-06-07Rollup merge of #140560 - Urgau:test_attr-module-level, r=GuillaumeGomezGuillaume Gomez-1/+0
Allow `#![doc(test(attr(..)))]` everywhere This PR adds the ability to specify [`#![doc(test(attr(..)))]`](https://doc.rust-lang.org/nightly/rustdoc/write-documentation/the-doc-attribute.html#testattr) ~~at module level~~ everywhere in addition to allowing it at crate-root. This is motivated by a recent PR #140323 (by ````@tgross35)```` where we have to duplicate 2 attributes to every single `f16` and `f128` doctests, by allowing `#![doc(test(attr(..)))]` at module level (and everywhere else) we can omit them entirely and just have (in both module): ```rust #![doc(test(attr(feature(cfg_target_has_reliable_f16_f128))))] #![doc(test(attr(expect(internal_features))))] ``` Those new attributes are appended to the one found at crate-root or at a previous module. Those "global" attributes are compatible with merged doctests (they already were before). Given the small addition that this is, I'm proposing to insta-stabilize it, but I can feature-gate it if preferred. Best reviewed commit by commit. r? ````@GuillaumeGomez````
2025-06-05Support middle::ty assoc const eq predicates againLeón Orell Valerian Liehr-19/+22
2025-06-05Rename `should_show_cast` to `should_fully_qualify`León Orell Valerian Liehr-3/+3
2025-05-30Auto merge of #141573 - nnethercote:rustdoc-alloc-cleanups, r=camelidbors-132/+132
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-30Address review comments.Nicholas Nethercote-6/+6
2025-05-27Rollup merge of #141517 - ↵Trevor Gross-21/+30
lolbinarycat:rustdoc-doctest-tooltip-ignore-141092, r=notriddle rustdoc: use descriptive tooltip if doctest is conditionally ignored fixes https://github.com/rust-lang/rust/issues/141092 here's what it looks like now: ![screenshot](https://github.com/user-attachments/assets/71e679fe-8828-439d-a2ce-b9187ad3aeea)
2025-05-27scrape-examples.js: fix typoslolbinarycat-2/+2
Co-authored-by: Guillaume Gomez <guillaume1.gomez@gmail.com>
2025-05-27Streamline `visibility_print_with_space`.Nicholas Nethercote-41/+37
Moving the visibility stuff into the `from_fn` avoids the `Cow` and makes the code a little shorter and simpler.
2025-05-27Streamline `TypeAliasPart::get`.Nicholas Nethercote-17/+16
- `ret` only ever gets at most one entry, so it can be an `Option` instead of a `Vec`. - Which means we can use `filter_map` instead of `flat_map`. - Move `trait_` next to the `ret` assignment, which can only happen once. - No need for `impls` to be a `Vec`, it can remain an iterator. - Avoid `Result` when collecting `impls`.
2025-05-26rustdoc: refactor Tooltip rendering logicbinarycat-43/+21
2025-05-26Avoid some unnecessary cloning.Nicholas Nethercote-11/+10
2025-05-26Make `{Type,Path}::generics` return iterators.Nicholas Nethercote-5/+4
Instead of a `Vec`, to avoid some allocations.
2025-05-26Simplify `make_href`.Nicholas Nethercote-5/+5
It never fails, so it doesn't need to return `Result`. And the `ItemType` in the result is just a copy of the one passed in via the `shortty` arg, so it can also be removed.
2025-05-26Rename some methods.Nicholas Nethercote-25/+36
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-26Refactor the end of `generate_item_def_id_path`.Nicholas Nethercote-6/+6
To avoids the early return and duplication of `Ok((url_parts, shortty, fqp))`.
2025-05-26Simplify `make_href`.Nicholas Nethercote-3/+4
Currently it is passed an `fqp` slice which it calls `to_vec` on and returns. This is a bit odd. It's better to let the call site clone if necessary. (One call site does, one does not).
2025-05-26Avoid `Box` in `href_relative_parts`.Nicholas Nethercote-25/+20
This reverts part of #91948, going back to returning a `UrlPartsBuilder`. It makes the code simpler, and also avoids some allocations.
2025-05-25Update to new APIGuillaume Gomez-1/+2
2025-05-25Improve codeGuillaume Gomez-44/+44
2025-05-25Tweak attribute rendering depending on wether or not it is a type aliasGuillaume Gomez-18/+104
2025-05-25Rename the `document_*` argument/field into `is_type_alias`Guillaume Gomez-12/+12
2025-05-25Split `Item::attributes` method into threeGuillaume Gomez-2/+2
2025-05-25Unify rendering of type aliases without ADT itemsGuillaume Gomez-137/+138
2025-05-25Rename `clean::Enum::variants` method into `non_stripped_variants`Guillaume Gomez-2/+2
2025-05-25Rollup merge of #139831 - lolbinarycat:rustdoc-mobile-sidebar, r=GuillaumeGomezJacob Pratt-1/+4
rustdoc: on mobile, make the sidebar full width and linewrap this is because the mobile sidebar cannot be resized, unlike on desktop.
2025-05-24Rollup merge of #141487 - GuillaumeGomez:update-askama, r=notriddleGuillaume Gomez-1/+1
Update askama to `0.14.0` [Askama 0.14.0 release notes](https://github.com/askama-rs/askama/releases/tag/v0.14.0) Just one change needed for a filter in rustdoc. r? ```@notriddle```
2025-05-24rustdoc: use descriptive tooltip if doctest is conditionally ignoredbinarycat-10/+41
fixes https://github.com/rust-lang/rust/issues/141092
2025-05-24Update `askama` version to `0.14.0` in librustdocGuillaume Gomez-1/+1
2025-05-24Simplify things a little more.Nicholas Nethercote-6/+3
2025-05-24Move code inside the `else` in `TypeAliasPart::get`.Nicholas Nethercote-29/+33
This is a huge perf win for rustdoc on the `typenum` and `nalgebra` benchmarks, because the `else` branch doesn't get hit much.
2025-05-24Simplify the "is some" test in `TypeAliasPart::get`.Nicholas Nethercote-1/+1
The comparison against `text` seems to be unnecessary.
2025-05-22scrape-examples.js: add another nonnull() invokationbinarycat-1/+1
2025-05-22fix typobinarycat-4/+5
2025-05-22Collect and use `#![doc(test(attr(..)))]` at module level tooUrgau-1/+0
2025-05-22Auto merge of #140527 - GuillaumeGomez:doctest-main-fn, r=notriddlebors-1/+5
Emit a warning if the doctest `main` function will not be run Fixes #140310. I think we could try to go much further like adding a "link" (ie UI annotations) on the `main` function in the doctest. However that will require some more computation, not sure if it's worth it or not. Can still be done in a follow-up if we want it. For now, this PR does two things: 1. Pass the `DiagCtxt` to the doctest parser to emit the warning. 2. Correctly generate the `Span` to where the doctest is starting (I hope the way I did it isn't too bad either...). cc `@fmease` r? `@notriddle`
2025-05-22Rollup merge of #140868 - SpecificProtagonist:rustdoc-trait-impl-code-link, ↵Matthias Krüger-1/+3
r=notriddle rustdoc: Fix links with inline code in trait impl docs Fixes #140857