about summary refs log tree commit diff
path: root/src/librustdoc/html/render
AgeCommit message (Collapse)AuthorLines
2021-04-19Auto merge of #84288 - notriddle:short-links, r=jyn514bors-12/+1
rustdoc: get rid of CURRENT_DEPTH Fixes #82742
2021-04-18Put attrs in a Box for memory efficiency.Tor Hovland-2/+0
2021-04-18Now also displays portability tags.Tor Hovland-3/+8
2021-04-18Give import items their own CSS class.Tor Hovland-1/+1
2021-04-18Add stability tags to ImportItem.Tor Hovland-4/+22
2021-04-17rustdoc: get rid of CURRENT_DEPTHMichael Howell-12/+1
2021-04-17Reduce visual weight of attributes.Jacob Hoffman-Andrews-1/+0
2021-04-17Rollup merge of #84150 - jsha:defer-search-js, r=GuillaumeGomezDylan DPC-1/+2
rustdoc: move some search code into search.js This reduces main.s from 3094 lines to 1587. Also it saves some bytes of download in the case where search isn't used. There were a fair number of variables that needed to be accessible in both main.js and search.js, but I didn't want to put too many symbols in the global namespace, so I consolidated much of the search-related state and functions into a new object `window.searchState`. Demo at https://hoffman-andrews.com/rust/move-search/std/?search=foo
2021-04-17rustdoc: move the cx argument to the end of the listMichael Howell-20/+20
This should help make things consistent.
2021-04-17rustdoc: use more precise relative URLSMichael Howell-165/+128
Instead of using a depth counter and adding "../" to get to the top, this commit makes rustdoc actually compare the path of what it's linking from to the path that it's linking to. This makes the resulting HTML shorter. Here's a comparison of one of the largest (non-source) files in the Rust standard library docs (about 4% improvement before gzipping). $ wc -c struct.Wrapping.old.html struct.Wrapping.new.html 2387389 struct.Wrapping.old.html 2298538 struct.Wrapping.new.html Most if it can be efficiently gzipped away. $ wc -c struct.Wrapping.old.html.gz struct.Wrapping.new.html.gz 70679 struct.Wrapping.old.html.gz 70050 struct.Wrapping.new.html.gz But it also makes a difference in the final DOM size, reducing it from 91MiB to 82MiB.
2021-04-16Rollup merge of #83337 - Manishearth:item-hide, r=GuillaumeGomezDylan DPC-54/+109
rustdoc: Hide item contents, not items This tweaks rustdoc to hide item contents instead of items, and only when there are too many of them. This means that users will _always_ see the type parameters, and will _often_ see fields/etc as long as they are small. Traits have some heuristics for hiding only the methods or only the methods and the consts, since the associated types are super important. I'm happy to play around with the heuristics here; we could potentially make it so that structs/enums/etc are always hidden but traits will try really hard to show type aliases. This needs a test, but you can see it rendered at https://manishearth.net/sand/doc_render/bar/ <details> <summary> Code example </summary> ```rust pub struct PubStruct { pub a: usize, pub b: usize, } pub struct BigPubStruct { pub a: usize, pub b: usize, pub c: usize, pub d: usize, pub e: usize, pub f: usize, } pub union BigUnion { pub a: usize, pub b: usize, pub c: usize, pub d: usize, pub e: usize, pub f: usize, } pub union Union { pub a: usize, pub b: usize, pub c: usize, } pub struct PrivStruct { a: usize, b: usize, } pub enum Enum { A, B, C, D { a: u8, b: u8 } } pub enum LargeEnum { A, B, C, D, E, F, G, H, I, J } pub trait Trait { type A; #[must_use] fn foo(); fn bar(); } pub trait GinormousTrait { type A; type B; type C; type D; type E; type F; const N: usize = 1; #[must_use] fn foo(); fn bar(); } pub trait HugeTrait { type A; const M: usize = 1; const N: usize = 1; const O: usize = 1; const P: usize = 1; const Q: usize = 1; #[must_use] fn foo(); fn bar(); } pub trait BigTrait { type A; #[must_use] fn foo(); fn bar(); fn baz(); fn quux(); fn frob(); fn greeble(); } #[macro_export] macro_rules! foo { (a) => {a}; } ``` </details> Fixes https://github.com/rust-lang/rust/issues/82114
2021-04-13Split search.js from search-index.js.Jacob Hoffman-Andrews-2/+4
2021-04-13tidy format rustFrançois Mockers-10/+28
2021-04-13fix source link when in a trait implementationFrançois Mockers-8/+30
2021-04-13add anchors links on hover to items from trait implFrançois Mockers-6/+13
2021-04-13fix links from trait impl methods to trait declarationFrançois Mockers-3/+4
2021-04-12Move search JS into search-index.jsJacob Hoffman-Andrews-3/+2
Export a few variables and functions into the global scope because they are needed both by main.js and search-index.js.
2021-04-12& -> &&Manish Goregaokar-2/+2
2021-04-12Wrap toggle_open()Manish Goregaokar-1/+4
2021-04-12should_hide_fields > 12Manish Goregaokar-2/+1
2021-04-12Add css classesManish Goregaokar-2/+2
2021-04-12Improve CSS for "hide contents, not items"Jacob Hoffman-Andrews-50/+48
Introduce a first use of the `<details>` and `<summary>` tags as replacements for the JS-built toggles. I think this has the potential to replace all the JS toggles and generally clean up the JS, CSS, and HTML. Split rendering of attributes into two cases: in the case where they are rendered as descendents of a `<pre>` tag, where they use indent spaces and newlines for formatting, matching their surrounding markup. In the case where they are rendered as descendants of a `<code>` tag, they are rendered as `<div>`. This let me clean up some fragile CSS that was adjusting the margin-left of attributes depending on context. Remove toggles for attributes. With the ALLOWED_ATTRIBUTES filter, it's rare for an item to have more than one attribute, so hiding attributes behind a toggle doesn't save any screen space in the common case. Fix a couple of invocations of `matches!` that didn't compile on my machine. Fix a boolean for the JS `createToggle` call that was causing "Expand description" to show up spuriously on already-expanded descriptions. Add JS for auto-hide settings and hide all / show all. Remove a z-index property and some font color tweaks made unnecessary by the <details> toggles. Add CSS for the <details> toggles.
2021-04-12Update src/librustdoc/html/render/print_item.rsManish Goregaokar-1/+1
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2021-04-12Update src/librustdoc/html/render/print_item.rsManish Goregaokar-1/+1
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2021-04-12rustdoc: Add setting for hiding large itemsManish Goregaokar-0/+1
2021-04-12rustdoc: smartly hide associated items of traits if there are too many of themManish Goregaokar-6/+24
2021-04-12rustdoc: hide fields of structs/unions > 5Manish Goregaokar-7/+30
2021-04-12rustdoc: hide variants of enums > 5Manish Goregaokar-0/+24
2021-04-12rustdoc: Stop hiding entire item declarationsManish Goregaokar-12/+1
2021-04-06Rollup merge of #82963 - camelid:move-sharedcontext, r=GuillaumeGomezDylan DPC-83/+77
Move `SharedContext` to `context.rs` It is tightly connected to `Context` and is primarily used as a field in `Context`. Thus, it should be next to `Context`.
2021-04-05Move `SharedContext` to `context.rs`Camelid-83/+77
It is tightly connected to `Context` and is primarily used as a field in `Context`. Thus, it should be next to `Context`.
2021-04-06Rollup merge of #83835 - notriddle:sort-index, r=ollie27Yuki Okushi-9/+23
rustdoc: sort search index items for compression This should not affect the appearance of the docs pages themselves. This makes the pre-compressed search index smaller, thanks to the empty-string path duplication format, and also the gzipped version, by giving the algorithm more structure to work with. rust$ wc -c search-index-old.js search-index-new.js 2628334 search-index-old.js 2586181 search-index-new.js 5214515 total rust$ gzip search-index-* rust$ wc -c search-index-old.js.gz search-index-new.js.gz 239486 search-index-old.js.gz 237386 search-index-new.js.gz 476872 total
2021-04-05Rollup merge of #83826 - slightlyoutofphase:rustdoc-sidebar-order-shuffle, ↵Dylan DPC-7/+8
r=jyn514 List trait impls before deref methods in doc's sidebar This PR is acting directly on a suggestion made by ```````@jyn514``````` in #83133. I've tested the changes locally, and can confirm that it does in fact properly achieve what he thought it would. This PR also in turn closes #83133.
2021-04-05Update Source Serif to release 4.004Trevor Spiteri-4/+4
Now the family name is Source Serif 4 (upstream issue 77) instead of Source Serif Pro.
2021-04-04Get rid of unneeded `aliases` fieldMichael Howell-2/+6
2021-04-04Rollup merge of #83809 - GuillaumeGomez:remove-initial-ids, r=camelidDylan DPC-23/+2
Remove unneeded INITIAL_IDS const Some IDs inside this map didn't exist anymore, some others were duplicates of what we have inside `IdMap`. So instead of keeping the two around and since `INITIAL_IDS` was only used by `IdMap`, no need to keep both of them.
2021-04-03rustdoc: sort search index items for compressionMichael Howell-7/+17
This should not affect the appearance of the docs pages themselves. This makes the pre-compressed search index smaller, thanks to the empty-string path duplication format, and also the gzipped version, by giving the algorithm more structure to work with. rust$ wc -c search-index-old.js search-index-new.js 2628334 search-index-old.js 2586181 search-index-new.js 5214515 total rust$ gzip search-index-* rust$ wc -c search-index-old.js.gz search-index-new.js.gz 239486 search-index-old.js.gz 237386 search-index-new.js.gz 476872 total
2021-04-03Remove unneeded INITIAL_IDS constGuillaume Gomez-23/+2
2021-04-03Remove trailing whitespaceSlightlyOutOfPhase-1/+1
2021-04-03List trait impls before methods from deref in the sidebar of Rustdoc's outputSlightlyOutOfPhase-7/+8
2021-04-04Rollup merge of #83756 - camelid:internal-rename-doc-spotlight, r=GuillaumeGomezYuki Okushi-11/+13
rustdoc: Rename internal uses of `spotlight` I didn't make these renames in #80965 because I didn't want the PR to conflict with #80914.
2021-04-02rustdoc: Rename internal uses of `spotlight`Camelid-11/+13
I didn't make these renames in #80965 because I didn't want the PR to conflict with #80914.
2021-04-02Rollup merge of #83478 - jyn514:fine-grained-files, r=Mark-SimulacrumDylan DPC-134/+178
rustdoc: Add unstable option to only emit shared/crate-specific files The intended use case is for docs.rs, which can now copy exactly the files it cares about, rather than having to guess based on whether they have a resource suffix or not. In particular, some files have a resource suffix but cannot be shared between crates: https://github.com/rust-lang/docs.rs/pull/1312#issuecomment-798783688 The end goal is to fix rust-lang/docs.rs#1327 by reverting rust-lang/docs.rs#1324. This obsoletes `--print=unversioned-files`, which I plan to remove as soon as docs.rs stops using it. I recommend reviewing this one commit at a time. r? ``@GuillaumeGomez`` cc ``@Nemo157`` ``@pietroalbini``
2021-03-31Fix `--external-css` to be invocation-specific and note main.js should be ↵Joshua Nelson-1/+10
invocation specific
2021-03-31Add a button to copy the "use statement"Guillaume Gomez-0/+1
2021-03-31Rename CrateSpecific -> InvocationSpecificJoshua Nelson-7/+7
2021-03-31Enforce that Toolchain files are static and Crate files are dynamicJoshua Nelson-28/+35
This also changes custom themes from Toolchain to Crate files.
2021-03-26Rollup merge of #83055 - aDotInTheVoid:selective-strip-item-doc, r=jyn514Dylan DPC-0/+2
[rustdoc] Don't document stripped items in JSON renderer. Fixes #80664, see [my comment there](https://github.com/rust-lang/rust/issues/80664#issuecomment-797557948) for why Note that we already do something similar in `convert_item`: https://github.com/rust-lang/rust/blob/bb4cdf8ec034dca5c056ec9295f38062e5b7e871/src/librustdoc/json/conversions.rs#L28-L31 ``@rustbot`` modify labels: +T-rustdoc +A-rustdoc-json r? ``@jyn514`` cc ``@CraftSpider``
2021-03-25Add unstable option to only emit shared/crate-specific filesJoshua Nelson-12/+40
The intended use case is for docs.rs, which can now copy exactly the files it cares about, rather than having to guess based on whether they have a resource suffix or not. In particular, some files have a resource suffix but cannot be shared between crates: https://github.com/rust-lang/docs.rs/pull/1312#issuecomment-798783688 The end goal is to fix https://github.com/rust-lang/docs.rs/issues/1327 by reverting https://github.com/rust-lang/docs.rs/pull/1324. This obsoletes `--print=unversioned-files`, which I plan to remove as soon as docs.rs stops using it.
2021-03-25Add SharedResource abstraction and use it in write_sharedJoshua Nelson-115/+115
This cleans up the code quite a bit, and also makes the next commit much easier.