about summary refs log tree commit diff
path: root/src/librustdoc/html/render/mod.rs
AgeCommit message (Collapse)AuthorLines
2021-11-27Rollup merge of #91062 - jsha:static-file-replace, r=jyn514,GuillaumeGomezMatthias Krüger-23/+15
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-2/+2
At last! The new name is shorter, simpler, and consistent with `hir::Ty`.
2021-11-25Stop re-exporting `Type::ResolvedPath`Noah Lev-1/+1
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-3/+3
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-24Simplify rendering of stylesheet links into HTMLJacob Hoffman-Andrews-23/+15
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-3/+3
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-1/+1
2021-11-14Auto merge of #90883 - matthiaskrgr:rollup-iu9k5pe, r=matthiaskrgrbors-12/+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-1/+1
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-12/+7
2021-11-07rustdoc: Remove top-level wrappers for `ImplKind` methodsNoah Lev-4/+4
The `ImplKind` methods can just be used directly instead.
2021-11-07rustdoc: Use `ty::ImplPolarity` instead of custom enumNoah Lev-4/+5
2021-11-07Use an enum to record polarity in `clean::Impl`Noah Lev-6/+6
2021-11-07rustdoc: Refactor `Impl.{synthetic,blanket_impl}` into enumNoah Lev-6/+5
This change has two advantages: 1. It makes the possible states clearer, and it makes it impossible to construct invalid states, such as a blanket impl that is also an auto trait impl. 2. It shrinks the size of `Impl` a bit, since now there is only one field, rather than two.
2021-11-05rustdoc: use Type::def_id() instead of Type::def_id_no_primitives()Muhammad Falak R Wani-1/+1
Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com>
2021-11-02Add line number to URLs in "additional examples" section of rustdocWill Crichton-13/+20
2021-10-30Rollup merge of #90183 - GuillaumeGomez:recurse-deref, r=jyn514Guillaume Gomez-16/+78
Show all Deref implementations recursively Fixes #87783. This is a re-implementation of #80653, so taking the original PR comment: This changes `rustdoc` to recursively follow `Deref` targets so that methods from all levels are added to the rendered output. This implementation displays the methods from all levels in the expanded state with separate sections for each level. ![image](https://user-images.githubusercontent.com/279572/103482863-46723b00-4ddb-11eb-972b-c463351a425c.png) cc `@camelid` r? `@jyn514`
2021-10-30Rollup merge of #90412 - jyn514:macro-use, r=camelidMatthias Krüger-0/+1
Remove unnecessary `macro_use`s in rustdoc
2021-10-30Remove unnecessary `macro_use`s in rustdocJoshua Nelson-0/+1
2021-10-29Fix invalid handling of genericsGuillaume Gomez-1/+2
2021-10-29Don't display "Methods from Deref<...>" if no method is display (the ones ↵Guillaume Gomez-3/+9
which don't have `self` argument)
2021-10-29Recursively document DerefGuillaume Gomez-13/+69
2021-10-27Auto merge of #90186 - jsha:fix-header-sizes, r=GuillaumeGomezbors-1/+1
Fix documentation header sizes And add a rustdoc-gui test confirming various header sizes. Split off from #90156. This fixes a regression in #89506 where the heading level of titles within Markdown was too high (h2) for docblocks under structs, unions, and enum impls. r? `@camelid` Demo: https://jacob.hoffman-andrews.com/rust/fix-header-sizes/std/string/struct.String.html#impl-Add%3C%26%27_%20str%3E Stable: https://doc.rust-lang.org/stable/std/string/struct.String.html#impl-Add%3C%26%27_%20str%3E Beta: https://doc.rust-lang.org/beta/std/string/struct.String.html#impl-Add%3C%26%27_%20str%3E
2021-10-27Rollup merge of #90154 - camelid:remove-getdefid, r=jyn514Matthias Krüger-11/+8
rustdoc: Remove `GetDefId` See the individual commit messages for details. r? `@jyn514`
2021-10-25Fix documentation header sizesJacob Hoffman-Andrews-1/+1
And add a rustdoc-gui test confirming various header sizes.
2021-10-25Fix clippy lints in librustdocGuillaume Gomez-19/+18
2021-10-23Rollup merge of #85833 - willcrichton:example-analyzer, r=jyn514Matthias Krüger-2/+236
Scrape code examples from examples/ directory for Rustdoc Adds support for the functionality described in https://github.com/rust-lang/rfcs/pull/3123 Matching changes to Cargo are here: https://github.com/rust-lang/cargo/pull/9525 Live demo here: https://willcrichton.net/example-analyzer/warp/trait.Filter.html#method.and
2021-10-22Move def_id logic into render_call_locationsWill Crichton-4/+3
2021-10-22Rename `Type::def_id_full()` to `Type::def_id()`Noah Lev-10/+7
It should be preferred over `def_id_no_primitives()`, so it should have a shorter name. I also put it before `def_id_no_primitives()` so that it shows up first in the docs.
2021-10-22Replace `GetDefId` with inherent methodsNoah Lev-1/+1
Now that it's only implemented for `Type`, using inherent methods instead means that imports are no longer necessary. Also, `GetDefId` is only meant to be used with `Type`, so it shouldn't be a trait.
2021-10-22Remove `GetDefId` impl for `FnRetTy`Noah Lev-1/+1
It was only used in one place, so it seems better to use ordinary functions.
2021-10-22Revert def_id addition from clean::Function, add test forWill Crichton-4/+3
scrape-examples options
2021-10-13Improve code readability for sidebar linksGuillaume Gomez-16/+48
2021-10-12List associated constants in the sidebarGuillaume Gomez-7/+38
2021-10-10Auto merge of #89695 - jsha:more-templates, r=GuillaumeGomezbors-0/+1
Move top part of print_item to Tera templates Part of #84419. This moves the first line of each item page (E.g. `Struct foo::Bar .... 1.0.0 [-][src]` into a Tera template. I also moved template initialization into its own module and added a small macro to reduce duplication and opportunity for errors.
2021-10-09Auto merge of #88379 - camelid:cleanup-clean, r=jyn514bors-67/+53
rustdoc: Cleanup various `clean` types Cleanup various `clean` types.
2021-10-08Move template initialization into its own file.Jacob Hoffman-Andrews-0/+1
2021-10-08Move more scrape-examples logic from JS to rustWill Crichton-18/+27
Fix failing test Add missing backslash Fix padding issue with horizontal scrollbar
2021-10-07Move some expansion logic into generation-time, fix section header links, ↵Will Crichton-23/+28
remove ID from line numbers, fix horizontal scrolling on non-expanded elements
2021-10-06Update to latest rustc and rustdoc stylesWill Crichton-3/+4
2021-10-06Change serialized format to use DefPathHash instead of custom StringWill Crichton-22/+19
Move test to rustdoc-ui Fix test writing to wrong directory Formatting Fix test Add FIXME Remove raw multiline strings
2021-10-06Incorporate jyn's feedbackWill Crichton-31/+46
* Move call location logic from function constructor to rendering * Fix issue with macro spans in scraping examples * Clean up example loading logic Documentation / newtype for DecorationInfo Fix line number display Serialize edition of call site, other small cleanup
2021-10-06Add styles for non-white themesWill Crichton-14/+14
Tweak colors Tabs New link heading style
2021-10-06Reduce blur size, fix example width bug, add better error handling for I/O ↵Will Crichton-16/+58
issues Remove repository url Fix formatting Fix file_span in print_src Formatting
2021-10-06Move highlighting logic from JS to RustWill Crichton-12/+29
Continue migrating JS functionality Cleanup Fix compile error Clean up the diff Set toggle font to sans-serif
2021-10-06Sort examples by sizeWill Crichton-18/+57
Improve styling Start to clean up code, add comments
2021-10-06Generate example source files with corresponding linksWill Crichton-41/+50
Add display name Fix remaining merge conflicts Only embed code for items containing examples
2021-10-06Factor scraping and rendering into separate calls to rustdocWill Crichton-2/+9
Simplify toggle UI logic, add workspace root for URLs