about summary refs log tree commit diff
path: root/src/librustdoc/html/render/mod.rs
AgeCommit message (Collapse)AuthorLines
2022-07-08add opt in attribute for stable-in-unstable itemsJane Lusby-1/+1
2022-07-07Rollup merge of #99017 - GuillaumeGomez:rustdoc-ending-enum, r=notriddleMatthias Krüger-4/+4
Replace boolean argument for print_where_clause with an enum to make code more clear As you suggested ``@notriddle.`` Just not sure if the naming seems good to you? r? ``@notriddle``
2022-07-07Replace boolean argument for print_where_clause with an enum to make code ↵Guillaume Gomez-4/+4
more clear
2022-07-07Rollup merge of #98973 - GuillaumeGomez:inherent-impl-anchors, r=notriddleDylan DPC-4/+16
Remove (unused) inherent impl anchors This is something `@notriddle` realized a few days ago: we have unused anchors in the DOM. This PR removes them. You can test it [here](https://rustdoc.crud.net/imperio/inherent-impl-anchors/foo/index.html). r? `@notriddle`
2022-07-06Don't generate anchors on inherent impl methodsGuillaume Gomez-4/+16
2022-07-05Fix link generation in the sidebar for implsGuillaume Gomez-15/+12
2022-07-05rustdoc: Add more semantic information to impl idspierwill-25/+8
Instead of generating `#impl`, `#impl-1`, etc., generate IDs like `#impl-Foo<M>`. Co-authored-by: Noah Lev <camelidcamel@gmail.com>
2022-07-04Rollup merge of #98814 - fmease:minimal-fix-for-issue-97933, r=GuillaumeGomezMatthias Krüger-1/+3
rustdoc: Censor certain complex unevaluated const exprs Fixes #97933. This is more of a hotfix for the aforementioned issue. By that, I mean that my proposed patch is not the best solution but one that does not change as much existing code. It treats symptoms rather than the root cause. This PR “censors” certain complex unevaluated constant expressions like `match`es, blocks, function calls, struct literals etc. by pretty-printing them as `_` / `{ _ }` (number and string literals, paths and `()` are still printed as one would expect). Resorting to this placeholder is preferable to printing the full expression verbatim since they can be quite large and verbose resulting in an unreadable mess in the generated documentation. Further, mindlessly printing the const would leak private and `doc(hidden)` struct fields (#97933), at least in the current stable & nightly implementations which rely on `span_to_snippet` (!) and `rustc_hir_pretty::id_to_string`. The censoring of _verbose_ expressions is probably going to stay longer term. However, in regards to private and `doc(hidden)` struct fields, I have a more proper fix in mind which I have already partially implemented locally and for which I am going to open a separate PR sometime soon. For that, I was already in contact with `@GuillaumeGomez.` The proper fix involves rustdoc not falling back on pretty-printing unevaluated consts so easily (what this PR is concerned about) and instead preferring to print evaluated consts which contain more information allowing it to selectively hide private and `doc(hidden)` fields, create hyperlinks etc. generally making the output more granular and precise (compared to the brutal `_` placeholder). Unfortunately, I was a bit too late and the issue just hit stable (1.62). Should this be backported to beta or even a potential 1.62.1? r? `@GuillaumeGomez`
2022-07-04rustdoc: censor certain complex unevaluated const exprsLeón Orell Valerian Liehr-1/+3
2022-06-27Put back, fix ()-output optimizationMichael Howell-0/+1
2022-06-24rustdoc: reference function signature types from the `p` arrayMichael Howell-37/+44
This reduces the size of the function signature index, because it's common to have many functions that operate on the same types. $ wc -c search-index-old.js search-index-new.js 5224374 search-index-old.js 3932314 search-index-new.js By my math, this reduces the uncompressed size of the search index by 32%. On compressed signatures, the wins are less drastic, a mere 8%: $ wc -c search-index-old.js.gz search-index-new.js.gz 404532 search-index-old.js.gz 371635 search-index-new.js.gz
2022-06-20Improve loading of crates.js and sidebar-items.jsJacob Hoffman-Andrews-18/+1
Now that the "All Crates" dropdown is only rendered on the search results page, there is no need to load crates.js on most pages. Load it only on crate pages. Also, add the `defer` attribute so it does not block page rendering. For sidebar-items.js, move the script tag to `<head>`. Since it already has the defer attribute it won't block loading. The defer attribute does preserve ordering between scripts, so instead of the callback on load, it can set a global variable on load, which is slightly simpler. Also, since it is required to finish rendering the page, beginning its load earlier is better. Remove generation and handling of sidebar-vars. Everything there can be computed with information available in JS via other means. Remove the "other" wrapper in the sidebar. It was unnecessary. Remove excess script fields
2022-06-06Rollup merge of #90905 - GuillaumeGomez:empty-impl-blocks, r=jshaMatthias Krüger-0/+7
Add empty impl blocks if they have documentation Fixes https://github.com/rust-lang/rust/issues/90866. The update for the test script is needed to count the number of impl blocks we have with only the struct. To be noted that with https://github.com/rust-lang/rust/pull/89676 merged, it wouldn't be needed (I don't know what is the status of it btw. cc ```@Mark-Simulacrum).``` It looks like this: ![Screenshot from 2021-11-14 16-51-28](https://user-images.githubusercontent.com/3050060/141689100-e57123c0-bf50-4c42-adf5-d991e169a0e4.png) cc ```@jyn514``` r? ```@camelid```
2022-06-04Don't generate "Impls on Foreign Types" for stdJacob Hoffman-Andrews-3/+2
Hack: many traits and types in std are re-exported from core or alloc. In general, rustdoc is capable of recognizing these implementations as being on local types. However, in at least one case, rustdoc gets confused and labels an implementation as being on a foreign type. To make sure that confusion doesn't pass on to the reader, consider all implementations in std, core, and alloc to be on local types.
2022-06-02Rollup merge of #97613 - jsha:implementation-is-on-local-type, r=GuillaumeGomezYuki Okushi-3/+1
rustdoc: Improve calculation of "Impls on Foreign Types" The existing code to calculate whether an implementation was on a "Foreign Type" was duplicated across the sidebar generation and the page generation. It also came to the wrong conclusion for some cases where both the trait and the "for" type were re-exports. This PR extracts the logic into a method of `Impl`, breaks it into a multi-line method so it can be commented, and adds a case for when the trait and the "for" type came from the same crate. This fixes some cases - like the platform-specific integer types (`__m256`, `__m128`, etc). But it doesn't fix all cases. See the screenshots below. [Before](https://doc.rust-lang.org/nightly/std/clone/trait.Clone.html#foreign-impls): <img src="https://user-images.githubusercontent.com/220205/171338226-59ce6daf-3d76-4bad-bc8d-72a8259a8f43.png" width=200> [After](https://rustdoc.crud.net/jsha/implementation-is-on-local-type/std/clone/trait.Clone.html): <img src="https://user-images.githubusercontent.com/220205/171338147-28308a65-1597-4223-be47-9550062404dd.png" width=200> The remaining types (`CString`, `NulError`, etc) are all from the `alloc` crate, while the `Clone` trait is from the `core` crate. Since `CString` and `Clone` are both re-exported by `std`, they are logically local to each other, but I couldn't figure out a good way to detect that in this code. I figure this is still a good step forward. Related: #97610 r? `@camelid`
2022-06-01Improve calculation of "Impls on Foreign Types"Jacob Hoffman-Andrews-3/+1
2022-05-31Display empty impl blocks if they have documentationsGuillaume Gomez-0/+7
2022-05-29Fix order of closing HTML elements in rustdoc outputJan-Erik Rediger-1/+1
2022-05-27Pass Context as a &mut to allow to remove RefCell fieldsGuillaume Gomez-30/+28
2022-05-24fix clippy perf lintsklensy-1/+3
2022-05-24fix simple clippy lintsklensy-4/+4
2022-05-21Remove fields_stripped fields (and equivalents)Guillaume Gomez-2/+1
2022-05-21Remove `crate` visibility modifier in libs, testsJacob Pratt-22/+22
2022-05-09Auto merge of #95960 - jhpratt:remove-rustc_deprecated, r=compiler-errorsbors-2/+2
Remove `#[rustc_deprecated]` This removes `#[rustc_deprecated]` and introduces diagnostics to help users to the right direction (that being `#[deprecated]`). All uses of `#[rustc_deprecated]` have been converted. CI is expected to fail initially; this requires #95958, which includes converting `stdarch`. I plan on following up in a short while (maybe a bootstrap cycle?) removing the diagnostics, as they're only intended to be short-term.
2022-05-06Fix reexports missing from the search indexGuillaume Gomez-1/+10
2022-04-30Move settings into full JSGuillaume Gomez-128/+0
2022-04-16Rename `def_id` into `item_id` when the type is `ItemId` for readabilityGuillaume Gomez-5/+5
2022-04-14Error on `#[rustc_deprecated]`Jacob Pratt-2/+2
2022-04-13Rollup merge of #93217 - willcrichton:example-analyzer, r=GuillaumeGomezDylan DPC-1/+35
Improve Rustdoc UI for scraped examples with multiline arguments, fix overflow in line numbers This PR improves a few aspects of the scrape examples feature in Rustdoc. * Only function names and not the full call expression are highlighted. * For call-sites with multiline arguments, the minimized code viewer will scroll to the top of the call-site rather than the middle if the argument is larger than the viewer size, ensuring that the function name is visible. * This fixes an issue where the line numbers column had a visible x-scroll bar. r? `@GuillaumeGomez`
2022-04-12Add Rustdoc book link to scrape examples help. Remove remaining panicWill Crichton-3/+9
locations in scrape examples.
2022-04-12rustdoc: discr. required+provided assoc consts+tysLeón Orell Valerian Liehr-90/+157
2022-04-06Switch item-info div to span to generate valid HTMLGuillaume Gomez-3/+3
2022-04-05Generate a <div> instead of a <span> for item-info elementsGuillaume Gomez-1/+1
2022-04-03Rollup merge of #95613 - GuillaumeGomez:fix-rustdoc-attr-display, r=notriddleDylan DPC-1/+6
Fix rustdoc attribute display Fixes #81482. r? `@notriddle`
2022-04-03Fix display of attributes in rustdocGuillaume Gomez-1/+6
2022-03-30Only show associated consts from inherent impls in sidebarJules Bertholet-0/+1
2022-03-29Remove header field from clean::FunctionGuillaume Gomez-4/+3
2022-03-27Add scrape examples help pageWill Crichton-3/+26
2022-03-27Fix markdown issue, remove hard-coded rust-lang.org urlWill Crichton-1/+3
2022-03-27Improve alignment of additional scraped examples, add scrape examples help pageWill Crichton-0/+2
2022-03-27Only highlight identifier in scraped examples, not argumentsWill Crichton-29/+4
2022-03-27Improve Rustdoc UI for scraped examples with multiline arguments, fixWill Crichton-3/+29
overflow in line numbers
2022-03-16resolve the conflict in compiler/rustc_session/src/parse.rscodehorseman-1/+1
Signed-off-by: codehorseman <cricis@yeah.net>
2022-03-14Auto merge of #94139 - est31:let_else_rustdoc, r=notriddlebors-10/+2
librustdoc: adopt let else in more places Continuation of #89933, #91018, #91481, #93046, #93590, #94011. I have extended my clippy lint to also recognize tuple passing and match statements. The diff caused by fixing it is way above 1 thousand lines. Thus, I split it up into multiple pull requests to make reviewing easier. This PR handles librustdoc.
2022-03-11Collapse Blanket Implementations and Auto-trait implementations by defaultGuillaume Gomez-5/+11
2022-03-08Unify inherent impl blocks by wrapping them into a divGuillaume Gomez-6/+10
2022-03-04librustdoc: adopt let else in more placesest31-10/+2
2022-02-27make GATs print properly in traitsMichael Goulet-18/+39
2022-02-27move method out of nestingMichael Goulet-89/+90
2022-02-27Correctly generate links in the sidebar for implsGuillaume Gomez-7/+10