about summary refs log tree commit diff
path: root/src/librustdoc
AgeCommit message (Collapse)AuthorLines
2021-04-19Rollup merge of #84330 - GuillaumeGomez:remove-footer, r=jyn514Dylan DPC-1/+0
Remove unused footer section I realized yesterday while working on docs.rs that rustdoc was generating a "footer"section that it doesn't use. No need to keep it then. r? `@jyn514`
2021-04-19Remove unused footer sectionGuillaume Gomez-1/+0
2021-04-19Auto merge of #84283 - jsha:de-emphasize-attributes, r=GuillaumeGomezbors-4/+10
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
2021-04-19Auto merge of #84288 - notriddle:short-links, r=jyn514bors-52/+44
rustdoc: get rid of CURRENT_DEPTH Fixes #82742
2021-04-17rustdoc: get rid of CURRENT_DEPTHMichael Howell-52/+44
2021-04-18Fix the wrong return value type description of validateResulthi-rustin-1/+1
2021-04-17Reduce visual weight of attributes.Jacob Hoffman-Andrews-4/+10
2021-04-17Rollup merge of #84203 - jyn514:anchor-span, r=euclioDylan DPC-8/+16
rustdoc: Give a more accurate span for anchor failures r? `@euclio`
2021-04-17Rollup merge of #84150 - jsha:defer-search-js, r=GuillaumeGomezDylan DPC-1687/+1676
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: Give a more accurate span for anchor failuresJoshua Nelson-8/+16
2021-04-17rustdoc: move the cx argument to the end of the listMichael Howell-33/+33
This should help make things consistent.
2021-04-17rustdoc: change 'cx to 'tcx, to match the struct itselfMichael Howell-60/+60
2021-04-17Remove assert that no longer mattersMichael Howell-7/+0
The function `to_src_with_space` doesn't even accept the cache as a parameter, so it doesn't matter any more what's in it.
2021-04-17rustdoc: use more precise relative URLSMichael Howell-442/+463
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-17Auto merge of #84246 - notriddle:rustdoc-path-printing-cleanup, r=jyn514bors-43/+1
rustdoc: get rid of unused path printing code The code for printing a raw path is only used in utils.rs, which only prints the alternative (non-HTML) format. Path has a function that does the same thing without HTML support, so use that instead.
2021-04-16Auto merge of #84074 - notriddle:rustdoc-macro-visibility, r=jyn514bors-12/+40
rustdoc: clean up and test macro visibility print This fixes the overly-complex invariant mentioned in <https://github.com/rust-lang/rust/pull/83237#issuecomment-815346570>, where the macro source can't have any links in it only because the cache hasn't been populated yet.
2021-04-16rustdoc: get rid of unused path printing codeMichael Howell-43/+1
The code for printing a raw path is only used in utils.rs, which only prints the alternative (non-HTML) format. Path has a function that does the same thing without HTML support, so use that instead.
2021-04-16Rollup merge of #83337 - Manishearth:item-hide, r=GuillaumeGomezDylan DPC-146/+184
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-15Rollup merge of #84201 - jyn514:primitive-warnings, r=cuviperDylan DPC-0/+4
rustdoc: Note that forbidding anchors in links to primitives is a bug cc https://github.com/rust-lang/rust/issues/83083, https://github.com/rust-lang/rust/pull/84147#discussion_r613518820 r? `@cuviper`
2021-04-14rustdoc: Note that forbidding anchors in links to primitives is a bugJoshua Nelson-0/+4
2021-04-14Update comment on search.js static file.Jacob Hoffman-Andrews-2/+1
2021-04-14Change root_path to static_root_pathJacob Hoffman-Andrews-1/+1
Co-authored-by: Guillaume Gomez <guillaume1.gomez@gmail.com>
2021-04-14Auto merge of #83068 - mockersf:method-trait-foreign-impl, r=GuillaumeGomezbors-19/+69
rustdoc: links from items in a trait impl are inconsistent Depending on where the struct implementing a trait is coming from, or the current page, the items in a trait impl are not linking to the same thing: |item| trait page, implementors| trait page, implementations on Foreign Types|struct page, trait implementations| |-|-|-|-| |function| link to current impl|link to first impl in the list|link to trait def |default function | not present |not present |link to trait def |default function with custom impl|link to current impl|link to trait def |link to trait def |constant| link to current impl|link to trait def |link to trait def |associated type| link to current impl|link to trait def |link to trait def ||*missing link to trait def*|*function link wrong + missing link to current impl*|*missing link to current impl*| <details> <summary>rust code with those cases</summary> ```rust pub trait MyTrait { type Assoc; const VALUE: u32; fn trait_function(&self); fn defaulted(&self) {} fn defaulted_override(&self) {} } impl MyTrait for String { /// will link to trait def type Assoc = (); /// will link to trait def const VALUE: u32 = 5; /// will link to first foreign implementor fn trait_function(&self) {} /// will link to trait def fn defaulted_override(&self) {} } impl MyTrait for Vec<u8> { /// will link to trait def type Assoc = (); /// will link to trait def const VALUE: u32 = 5; /// will link to first foreign implementor fn trait_function(&self) {} /// will link to trait def fn defaulted_override(&self) {} } impl MyTrait for MyStruct { /// in trait page, will link to current impl /// /// in struct page, will link to trait def type Assoc = bool; /// in trait page, will link to current impl /// /// in struct page, will link to trait def const VALUE: u32 = 20; /// in trait page, will link to current impl /// /// in struct page, will link to trait def fn trait_function(&self) {} /// in trait page, will link to current impl /// /// in struct page, will link to trait def fn defaulted_override(&self) {} } pub struct MyStruct; ``` </details> In this PR, I fixed all links to target the trait definition, and added an anchor-link to the current implementation appearing on mouse hover.
2021-04-13Split search.js from search-index.js.Jacob Hoffman-Andrews-9/+12
2021-04-13tidy format rustFrançois Mockers-10/+28
2021-04-13format cssFrançois Mockers-1/+2
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-8/+16
2021-04-13fix links from trait impl methods to trait declarationFrançois Mockers-3/+4
2021-04-13Further consolidate search-related vars and funcsJacob Hoffman-Andrews-76/+61
2021-04-13Consolidate search-related vars and functions.Jacob Hoffman-Andrews-175/+167
This allows sharing across main.js and search.js without exporting too many symbols into the global namespace.
2021-04-12Move search JS into search-index.jsJacob Hoffman-Andrews-1524/+1534
Export a few variables and functions into the global scope because they are needed both by main.js and search-index.js.
2021-04-12Add explanatory note to `bare_urls` lintCamelid-0/+1
I think the lint is confusing otherwise since it doesn't fully explain what the problem is.
2021-04-12+ignore-tidy-filelengthManish Goregaokar-1/+2
2021-04-12Move color to themesManish Goregaokar-5/+9
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-12/+12
2021-04-12Improve CSS for "hide contents, not items"Jacob Hoffman-Andrews-130/+116
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-1/+6
2021-04-12rustdoc: smartly hide associated items of traits if there are too many of themManish Goregaokar-12/+30
2021-04-12rustdoc: hide fields of structs/unions > 5Manish Goregaokar-8/+31
2021-04-12rustdoc: hide variants of enums > 5Manish Goregaokar-7/+34
2021-04-12rustdoc: Stop hiding entire item declarationsManish Goregaokar-33/+5
2021-04-11Move crate loader to collect_intra_doc_links::earlyJoshua Nelson-61/+80
This groups the similar code together, and also allows making most of collect_intra_doc_links private again
2021-04-10Preprocess intra-doc links consistentlyJoshua Nelson-91/+146
Previously, rustdoc would panic on links to external crates if they were surrounded by backticks.
2021-04-10rustdoc: clean up and test macro visibility printMichael Howell-12/+40
This fixes the overly-complex invariant mentioned in <https://github.com/rust-lang/rust/pull/83237#issuecomment-815346570>, where the macro source can't have any links in it only because the cache hasn't been populated yet.