about summary refs log tree commit diff
path: root/src/librustdoc
AgeCommit message (Collapse)AuthorLines
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.
2021-04-09Auto merge of #84034 - jyn514:regex-in-loop, r=Mark-Simulacrumbors-1/+1
Fix perf regression in rustdoc::bare_urls This regressed in #81764. After that PR, rustdoc compiled the regex for every single item in the crate: https://perf.rust-lang.org/compare.html?start=125505306744a0a5bb01d62337260a95d9ff8d57&end=2e495d2e845cf27740e3665f718acfd3aa17253e&stat=instructions%3Au This would have been caught by `clippy::declare_interior_mutable_const` (cc https://github.com/rust-lang/rust/issues/77983).
2021-04-09Fix perf regression in non-autolinksJoshua Nelson-1/+1
Before, this was compiling the regex on every single item in the crate. This would have been caught by `clippy::declare_interior_mutable_const`.
2021-04-09Auto merge of #84030 - jyn514:no-blanket-impls, r=GuillaumeGomezbors-44/+7
rustdoc: Don't generate blanket impls when running --show-coverage `get_blanket_impls` is the slowest part of rustdoc, and the coverage pass completely ignores blanket impls. This stops running it at all, and also removes some unnecessary checks in `calculate_doc_coverage` that ignored the impl anyway. We don't currently measure --show-coverage in perf.rlo, but I tested this locally on cargo and it brought the time down from 2.9 to 1.6 seconds. This also adds back a commented-out test; Rustdoc has been able to deal with `impl trait` for almost a year now. r? `@GuillaumeGomez`
2021-04-09rustdoc: Don't generate blanket impls when running --show-coverageJoshua Nelson-44/+7
get_blanket_impls is the slowest part of rustdoc, and the coverage pass completely ignores blanket impls. This stops running it at all, and also removes some unnecessary checks in `calculate_doc_coverage` that ignored the impl anyway. We don't currently measure --show-coverage in perf.rlo, but I tested this locally on cargo and it brought the time down from 2.9 to 1.6 seconds.
2021-04-08Rollup merge of #83992 - GuillaumeGomez:merge-idents, r=notriddleDylan DPC-18/+127
Merge idents when generating source content The idea here is to not have a span for each part of a path. Currently, for `a::b::c` we generate `<span>a</span>::<span>b</span>::<span>c</span>`, with this change, we will generate `<span>a::b::c</span>`. A nice "side-effect" is that it reduces the size of the output HTML too. :) cc `@notriddle`
2021-04-08Rollup merge of #81764 - jyn514:lint-links, r=GuillaumeGomezDylan DPC-65/+43
Stabilize `rustdoc::bare_urls` lint Closes https://github.com/rust-lang/rust/issues/77501. Closes https://github.com/rust-lang/rust/issues/83598.
2021-04-08Add test for idents mergeGuillaume Gomez-0/+20
2021-04-08Merge idents if they are part of a pathGuillaume Gomez-18/+107
2021-04-08Auto merge of #83981 - nagisa:nagisa/revert-cfg-wasm, r=Mark-Simulacrumbors-1/+0
Remove the insta-stable `cfg(wasm)` The addition of `cfg(wasm)` was an oversight on my end that turns out to have a number of downsides: * It was introduced as an insta-stable addition, forgoing the usual staging mechanism we use for potentially far-reaching changes; * It is a breaking change for people who are using `--cfg wasm` either directly or via cargo for other purposes; * It is not entirely clear if a bare `wasm` cfg is a right option or whether `wasm` family of targets are special enough to warrant special-casing these targets specifically. As for the last point, there appears to be a fair amount of support for reducing the boilerplate in specifying architectures from the same family, while ignoring their pointer width. The suggested way forward would be to propose such a change as a separate RFC as it is potentially a quite contentious addition. cc #83879 `@devsnek`
2021-04-08Auto merge of #83866 - jyn514:disambiguator-error, r=camelidbors-14/+34
rustdoc: Link to the docs on namespaces when an unknown disambiguator is found cc https://github.com/rust-lang/rust/issues/83859 `@lopopolo` does this look about like what you expected? r? `@camelid`
2021-04-08Rollup merge of #82497 - jyn514:json, r=CraftSpiderDylan DPC-14/+13
Fix handling of `--output-format json` flag - Don't treat it as deprecated on stable and beta channels. Before, it would give confusing and incorrect output: ``` warning: the 'output-format' flag is considered deprecated | = warning: see issue #44136 <https://github.com/rust-lang/rust/issues/44136> for more information error: json output format isn't supported for doc generation ``` Both of those are wrong: output-format isn't deprecated, and json output is supported. - Require -Z unstable-options for `--output-format json` Previously, it was allowed by default on nightly, which made it hard to realize the flag wouldn't be accepted on beta or stable. To get the test working I had to remove `-Z unstable-options`, which x.py passed to compiletest unconditionally. It was first added in https://github.com/rust-lang/rust/commit/8c2ec689c159e7f021d5913efb991aff875be967 so `-Z miri` would be allowed. -Z miri is no longer passed unconditionally, so hopefully removing it won't break anything. r? ```@aDotInTheVoid``` cc ```@HeroicKatora``` ```@CraftSpider``` Thanks to ```@memoryruins``` for pointing it out on Discord! cc ```@Mark-Simulacrum``` for the change to compiletest.
2021-04-07Remove the insta-stable `cfg(wasm)`Simonas Kazlauskas-1/+0
The addition of `cfg(wasm)` was an oversight on my end that has a number of downsides: * It was introduced as an insta-stable addition, forgoing the usual staging mechanism we use for potentially far-reaching changes; * It is a breaking change for people who are using `--cfg wasm` either directly or via cargo for other purposes; * It is not entirely clear if a bare `wasm` cfg is a right option or whether `wasm` family of targets are special enough to warrant special-casing these targets specifically. As for the last point, there appears to be a fair amount of support for reducing the boilerplate in specifying architectures from the same family, while ignoring their pointer width. The suggested way forward would be to propose such a change as a separate RFC as it is potentially a quite contentious addition.
2021-04-07Reuse logic for determining the channel in the rest of rustdocJoshua Nelson-22/+29
This doesn't update main.js because it's included as a fixed string.
2021-04-07rustdoc: Link to the docs on namespaces when an unknown disambiguator is foundJoshua Nelson-1/+14
2021-04-07change based on reviewsAliénore Bouttefeux-2/+2
2021-04-07Auto merge of #83833 - jyn514:no-resolver, r=GuillaumeGomezbors-82/+82
rustdoc: Store intra-doc links in Cache instead of on items directly Items are first built after rustdoc creates the TyCtxt. To allow resolving the links before the TyCtxt is built, the links can't be stored on `clean::Item` directly. Helps with https://github.com/rust-lang/rust/issues/83761. Opening this early because I think it might decrease memory usage.
2021-04-06Auto merge of #83828 - camelid:rustdoc-vec-perf, r=jyn514bors-3/+5
rustdoc: Use `ThinVec` in a few places Almost every crate has no primitives and no keywords defined in it, so using `ThinVec` should make some types smaller.
2021-04-06Fix handling of `--output-format json` flagJoshua Nelson-14/+13
- Don't treat it as deprecated on stable and beta channels. Before, it would give confusing and incorrect output: ``` warning: the 'output-format' flag is considered deprecated | = warning: see issue #44136 <https://github.com/rust-lang/rust/issues/44136> for more information error: json output format isn't supported for doc generation ``` Both of those are wrong: output-format isn't deprecated, and json output is supported. - Require -Z unstable-options for `--output-format json` Previously, it was allowed by default on nightly, which made it hard to realize the flag wouldn't be accepted on beta or stable. Note that this still allows `--output-format html`, which has been stable since 1.0. - Remove unnecessary double-checking of the feature gate when parsing the output format - Add custom run-make test since compiletest passes -Zunstable-options by default
2021-04-06Store links in Cache instead of on items directlyJoshua Nelson-82/+82
Items are first built after rustdoc creates the TyCtxt. To allow resolving the links before the TyCtxt is built, the links can't be stored on `clean::Item` directly.
2021-04-06Auto merge of #83934 - Dylan-DPC:rollup-nw5dadn, r=Dylan-DPCbors-86/+85
Rollup of 7 pull requests Successful merges: - #82963 (Move `SharedContext` to `context.rs`) - #83829 (rustc_target: Rely on defaults more in target specs) - #83895 (Add listing of lints (eg via `-W help`) to rustdoc) - #83902 (Update LLVM to support more wasm simd ops) - #83903 (Fix typo in TokenStream documentation) - #83910 (Update cargo) - #83920 (Fix HashMap/HashSet LLDB pretty-printer after hashbrown 0.11.0) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-04-06rustdoc: Use `ThinVec` in a few placesCamelid-3/+5
Almost every crate has no primitives and no keywords defined in it, so using `ThinVec` should make some types smaller.
2021-04-06correction based on reviewAliénore Bouttefeux-2/+2
2021-04-06Rollup merge of #83895 - eggyal:issue-83883, r=jyn514Dylan DPC-3/+8
Add listing of lints (eg via `-W help`) to rustdoc Fixes #83883 r? `@jyn514`
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-06Auto merge of #83875 - jyn514:diag_info, r=bugadanibors-124/+52
rustdoc: Use DiagnosticInfo in more parts of intra-doc links This makes the code a lot less verbose. This is separated into lots of tiny commits because it was easier for me that way, but the overall diff isn't that big if you want to read it at once. r? `@bugadani`
2021-04-06Add listing of lints (eg via -W help) to rustdocAlan Egerton-3/+8
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-05Auto merge of #83905 - JohnTitor:rollup-pa1la80, r=JohnTitorbors-158/+128
Rollup of 8 pull requests Successful merges: - #83370 (Add `x.py setup tools` which enables `download-rustc` by default) - #83489 (Properly suggest deref in else block) - #83734 (Catch a bad placeholder type error for statics in `extern`s) - #83814 (expand: Do not ICE when a legacy AST-based macro attribute produces and empty expression) - #83835 (rustdoc: sort search index items for compression) - #83849 (rustdoc: Cleanup handling of associated items for intra-doc links) - #83881 (:arrow_up: rust-analyzer) - #83885 (Document compiler/ with -Aprivate-intra-doc-links) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-04-06Rollup merge of #83849 - jyn514:intra-doc-cleanup, r=bugadaniYuki Okushi-135/+102
rustdoc: Cleanup handling of associated items for intra-doc links Helps with https://github.com/rust-lang/rust/issues/83761 (right now the uses of the resolver are all intermingled with uses of the tyctxt). Best reviewed one commit at a time. r? ```@bugadani``` maybe? Feel free to reassign :)
2021-04-06Rollup merge of #83835 - notriddle:sort-index, r=ollie27Yuki Okushi-23/+26
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-05Auto merge of #83152 - guswynn:jemallocator_part2, r=Mark-Simulacrumbors-0/+54
Use tikv-jemallocator in rustc/rustdoc in addition to jemalloc-sys when enabled. In https://github.com/rust-lang/rust/pull/81782 it was mentioned that one reason rustc may benefit from minimalloc is it doesn't use the `sdallocx` api from jemalloc. Currently, on unix, rust uses jemalloc by importing its symbols to use them with the default, System (libc) global allocator. This PR switches its global alloc to `tikv-jemallocator`, which correctly uses sized deallocation (https://docs.rs/tikv-jemallocator/0.4.1/src/tikv_jemallocator/lib.rs.html#121-126). `tikv-jemallocator`, as far as I can tell, is a more up-to-date set of bindings to jemalloc than `jemallocator` The perf results of this pr are in large part due to the version upgrade of jemalloc, but sized deallocation has a non-trivial improvement, particularly to rustdoc. This pr also includes changes to bootstrap to correctly pass the jemalloc feature through to the rustdoc build
2021-04-05Merge branch 'master' into masterAliénore Bouttefeux-106/+206
2021-04-05fix failing buildAliénore Bouttefeux-1/+2
2021-04-05Use DiagnosticInfo for `report_diagnostic`Joshua Nelson-39/+29