about summary refs log tree commit diff
path: root/src/librustdoc/html/render
AgeCommit message (Collapse)AuthorLines
2021-12-27Make `search_index` functions private where possibleNoah Lev-2/+2
Now the only two crate-public items are `build_index` and `get_index_search_type` (because for some reason the latter is also used in `formats::cache`).
2021-12-27Move `ExternalLocation` to `clean::types`Noah Lev-12/+2
It was previously defined in `render::search_index` but wasn't used at all there. `clean::types` seems like a better fit since that's where `ExternalCrate` is defined.
2021-12-27rustdoc: Remove some unnecessary `cache` parametersNoah Lev-23/+12
Based on https://github.com/rust-lang/rust/pull/80883#issuecomment-774437832. The `tcx` parameters do seem to be used though, so I only removed the `cache` parameters.
2021-12-27Rename `rustdoc::html::render::cache` to `search_index`Noah Lev-2/+2
The old name wasn't very clear, while the new one makes it clear that this is the code responsible for creating the search index.
2021-12-23Rollup merge of #92146 - willcrichton:example-analyzer, r=jyn514Matthias Krüger-6/+10
Don't emit shared files when scraping examples from dependencies in Rustdoc This PR fixes #91605. The issue is that `Context::init` gets called when scraping dependencies. By default, just calling `init` calls into `write_shared` and `build_index` which register the scraped crate into a list that later gets used for the Rustdoc sidebar. The fix is to ensure that `write_shared` is not called when scraping. r? `@jyn514`
2021-12-19Auto merge of #92099 - matthiaskrgr:rollup-4gwv67m, r=matthiaskrgrbors-11/+2
Rollup of 7 pull requests Successful merges: - #91141 (Revert "Temporarily rename int_roundings functions to avoid conflicts") - #91984 (Remove `in_band_lifetimes` from `rustc_middle`) - #92028 (Sync portable-simd to fix libcore build for AVX-512 enabled targets) - #92042 (Enable `#[thread_local]` for all windows-msvc targets) - #92071 (Update example code for Vec::splice to change the length) - #92077 (rustdoc: Remove unused `collapsed` field) - #92081 (rustdoc: Remove unnecessary `need_backline` function) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-12-19Auto merge of #91957 - nnethercote:rm-SymbolStr, r=oli-obkbors-25/+25
Remove `SymbolStr` This was originally proposed in https://github.com/rust-lang/rust/pull/74554#discussion_r466203544. As well as removing the icky `SymbolStr` type, it allows the removal of a lot of `&` and `*` occurrences. Best reviewed one commit at a time. r? `@oli-obk`
2021-12-18Remove `collapsed` fieldJoshua Nelson-11/+2
`render/context` always runs after `run_global_context`, so it was always set to `true`. This is a holdover from when rustdoc allowed configuring passes, but the `collapse-docs` pass was removed ages ago, and the ability to configure passes is about to be removed.
2021-12-17Auto merge of #91812 - camelid:assoc-const-lazy, r=GuillaumeGomezbors-12/+4
rustdoc: Pretty-print assoc const defaults on-demand This should improve performance, clean up the code, and help pave the way for #83035.
2021-12-15Remove unnecessary sigils around `Symbol::as_str()` calls.Nicholas Nethercote-18/+18
2021-12-15Remove `SymbolStr`.Nicholas Nethercote-7/+7
By changing `as_str()` to take `&self` instead of `self`, we can just return `&str`. We're still lying about lifetimes, but it's a smaller lie than before, where `SymbolStr` contained a (fake) `&'static str`!
2021-12-14fix clippy::single_char_pattern perf findingsMatthias Krüger-3/+3
2021-12-11rustdoc: Remove unused `_default` parameterNoah Lev-12/+4
It can always be re-added later if we decide to display associated const default values.
2021-12-11rustdoc: Pretty-print assoc const defaults on-demandNoah Lev-1/+1
This should improve performance, clean up the code, and help pave the way for #83035.
2021-12-11Don't emit shared files when scraping dependenciesWill Crichton-6/+10
2021-12-11Rollup merge of #91682 - camelid:alias-layout, r=jyn514Matthias Krüger-0/+1
rustdoc: Show type layout for type aliases Fixes #91265. At first, you might think, "Why not just click through to the aliased type?" But, if a type alias instantiates all of the generic parameters of the aliased type, then it can show layout info even though the aliased type cannot (because we can't compute layout for generic types). So, I think it's useful to show layout info for type aliases. This is a followup of 78d4b453ad2e19d44011b26fc55c949bff5dba3d (originally part of #83501).
2021-12-10Split CSS classes for "typedef" vs "associatedtype".Jacob Hoffman-Andrews-1/+1
2021-12-08rustdoc: Show type layout for type aliasesNoah Lev-0/+1
At first, you might think, "Why not just click through to the aliased type?" But, if a type alias instantiates all of the generic parameters of the aliased type, then it can show layout info even though the aliased type cannot (because we can't compute layout for generic types). So, I think it's useful to show layout info for type aliases. This is a followup of 78d4b453ad2e19d44011b26fc55c949bff5dba3d (originally part of #83501).
2021-12-08Rollup merge of #91534 - jsha:heading-color, r=GuillaumeGomezMatthias Krüger-1/+1
Make rustdoc headings black, and markdown blue Demo: https://rustdoc.crud.net/jsha/heading-color/std/string/index.html#structs https://rustdoc.crud.net/jsha/heading-color/std/string/struct.String.html#examples Fixes #91304 r? ```@camelid``` /cc ```@GuillaumeGomez``` (Note: we may want to make rustdoc headings and markdown headings the same color -- #90245 -- but we would want to do that intentionally; this is fixing up a change that did so accidentally)
2021-12-04Make rustdoc headings black, and markdown blueJacob Hoffman-Andrews-1/+1
2021-12-03Remove single-use `GenericParamDef::get_type` functionNoah Lev-13/+13
Rationale: * The name was confusing. * It was only used in one place. * That place didn't actually need all the functionality of `get_type`; rather, removing `get_type` makes that code clearer.
2021-12-02Auto merge of #91291 - GuillaumeGomez:const-deref-method, r=camelidbors-25/+77
Fix const deref methods display Fixes https://github.com/rust-lang/rust/issues/90855 (more information in the issue). r? `@camelid`
2021-12-01address reviewb-naber-1/+1
2021-12-01more fixed issuesb-naber-0/+7
2021-11-30Return ConstStability instead of &ConstStability in Item::const_stabilityGuillaume Gomez-2/+2
2021-11-30Improve code by replacing &str with Symbol in render_stability_since_rawGuillaume Gomez-15/+11
2021-11-30Fix display for "const" deref methods in rustdocGuillaume Gomez-14/+70
2021-11-29Only show notable traits if both types are the sameMichael Howell-1/+8
Checking only their DefId doesn't work because all slices have the same fake DefId. Fixes #91347
2021-11-27Rollup merge of #91062 - jsha:static-file-replace, r=jyn514,GuillaumeGomezMatthias Krüger-92/+50
rustdoc: Consolidate static-file replacement mechanism There were a few places in rustdoc where we would take static JS or CSS and rewrite it at doc generation time to insert values. This consolidates all the CSS instances into one CSS file and replaces the JS examples with data- attributes on the rustdoc-vars div. Demo https://rustdoc.crud.net/jsha/static-file-replace/test_docs/ r? ``@GuillaumeGomez``
2021-11-26Rename `Type::ResolvedPath` to `Type::Path`Noah Lev-16/+17
At last! The new name is shorter, simpler, and consistent with `hir::Ty`.
2021-11-25Stop re-exporting `Type::ResolvedPath`Noah Lev-15/+14
I would like to rename it to `Type::Path`, but then it can't be re-exported since the name would conflict with the `Path` struct. Usually enum variants are referred to using their qualified names in Rust (and parts of rustdoc already do that with `clean::Type`), so this is also more consistent with the language.
2021-11-25Auto merge of #91195 - camelid:path-did, r=jyn514bors-8/+9
rustdoc: Remove `ResolvedPath.did` `ResolvedPath.did` was not actually the same as `.path.def_id()`. Instead, `.did` referred to the `DefId` of the page to be used as a hyperlink target. For example, a link to `Struct::method()` would use `Struct`'s `DefId` as its `.did` field. This behavior is confusing, easy to accidentally misuse, and can instead be obtained on-demand when computing hyperlink targets. It's also likely part of the reason `kind_side_channel` exists. I'm currently working on some experimental refactorings in `collect_intra_doc_links` that I believe require -- or at least benefit from -- removing `.did`. r? `@jyn514`
2021-11-24Consistentize the system for image URLs in CSS.Jacob Hoffman-Andrews-28/+20
2021-11-24Move themes and version into rustdoc-varsJacob Hoffman-Andrews-32/+2
We had been injecting the list of themes and the rustdoc version into main.js by rewriting it at doc generation time. By avoiding this rewrite, we can make it easier to edit main.js without regenerating all the docs. Added a more convenient accessor for rustdoc-vars. Changed storage.js to not rely on resourcesSuffix. It could in theory use rustdoc-vars, but because rustdoc-vars is at the end of the HTML, it's not available when storage.js runs (very early in page load).
2021-11-24Simplify rendering of stylesheet links into HTMLJacob Hoffman-Andrews-32/+28
We carry around a list of stylesheets that can carry two different types of thing: 1. Internal stylesheets specific to a page type (only for settings) 2. Themes In this change I move the link generation for settings.css into settings(), so Context.style_files is reserved just for themes. We had two places where we extracted a base theme name from a list of StylePaths. I consolidated that code to be a method on StylePath. I moved generation of link tags for stylesheets into the page.html template. With that change, I made the template responsible for special handling of light.css (making it the default theme) and of the other themes (marking them disabled). That allowed getting rid of the `disabled` field on StylePath.
2021-11-24Rollup merge of #91075 - jsha:chill-item-info, r=GuillaumeGomezGuillaume Gomez-17/+1
Reduce prominence of item-infos Fixes #59853 - Remove border. - Reduce size of emoji slightly. - Remove details disclosure for unstable reason. This was inconsistent with our other details disclosures, and the detail revealed was usually better explained by clicking on the issue link. Demo: https://rustdoc.crud.net/jsha/chill-item-info/std/mem/union.MaybeUninit.html#method.slice_assume_init_ref Compare vs: https://doc.rust-lang.org/nightly/std/mem/union.MaybeUninit.html#method.slice_assume_init_ref <img src="https://user-images.githubusercontent.com/220205/142717815-09828c9e-6ff4-445a-8ccc-31e028fd4985.png" width=700>
2021-11-24Remove `ResolvedPath.did`Noah Lev-8/+9
2021-11-21Auto merge of #91073 - camelid:small-cleanups, r=jyn514bors-2/+2
rustdoc: Make two small cleanups
2021-11-20Reduce prominence of item-infosJacob Hoffman-Andrews-17/+1
- Remove border. - Reduce size of emoji slightly. - Remove details disclosure for unstable reason. This was inconsistent with our other details disclosures, and the detail revealed was usually better explained by clicking on the issue link.
2021-11-19rustdoc: Record aliases as SymbolsNoah Lev-2/+2
2021-11-20Rollup merge of #90089 - jsha:enum-fields-headings, r=camelid,GuillaumeGomezMatthias Krüger-13/+11
Improve display of enum variants Use h3 and h4 for the variant name and the "Fields" subheading. Remove the "of T" part of the "Fields" subheading. Remove border-bottom from "Fields" subheading. Move docblock below "Fields" listing. Fixes #90061 Demo: https://jacob.hoffman-andrews.com/rust/xmlparser-updated/xmlparser/enum.Token.html#variants https://jacob.hoffman-andrews.com/rust/fix-enum-variants/std/io/enum.ErrorKind.html#variants https://jacob.hoffman-andrews.com/rust/fix-enum-variants/std/result/enum.Result.html#variants r? ``@camelid``
2021-11-14Auto merge of #90757 - GuillaumeGomez:search-index-performance, r=camelidbors-4/+0
Remove unneeded FIXMEs comments in search index generation Original comment: > Instead of recreating a new `vec` for each arguments, we re-use the same. The impact on performance should be minor but worth a try. After testing it, we reached the conclusion that the code readability drop wasn't worth the almost unnoticeable performance improvement. r? `@camelid`
2021-11-14Auto merge of #90883 - matthiaskrgr:rollup-iu9k5pe, r=matthiaskrgrbors-13/+7
Rollup of 3 pull requests Successful merges: - #90771 (Fix trait object error code) - #90840 (relate lifetime in `TypeOutlives` bounds on drop impls) - #90853 (rustdoc: Use an empty Vec instead of Option<Vec>) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-11-13Auto merge of #90385 - mfrw:mfrw/librustdoc, r=GuillaumeGomezbors-13/+24
rustdoc: use Type::def_id() instead of Type::def_id_no_primitives() For: #90187 r? `@jyn514`
2021-11-12Use an empty Vec instead of Option<Vec>Michael Howell-13/+7
2021-11-12Rollup merge of #90795 - GuillaumeGomez:more-search-index-comments, r=notriddleMatthias Krüger-2/+13
Add more comments to explain the code to generate the search index Fixes #90766. I tried to put comments when the code wasn't easy to understand at first sight and added more documentation on the recursive function. Please tell me if I misused the terminology or if comments can be improved or added into other places. r? `@notriddle`
2021-11-12Add more comments to explain the code to generate the search indexGuillaume Gomez-2/+13
2021-11-12Remove unneeded FIXME: after testing the suggested changes, we reached the ↵Guillaume Gomez-4/+0
conclusion that the code readibility wasn't worth the almost unnoticeable perf improvement
2021-11-11Use `Iterator::collect` instead of calling `Vec::push` in a loopMichael Howell-23/+26
2021-11-11librustdoc: revert use of def_id for one of the edge caseMuhammad Falak R Wani-5/+10
Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com>