| Age | Commit message (Collapse) | Author | Lines |
|
|
|
|
|
|
|
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`
|
|
|
|
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.
|
|
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>
|
|
`search.js`
|
|
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`
|
|
|
|
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.
|
|
fixes https://github.com/rust-lang/rust/issues/138067
|
|
|
|
- It doesn't need to be cloneable.
- Some of the `Rc`s and `RefCell`s aren't doing anything.
- `after_krate` can consume `self`.
|
|
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````
|
|
|
|
|
|
rustdoc: cleanups relating to allocations
These commits generally clean up the code a bit and also reduce allocation rates a bit.
r? `@camelid`
|
|
|
|
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:

|
|
Co-authored-by: Guillaume Gomez <guillaume1.gomez@gmail.com>
|
|
Moving the visibility stuff into the `from_fn` avoids the `Cow` and
makes the code a little shorter and simpler.
|
|
- `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`.
|
|
|
|
|
|
Instead of a `Vec`, to avoid some allocations.
|
|
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.
|
|
Most of the methods returning `impl Display` have `print` in their name.
This commit renames a few that didn't follow that convention.
|
|
To avoids the early return and duplication of `Ok((url_parts, shortty,
fqp))`.
|
|
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).
|
|
This reverts part of #91948, going back to returning a
`UrlPartsBuilder`. It makes the code simpler, and also avoids some
allocations.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rustdoc: on mobile, make the sidebar full width and linewrap
this is because the mobile sidebar cannot be resized, unlike on desktop.
|
|
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```
|
|
fixes https://github.com/rust-lang/rust/issues/141092
|
|
|
|
|
|
This is a huge perf win for rustdoc on the `typenum` and `nalgebra`
benchmarks, because the `else` branch doesn't get hit much.
|
|
The comparison against `text` seems to be unnecessary.
|
|
|
|
|
|
|
|
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`
|
|
r=notriddle
rustdoc: Fix links with inline code in trait impl docs
Fixes #140857
|