about summary refs log tree commit diff
path: root/src/librustdoc/html/render/mod.rs
AgeCommit message (Collapse)AuthorLines
2021-03-02Load rustdoc's JS search index on-demand.Jacob Hoffman-Andrews-7/+10
Instead of being loaded on every page, the JS search index is now loaded when either (a) there is a `?search=` param, or (b) the search input is focused. This saves both CPU and bandwidth. As of Feb 2021, https://doc.rust-lang.org/search-index1.50.0.js is 273,838 bytes gzipped or 2,544,939 bytes uncompressed. Evaluating it takes 445 ms of CPU time in Chrome 88 on a i7-10710U CPU (out of a total ~2,100 ms page reload). Generate separate JS file with crate names. This is much smaller than the full search index, and is used in the "hot path" to draw the page. In particular it's used to crate the dropdown for the search bar, and to append a list of crates to the sidebar (on some pages). Skip early search that can bypass 500ms timeout. This was occurring when someone had typed some text during the load of search-index.js. Their query was usually not ready to execute, and the search itself is fairly expensive, delaying the overall load, which delayed the input / keyup events, which delayed eventually executing the query.
2021-03-01Remove the dummy cache in `DocContext`Joshua Nelson-2/+1
The same information is available everywhere; the only reason the dummy cache was needed is because it waas previously stored in three different places. This consolidates the info a bit so the cache in `DocContext` is used throughout. As a bonus, it means `renderinfo` is used much much less. - Return a `Cache` from `run_global_ctxt`, not `RenderInfo` - Remove the unused `render_info` from `run_renderer` - Remove RefCell around `inlined` - Add intra-doc links
2021-02-26Rollup merge of #82545 - jsha:woff2, r=GuillaumeGomezGuillaume Gomez-0/+2
rustdoc: add optional woff2 versions of FiraSans. For browsers that support woff2 (most modern ones: https://caniuse.com/woff2), this offers a reduction in download size for these two fonts from 362k to 257k (32% reduction). It decreases the total page size for `struct.String.html` (counting all subresources) by about 2.5%. If this is interesting, I'm happy to apply the same treatment to the other fonts, but these two are the biggest.
2021-02-26Embed woff2 files in rustdoc binary.Jacob Hoffman-Andrews-0/+2
2021-02-25Rollup merge of #82484 - bugadani:docfix, r=jyn514Aaron Hill-1/+0
rustdoc: Remove duplicate "List of all items" Closes #82477 r? `@jyn514`
2021-02-24Remove duplicate stringDániel Buga-1/+0
2021-02-23Put clean::Trait extra information into a new struct to make it more coherentGuillaume Gomez-4/+4
2021-02-23Remove is_spotlight field from `Trait`Guillaume Gomez-4/+5
2021-02-23Fix nitsGuillaume Gomez-8/+4
2021-02-23Add --generate-redirect-map option to replace HTML redirection file with a ↵Guillaume Gomez-12/+49
unique JSON map
2021-02-22Rollup merge of #82351 - notriddle:docs-meta-description, r=jyn514Yuki Okushi-1/+4
Use the first paragraph, instead of cookie-cutter text, for rustdoc descriptions Partially addresses #82283.
2021-02-20Revert changes to all.htmlMichael Howell-6/+1
This code wasn't actually working, and trying to SEO optimize that page is pointless anyway.
2021-02-20Use the first paragraph, instead of cookie-cutter text, for rustdoc descriptionsMichael Howell-2/+10
Fixes #82283
2021-02-20Don't render [src] link on dummy spansGuillaume Gomez-0/+3
2021-02-16Make `Clean` take &mut DocContextJoshua Nelson-1/+1
- Take `FnMut` in `rustc_trait_selection::find_auto_trait_generics` - Take `&mut DocContext` in most of `clean` - Collect the iterator in auto_trait_impls instead of iterating lazily; the lifetimes were really bad. - Changes `fn sess` to properly return a borrow with the lifetime of `'tcx`, not the mutable borrow.
2021-02-08Auto merge of #81313 - LeSeulArtichaut:revert-32558, r=jyn514bors-7/+6
Restore linking to itself in implementors section of trait page Reverts #32558 as proposed in [this Zulip discussion](https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/Trait.20implementation.20self-links/near/223773273) r? `@jyn514` cc `@camelid`
2021-02-06Restore linking to itself in implementors section of trait pageLeSeulArtichaut-7/+6
2021-02-05Remove Function all_types and ret_types fieldsGuillaume Gomez-1/+1
2021-01-30Balance sidebar `Deref` cycle check with main contentJ. Ryan Stinnett-7/+11
The `Deref` cycle checks added as part of #80653 were "unbalanced" in the sense that the main content code path checks for cycles _before_ descending, while the sidebar checks _after_. Checking _before_ is correct, so this changes the sidebar path to match the main content path.
2021-01-30rustdoc tweakingbors-338/+361
* Reuse memory * simplify `next_def_id`, avoid multiple hashing and unnecessary lookups * remove `all_fake_def_ids`, use the global map instead (probably not a good step toward parallelization, though...) * convert `add_deref_target` to iterative implementation * use `ArrayVec` where we know the max number of elements * minor touchups here and there * avoid building temporary vectors that get appended to other vectors At most places I may or may not be doing the compiler's job is this PR.
2021-01-28Fix rustdoc page title text selectionKasper-32/+32
2021-01-27More cleanupGuillaume Gomez-5/+2
2021-01-27Unify cache usage and improve namingGuillaume Gomez-11/+12
2021-01-27Update to new rustdoc APIsGuillaume Gomez-1/+1
2021-01-27Remove cache usage wherever possibleGuillaume Gomez-22/+27
2021-01-27Remove CACHE_KEY globalGuillaume Gomez-273/+279
2021-01-24Rollup merge of #81302 - LeSeulArtichaut:80777-trait-render, r=jyn514Jonas Schievink-30/+21
Fix rendering of stabilization version for trait implementors Rustdoc compares an item's stabilization version with its parent's to not render it if they are the same. Here, the implementor was compared with itself, resulting in the stabilization version never getting shown. This probably needs a test. Fixes #80777. r? `@jyn514`
2021-01-23Fix rendering of stabilization version for trait implementorsLeSeulArtichaut-4/+4
2021-01-23Rollup merge of #81275 - jyn514:time-render, r=wesleywiserJonas Schievink-0/+4
Fix <unknown> queries and add more timing info to render_html Closes https://github.com/rust-lang/rust/issues/81251. ## Fix `<unknown>` queries This happened because `alloc_query_strings` was never called. ## Add more timing info to render_html This still has some issues I'm not sure how to work out: - `create_renderer` and `renderer_after_krate` aren't shown by default. I want something like `verbose_generic_activity_with_arg`, but it doesn't exist. I'm also not sure how to show activities that aren't on by default - I tried `-Z self-profile -Z self-profile-args=all`, but it didn't show up. r? `@wesleywiser`
2021-01-23Cleanup `render_stability_since_raw` to remove code duplicationLeSeulArtichaut-26/+17
2021-01-23Add more timing info to render_htmlJoshua Nelson-0/+4
- Show `create_renderer` and `renderer_after_crate` by default - Don't rewrite `extra_verbose_generic_activity`
2021-01-22Rollup merge of #81227 - CraftSpider:struct-type-clean, r=jyn514Mara Bos-7/+7
Remove doctree::StructType Also removes it from the Union type, as unions can only ever be 'Plain'. Adds a new StructType to JSON, 'union', as the easiest way to encode the type of a union there. This leaves only one item in doctree, `Module`. r? `@jyn514`
2021-01-21Fix rustc::internal lints on rustdocJoshua Nelson-2/+1
2021-01-21Rollup merge of #81184 - jyn514:combine-after, r=CraftSpiderYuki Okushi-12/+15
Remove unnecessary `after_run` function It's called at the same time and in the same place as `after_krate`, so they can be combined.
2021-01-20Remove StructType entirely and replace it with CtorKindRune Tynan-6/+7
2021-01-20Move StructType to clean, remove it from Unions, make JSON output whether ↵Rune Tynan-7/+6
something is a union
2021-01-19Remove unnecessary `after_run` functionJoshua Nelson-12/+15
It's called at the same time and in the same place as `after_krate`, so they can be combined.
2021-01-18Remove inline script tagsGuillaume Gomez-5/+2
2021-01-15Rename VariantKind -> VariantJoshua Nelson-6/+6
There's no `Variant`, so it seems silly to have `Kind`.
2021-01-15Remove useless `clean::Variant` structJoshua Nelson-13/+10
It had exactly one field and no special behavior, so there was no point.
2021-01-09Replace under-used ImplPolarity enum with a booleanGuillaume Gomez-8/+3
2021-01-08Combine several `push_str` callsJ. Ryan Stinnett-4/+3
2021-01-08Use target in `Deref` method section IDsJ. Ryan Stinnett-40/+51
There can now be multiple `Deref` method sections, so this adds the target type to the section ID to ensure they are unique.
2021-01-08Recursively document methods via `Deref` traitsJ. Ryan Stinnett-3/+33
2021-01-04Extract `sidebar_deref_methods` functionJ. Ryan Stinnett-52/+52
2021-01-04Auto merge of #80661 - jyn514:duplicate-types, r=GuillaumeGomezbors-0/+3
Cleanup rustdoc handling of associated types This is best reviewed a commit at a time. No particular reason for these changes, they just stood out as I was reviewing https://github.com/rust-lang/rust/pull/80653 and thinking about https://github.com/rust-lang/rust/issues/80379. The new test case worked before, it just wasn't tested. r? `@GuillaumeGomez`
2021-01-03Simplify rustdoc handling of type aliases for associated typesJoshua Nelson-0/+3
The logic was very hard to follow before.
2021-01-02Improve code for DocFragment reworkGuillaume Gomez-6/+2
2021-01-02End of rework of Attributes structGuillaume Gomez-8/+7
2021-01-01clippy fixes for librustdocMatthias Krüger-7/+9
fixes clippy warnings of type: match_like_matches_macro or_fun_call op_ref needless_return let_and_return single_char_add_str useless_format unnecessary_sort_by match_ref_pats redundant_field_names