about summary refs log tree commit diff
path: root/src/librustdoc/html
AgeCommit message (Collapse)AuthorLines
2021-11-24Rollup merge of #91179 - GuillaumeGomez:a-color, r=jshaGuillaume Gomez-0/+6
Fix more <a> color Fixes #91175. Another bug I saw is: ![Screenshot from 2021-11-24 11-41-27](https://user-images.githubusercontent.com/3050060/143239845-f173cfeb-8f5c-4215-a5af-b71d4e1bcd84.png) I fixed it as well. r? ``@jsha``
2021-11-24Rollup merge of #91075 - jsha:chill-item-info, r=GuillaumeGomezGuillaume Gomez-20/+2
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-9/+11
2021-11-24Return the actual `DefId` for assoc. items in `register_res`Noah Lev-1/+12
Before, if `register_res` were called on an associated item or enum variant, it would return the parent's `DefId`. Now, it returns the actual `DefId`. This change is a step toward removing `Type::ResolvedPath.did` and potentially removing `kind_side_channel` in rustdoc. It also just simplifies rustdoc's behavior.
2021-11-24Fix clicking on anchors inside summary tags.Jacob Hoffman-Andrews-1/+1
2021-11-24Fix more <a> colorGuillaume Gomez-0/+6
2021-11-23Preload the most commonly used fonts.Jacob Hoffman-Andrews-0/+6
Don't preload italic font faces because they aren't used on all pages, and when they are used, they are used sparingly so it's okay if they are slower to load.
2021-11-23Fix RustDocEsteban Kuber-1/+1
2021-11-23Rollup merge of #91103 - jsha:non-toggle-click-doesnt-toggle, ↵Matthias Krüger-0/+8
r=Manishearth,GuillaumeGomez Inhibit clicks on summary's children A byproduct of using `<details>` and `<summary>` to show/hide detailed documentation was that clicking any part of a method heading (or impl heading) would show or hide the documentation. This was not super noticeable because clicking a link inside the method heading would navigate to that link. But clicking any unlinked black text in a method heading would trigger the behavior. That behavior was somewhat unexpected, and means that if you try to click a type name in a method heading, but miss by a few pixels, you get a confusing surprise. This change inhibits that behavior by putting an event listener on most summaries that cancels the event unless the event target was the summary itself. In practice, that means it cancels the event unless the target was the "[+]" / "[-]", because the rest of the heading is wrapped inside a `<div>`, which is the target for anything that doesn't have a more specific target. r? ``@Manishearth``
2021-11-22Rollup merge of #91102 - jsha:theme-anchor, r=GuillaumeGomezMatthias Krüger-28/+39
Set color for <a> in a more straightforward way. Previously, we set the default color for <a> tags to black, and then had an override with a bunch of not() clauses to set anchors in docblocks to blue. Instead, we should set the default color for <a> to blue (or equivalent in other themes), and override it for places like the sidebar or search results, where we don't want them to be styled as links. Demo at https://rustdoc.crud.net/jsha/theme-anchor/std/string/struct.String.html. This should result in no visible changes. r? `@GuillaumeGomez`
2021-11-22Auto merge of #91099 - jsha:cleanup-undocumented, r=GuillaumeGomezbors-33/+4
Remove styles for details.undocumented The Rust code that generated tags with that class was deleted in 10bafe1975e53769180701508e2b8cd3a3b34a0e. r? `@GuillaumeGomez`
2021-11-22Add GUI test for clicking on non-toggle summaryJacob Hoffman-Andrews-1/+1
2021-11-22Set color for <a> in a more straightforward wayJacob Hoffman-Andrews-28/+39
Previously, we set the default color for <a> tags to black, and then had an override with a bunch of not() clauses to set anchors in docblocks to blue. Instead, we should set the default color for <a> to blue (or equivalent in other themes), and override it for places like the sidebar or search results, where we don't want them to be styled as links.
2021-11-22Auto merge of #90872 - ken-matsui:add-defer-to-rustdoc-template, r=jshabors-10/+10
Move `scripts` on the rustdoc template into `head` and apply the `defer` attribute Closes https://github.com/rust-lang/rust/issues/90719
2021-11-21Inhibit clicks on summary's childrenJacob Hoffman-Andrews-0/+8
A byproduct of using `<details>` and `<summary>` to show/hide detailed documentation was that clicking any part of a method heading (or impl heading) would show or hide the documentation. This was not super noticeable because clicking a link inside the method heading would navigate to that link. But clicking any unlinked black text in a method heading would trigger the behavior. That behavior was somewhat unexpected, and means that if you try to click a type name in a method heading, but miss by a few pixels, you get a confusing surprise. This change inhibits that behavior by putting an event listener on most summaries that cancels the event unless the event target was the summary itself. In practice, that means it cancels the event unless the target was the "[+]" / "[-]", because the rest of the heading is wrapped inside a `<div>`, which is the target for anything that doesn't have a more specific target.
2021-11-20Remove styles for details.undocumentedJacob Hoffman-Andrews-33/+4
The Rust code that generated tags with that class was deleted in 10bafe1975e53769180701508e2b8cd3a3b34a0e.
2021-11-21Auto merge of #91073 - camelid:small-cleanups, r=jyn514bors-2/+2
rustdoc: Make two small cleanups
2021-11-20Move `scripts` on the rustdoc template into `head` and apply the `defer` ↵Ken Matsui-10/+10
attribute
2021-11-20Rollup merge of #90983 - GuillaumeGomez:sidebar-scrollbar, r=jshaMatthias Krüger-4/+4
Make scrollbar in the sidebar always visible for visual consistency Fixes #90943. I had to add a background in `dark` and `ayu` themes, otherwise it was looking strange (like an invisible margin). So it looks like this: ![Screenshot from 2021-11-17 14-45-49](https://user-images.githubusercontent.com/3050060/142212476-18892ae0-ba4b-48e3-8c0f-4ca1dd2f851d.png) ![Screenshot from 2021-11-17 14-45-53](https://user-images.githubusercontent.com/3050060/142212482-e97b2fad-68d2-439a-b62e-b56e6ded5345.png) Sadly, I wasn't able to add a GUI test to ensure that the scrollbar was always displayed because it seems not possible in puppeteer for whatever reason... I used this method: on small pages (like `lib2/sub_mod/index.html`), comparing `.navbar`'s `clientWidth` with `offsetWidth` (the first doesn't include the sidebar in the computed amount). When checking in the browser, it works fine but in puppeteer it almost never works... In case anyone want to try to solve the bug, here is the puppeteer code: <details> More information about this: I tried another approach which was to get the element in `evaluate` directly (by calling it from `page.evaluate(() => { .. });` directly instead of `parseAssertElemProp.evaluate(e => {...});`. ```js const puppeteer = require('puppeteer'); (async () => { const browser = await puppeteer.launch(); const page = await browser.newPage(); await page.goto("file:///path/rust/build/x86_64-unknown-linux-gnu/test/rustdoc-gui/doc/lib2/sub_mod/index.html"); await page.waitFor(".sidebar"); let parseAssertElemProp = await page.$(".sidebar"); if (parseAssertElemProp === null) { throw '".sidebar" not found'; } await parseAssertElemProp.evaluate(e => { const parseAssertElemPropDict = {"clientWidth": "192", "offsetWidth":"200"}; for (const [parseAssertElemPropKey, parseAssertElemPropValue] of Object.entries(parseAssertElemPropDict)) { if (e[parseAssertElemPropKey] === undefined || String(e[parseAssertElemPropKey]) != parseAssertElemPropValue) { throw 'expected `' + parseAssertElemPropValue + '` for property `' + parseAssertElemPropKey + '` for selector `.sidebar`, found `' + e[parseAssertElemPropKey] + '`'; } } }).catch(e => console.error(e)); await browser.close(); })(); ``` </details> r? ``@jsha``
2021-11-20Reduce prominence of item-infosJacob Hoffman-Andrews-20/+2
- 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-26/+27
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-18rustdoc: Avoid using `Iterator::count()` where possibleNoah Lev-1/+1
`count()` iterates over the whole collection. Using `len()` instead, or `.next().is_none()` when comparing to zero, should be faster.
2021-11-17Make scrollbar in the sidebar always visible for visual consistencyGuillaume Gomez-4/+4
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>
2021-11-10Remove potential useless data for search indexGuillaume Gomez-39/+46
2021-11-07rustdoc: Remove top-level wrappers for `ImplKind` methodsNoah Lev-7/+7
The `ImplKind` methods can just be used directly instead.
2021-11-07rustdoc: Use `ty::ImplPolarity` instead of custom enumNoah Lev-6/+8
2021-11-07Use an enum to record polarity in `clean::Impl`Noah Lev-8/+9
2021-11-07rustdoc: Refactor `Impl.{synthetic,blanket_impl}` into enumNoah Lev-9/+8
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-05Auto merge of #90583 - willcrichton:example-analyzer, r=jyn514bors-1/+7
Fix ICE when rustdoc is scraping examples inside of a proc macro This PR provides a clearer semantics for how --scrape-examples interacts with macros. If an expression's span AND it's enclosing item's span both are not `from_expansion`, then the example will be scraped. The added test case `rustdoc-scrape-examples-macros` shows a variety of situations. * A macro-rules macro that takes a function call as input: good * A macro-rules macro that generates a function call as output: bad * A proc-macro that generates a function call as output: bad * An attribute macro that generates a function call as output: bad * An attribute macro that takes a function call as input: good, if the proc macro is designed to propagate the input spans I ran this updated rustdoc on pyo3 and confirmed that it successfully scrapes examples from inside a proc macro, eg <img width="1013" alt="Screen Shot 2021-11-04 at 1 11 28 PM" src="https://user-images.githubusercontent.com/663326/140412691-81a3bb6b-a448-4a1b-a293-f7a795553634.png"> (cc `@mejrs)` Additionally, this PR fixes an ordering bug in the highlighting logic. Fixes https://github.com/rust-lang/rust/issues/90567. r? `@jyn514`
2021-11-05rustdoc: use Type::def_id() instead of Type::def_id_no_primitives()Muhammad Falak R Wani-22/+28
Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com>
2021-11-05Rollup merge of #90571 - GuillaumeGomez:missing-bottom-border-sidebar, r=jshaYuki Okushi-3/+9
Fix missing bottom border for headings in sidebar Fixes #90568. r? ```@jsha```
2021-11-04Sort scraped call locations before serializingWill Crichton-1/+7
2021-11-04Fix missing bottom border for headings in sidebarGuillaume Gomez-3/+9
2021-11-03Auto merge of #90475 - camelid:docvisitor, r=notriddlebors-36/+40
rustdoc: Add `DocVisitor` and use it where possible `DocFolder` allows transforming the docs, accomplished by making its methods take and return types by-value. However, several of the rustdoc `DocFolder` impls only *visit* the docs; they don't change anything. Passing around types by-value is thus unnecessary, confusing, and potentially inefficient for those impls. `DocVisitor` is very similar to `DocFolder`, except that its methods take shared references and return nothing (i.e., the unit type). This should both be more efficient and make the code clearer. There is an additional reason to add `DocVisitor`, too. As part of my cleanup of `external_traits`, I'm planning to add a `fn cache(&mut self) -> &mut Cache` method to `DocFolder` so that `external_traits` can be retrieved explicitly from the `Cache`, rather than implicitly via `Crate.external_traits` (which is an `Rc<RefCell<...>>`). However, some of the `DocFolder` impls that could be turned into `DocVisitor` impls only have a shared reference to the `Cache`, because they are used during rendering. (They have to access the `Cache` via `html::render::Context.shared.cache`, which involves an `Rc`.) Since `DocVisitor` does not mutate any of the types it's visiting, its equivalent `cache()` method will only need a shared reference to the `Cache`, avoiding the problem described above. r? `@GuillaumeGomez` cc `@jyn514`
2021-11-02Add line number to URLs in "additional examples" section of rustdocWill Crichton-13/+20
2021-11-02Fix URL for scrape-examples.js in rustdoc page templateWill Crichton-3/+3
2021-10-31rustdoc: Small micro-optimizations and cleanupsNoah Lev-7/+8
* Flip conjuncts of `&&` in rustdoc The `CrateNum` comparison should be very cheap, while `span.filename()` fetches and clones a `FileName`. * Use `into_local_path()` instead of `local_path().clone()`
2021-10-31Fix FIXMEs in `rustdoc::html::sources`Noah Lev-5/+6
One of the FIXMEs is irrelevant since that code is only run if `include_sources` is set. I fixed the other FIXME.
2021-10-31Clean up now that visitors only need `&clean::Crate`Noah Lev-15/+15
2021-10-31rustdoc: Use `DocVisitor` for sources collectionNoah Lev-12/+14