about summary refs log tree commit diff
path: root/src/librustdoc/html/render
AgeCommit message (Collapse)AuthorLines
2021-05-10Auto merge of #85074 - GuillaumeGomez:end-toggle-migration, r=jshabors-13/+38
Migrate top doc and non-exhaustive toggles to details tag Fixes #83332. r? `@jsha`
2021-05-10End toggle migrationGuillaume Gomez-13/+38
2021-05-07Rollup merge of #84442 - jyn514:doc-cfg, r=petrochenkovDylan DPC-2/+2
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`````````
2021-05-05Use local and remapped paths where appropriateAndy Wang-11/+4
2021-05-05Make local_path in RealFileName::Remapped Option to be removed in exported ↵Andy Wang-5/+12
metadata
2021-05-04Add type to differentiate between fake and real DefId'sJustus K-32/+40
2021-05-03Unify rustc and rustdoc parsing of `cfg()`Joshua Nelson-2/+2
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>
2021-05-03Change librustdoc write(.. \n) to writeln(..); fix comment in grammarmautamu-1/+1
More grammar
2021-05-02Auto merge of #84754 - GuillaumeGomez:toggle-migration, r=jshabors-98/+89
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: ![Screenshot from 2021-04-30 15-39-04](https://user-images.githubusercontent.com/3050060/116713412-0f9ce200-a9d5-11eb-979c-2e7a73d16706.png) ![Screenshot from 2021-04-30 15-39-07](https://user-images.githubusercontent.com/3050060/116713415-10357880-a9d5-11eb-9868-1ba9e5ebf65e.png) 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: ![Screenshot from 2021-04-30 15-39-12](https://user-images.githubusercontent.com/3050060/116713547-31966480-a9d5-11eb-90bb-686042eefeec.png) ![Screenshot from 2021-04-30 15-39-15](https://user-images.githubusercontent.com/3050060/116713549-322efb00-a9d5-11eb-94a9-cfea073120db.png) r? `@jsha`
2021-05-02Improve code readabilityGuillaume Gomez-18/+18
2021-05-02Migrate trait and impl blocks' toggles intoGuillaume Gomez-87/+78
2021-05-01Rollup merge of #84601 - tdelabro:rustdoc-get-rid-of-cache-extern_locations, ↵Yuki Okushi-50/+11
r=jyn514 rustdoc: Only store locations in Cache::extern_locations and calculate the other info on-demand help #84588
2021-04-30Remove unnecessary `provided_trait_methods` field from ImplJoshua Nelson-6/+7
It can be calculated on-demand.
2021-04-29only store locations in extern_locationsTimothée Delabrouille-5/+9
2021-04-28rustdoc: change aliases attribute to data-aliasesMichael Howell-1/+1
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
2021-04-28added methods src_root and location to External crate, remove ↵Timothée Delabrouille-45/+2
extern_location function
2021-04-28Rollup merge of #84616 - GuillaumeGomez:fix-empty-dom-toggle, r=jshaYuki Okushi-97/+108
Fix empty dom toggle Currently, the empty impl blocks have toggles: ![Screenshot from 2021-04-27 15-15-03](https://user-images.githubusercontent.com/3050060/116249703-5ee0d980-a76d-11eb-9e15-738c06e4fb1b.png) So when you expand it, nothing happens: ![Screenshot from 2021-04-27 15-15-07](https://user-images.githubusercontent.com/3050060/116249746-686a4180-a76d-11eb-8dc1-221ca0ac57c5.png) So now, in case the impl block is empty, we simply don't generate the details/summary wrapping (which also makes DOM lighter, yeay!): ![Screenshot from 2021-04-27 15-14-15](https://user-images.githubusercontent.com/3050060/116249825-7a4be480-a76d-11eb-9637-b26151311ebd.png) r? `@jsha`
2021-04-27Auto merge of #84494 - tdelabro:84304-bis, r=jyn514bors-19/+15
84304 - rustdoc: shrink Item::Attributes Helps with https://github.com/rust-lang/rust/issues/84304
2021-04-27Don't put empty implementations into details/summary blocksGuillaume Gomez-97/+108
2021-04-27cfg taken out of Attributes, put in ItemTimothée Delabrouille-17/+10
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
2021-04-27Removed usage of Attributes in FnDecl and ExternalCrate. Relocate part of ↵Timothée Delabrouille-4/+7
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.
2021-04-26Add open attribute on details which are supposed to be open by default ↵Guillaume Gomez-2/+2
instead of opening them with JS
2021-04-24Get rid of `item.span`Joshua Nelson-6/+6
- Remove `span` field, adding `Item::span()` instead - Special-case `Impl` and `Module` items - Use dummy spans for primitive items
2021-04-24Do the hard part firstJoshua Nelson-6/+6
The only bit failing was the module, so change that before removing the `span` field.
2021-04-25Rollup merge of #84518 - GuillaumeGomez:cleanup-up-dom-string, r=jshaYuki Okushi-4/+9
Clean up DOM strings Follow-up of #84320. r? ``@jsha``
2021-04-25Rollup merge of #84464 - jyn514:type-kind, r=CraftSpiderYuki Okushi-10/+10
rustdoc: Get rid of `clean::TypeKind` It does exactly the same thing as ItemType.
2021-04-25Rollup merge of #84460 - jyn514:doctree-is-crate, r=camelidYuki Okushi-2/+2
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```
2021-04-24Clean up DOM stringsGuillaume Gomez-4/+9
2021-04-24Rollup merge of #84458 - jyn514:cleanup-after-krate, r=GuillaumeGomezYuki Okushi-20/+19
Remove unnecessary fields and parameters in rustdoc r? `@GuillaumeGomez`
2021-04-24Rollup merge of #84320 - jsha:details-implementors, ↵Yuki Okushi-3/+12
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.
2021-04-23Use ItemType in cacheJoshua Nelson-10/+10
2021-04-23rustdoc: Remove unnecessary `is_crate` field from doctree::Module and ↵Joshua Nelson-2/+2
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.
2021-04-24Rollup merge of #84321 - Swatinem:subvariant-details, r=GuillaumeGomezYuki Okushi-0/+2
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.
2021-04-22Remove unnecessary item_name parameter to `mod_item_in`Joshua Nelson-3/+4
2021-04-22Remove unnecessary `item_name` parameter to `mod_item_out`Joshua Nelson-1/+1
2021-04-22Remove unnecessary `edition` field on SharedContextJoshua Nelson-8/+9
2021-04-22Remove unnecessary `edition` parameter to rendererJoshua Nelson-2/+1
2021-04-22Remove unnecessary `diag` parameter to `after_krate`Joshua Nelson-2/+3
2021-04-22Remove unnecessary `crate_name` parameter to `after_krate`Joshua Nelson-6/+3
It's always `tcx.crate_name(LOCAL_CRATE)`, it doesn't need to be passed in separately.
2021-04-22Remove `name` field from ExternalCrateJoshua Nelson-1/+2
2021-04-20fix is_module checkSmitty-4/+4
2021-04-20Rename pushname to is_moduleSmitty-3/+3
2021-04-20Write Rustdoc titles like "x in crate::mod - Rust"Smitty-9/+8
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.
2021-04-20Rollup merge of #84347 - Swatinem:simplify-document-fns, r=jyn514Dylan DPC-45/+11
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`.
2021-04-20Auto merge of #83900 - torhovland:issue-83832, r=jyn514bors-4/+34
Add stability tags to ImportItem. Fixes #83832.
2021-04-19rustdoc: use details tag for trait implementorsJacob Hoffman-Andrews-3/+12
This switches from JS-generated toggles to using the HTML <details> tag for expanding and collapsing entries in the "Implementors" section.
2021-04-19rustdoc: Simplify some document functionsArpad Borsos-45/+11
* 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`.
2021-04-19No longer need to add attrs to ImportSource.Tor Hovland-4/+13
2021-04-19rustdoc: Convert sub-variant toggle to HTMLArpad Borsos-0/+2
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.
2021-04-19Auto merge of #84283 - jsha:de-emphasize-attributes, r=GuillaumeGomezbors-1/+0
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. ![image](https://user-images.githubusercontent.com/220205/115131061-cc407d80-9fa9-11eb-9a77-ad3f3217f391.png) Demo at https://hoffman-andrews.com/rust/de-emph-attr/std/string/struct.String.html#method.trim