| Age | Commit message (Collapse) | Author | Lines |
|
Migrate top doc and non-exhaustive toggles to details tag
Fixes #83332.
r? `@jsha`
|
|
|
|
Unify rustc and rustdoc parsing of `cfg()`
This extracts a new `parse_cfg` function that's used between both.
- Treat `#[doc(cfg(x), cfg(y))]` the same as `#[doc(cfg(x)]
#[doc(cfg(y))]`. Previously it would be completely ignored.
- Treat `#[doc(inline, cfg(x))]` the same as `#[doc(inline)]
#[doc(cfg(x))]`. Previously, the cfg would be ignored.
- Pass the cfg predicate through to rustc_expand to be validated
Technically this is a breaking change, but doc_cfg is still nightly so I don't think it matters.
Fixes https://github.com/rust-lang/rust/issues/84437.
r? `````````@petrochenkov`````````
|
|
|
|
metadata
|
|
|
|
This extracts a new `parse_cfg` function that's used between both.
- Treat `#[doc(cfg(x), cfg(y))]` the same as `#[doc(cfg(x)]
#[doc(cfg(y))]`. Previously it would be completely ignored.
- Treat `#[doc(inline, cfg(x))]` the same as `#[doc(inline)]
#[doc(cfg(x))]`. Previously, the cfg would be ignored.
- Pass the cfg predicate through to rustc_expand to be validated
Co-authored-by: Vadim Petrochenkov <vadim.petrochenkov@gmail.com>
|
|
More grammar
|
|
Migrate trait and impl blocks' toggles into
Part of #83332
After this, I think only the "global" doc comment will be used as JS toggle. Once this PR is merged, I check what remains and remove them.
There is one change that this PR brings:


As you can see, I had to move the "undocumented" items below, they're not mixed with the others anymore. Unfortunately, I don't see a way to keep the current appearance without JS. As a a reminder, currently it looks like this:


r? `@jsha`
|
|
|
|
|
|
r=jyn514
rustdoc: Only store locations in Cache::extern_locations and calculate the other info on-demand
help #84588
|
|
It can be calculated on-demand.
|
|
|
|
The "aliases" attribute is not listed [on MDN], so it sounds like
it's rustdoc-specific. We don't want to conflict with any attributes
that are added to the spec in the future.
[on MDN]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Heading_Elements
|
|
extern_location function
|
|
Fix empty dom toggle
Currently, the empty impl blocks have toggles:

So when you expand it, nothing happens:

So now, in case the impl block is empty, we simply don't generate the details/summary wrapping (which also makes DOM lighter, yeay!):

r? `@jsha`
|
|
84304 - rustdoc: shrink Item::Attributes
Helps with https://github.com/rust-lang/rust/issues/84304
|
|
|
|
check item.is_fake() instead of self_id.is_some()
Remove empty branching in Attributes::from_ast
diverse small refacto after Josha review
cfg computation moved in merge_attrs
refacto use from_ast twice for coherence
take cfg out of Attributes and move it to Item
|
|
the fields in Attributes, as functions in AttributesExt.
refacto use from_def_id_and_attrs_and_parts instead of an old trick
most of josha suggestions + check if def_id is not fake before using it in a query
Removed usage of Attributes in FnDecl and ExternalCrate. Relocate part of the Attributes fields as functions in AttributesExt.
|
|
instead of opening them with JS
|
|
- Remove `span` field, adding `Item::span()` instead
- Special-case `Impl` and `Module` items
- Use dummy spans for primitive items
|
|
The only bit failing was the module, so change that before removing the
`span` field.
|
|
Clean up DOM strings
Follow-up of #84320.
r? ``@jsha``
|
|
rustdoc: Get rid of `clean::TypeKind`
It does exactly the same thing as ItemType.
|
|
rustdoc: Remove unnecessary `is_crate` field from doctree::Module and clean::Module
It can be calculated on-demand even without a TyCtxt.
This also changed `json::conversions::from_item_kind` to take a whole item, which avoids
having to add more and more parameters.
Helps with https://github.com/rust-lang/rust/issues/76382.
r? ```@camelid```
|
|
|
|
Remove unnecessary fields and parameters in rustdoc
r? `@GuillaumeGomez`
|
|
r=Manishearth,Nemo157,GuillaumeGomez
Use details tag for trait implementors.
Part of #83332 and following on from #83337 and #83355.
This removes one category of JS-generated toggles (implementors), and replaces them with a `<details>` tag. This simplifies the JS, and fixes some bugs where things that were supposed to be hidden by the toggle were not hidden. Compare https://hoffman-andrews.com/rust/details-implementors/std/io/trait.Read.html#impl-Read vs https://doc.rust-lang.org/nightly/std/io/trait.Read.html#implementors.
This introduces a `left: -23px` to put the toggle in the correct place, matching the current style for `.collapse-toggle`.
It's worth noting this introduces a slight behavior change: since the entire line is now a `<summary>`, any part of the line is clickable. So for instance, in `impl Read for File`, clicking `impl` or `for` will collapse / expand the docs. Clicking `Read` or `File` still links to the appropriate documentation as before.
|
|
|
|
clean::Module
It can be calculated on-demand even without a TyCtxt.
This also changed `from_item_kind` to take a whole item, which avoids
having to add more and more parameters.
|
|
rustdoc: Convert sub-variant toggle to HTML
Instead of creating a JS toggle, this injects details/summary for
sub-variants of enums. This also fixes the CSS so that the toggle button
does not jump when expanding/collapsing.
Takes inspiration from #83337 and should be considered part of #83332. Not quite sure if the `.sub-variant` selectors could be further simplified? AFAICS it is only used in that place, and that does not seem to allow any recursion.
|
|
|
|
|
|
|
|
|
|
|
|
It's always `tcx.crate_name(LOCAL_CRATE)`, it doesn't need to be passed
in separately.
|
|
|
|
|
|
|
|
This makes Rustdoc titles for items read like
"x in cratename::blah::foo - Rust". Title for modules and other
non-items are unchanged, and still read like
"doccratenameconst::blah::foo - Rust". This makes managing several open
Rustdoc tabs easier.
Closes #84371.
|
|
rustdoc: Simplify some document functions
* Remove `prefix` param of `document_short/full`, `render_markdown`, as its always an empty string.
* Remove `Option` wrapping of `document_short` `parent`, as its always `Some`.
|
|
Add stability tags to ImportItem.
Fixes #83832.
|
|
This switches from JS-generated toggles to using the HTML <details> tag
for expanding and collapsing entries in the "Implementors" section.
|
|
* Remove `prefix` param of `document_short/full`, `render_markdown`, as its always an empty string.
* Remove `Option` wrapping of `document_short` `parent`, as its always `Some`.
|
|
|
|
Instead of creating a JS toggle, this injects details/summary for
sub-variants of enums. This also fixes the CSS so that the toggle button
does not jump when expanding/collapsing.
|
|
rustdoc: Reduce visual weight of attributes.
Followup from #83337. As part of that PR, we stopped hiding attributes behind a toggle, because most things have just zero or one attributes. However, this made clear that the current rendering of attributes emphasizes them a lot, which distracts from function signatures. This PR changes their color of attributes to be the same as the toggles, and reduces their font weight.
This also removes `#[lang]` from the list of ALLOWED_ATTRIBUTES. This attribute is an implementation detail rather than part of the public-facing documentation.

Demo at https://hoffman-andrews.com/rust/de-emph-attr/std/string/struct.String.html#method.trim
|