about summary refs log tree commit diff
path: root/src/librustdoc/html
AgeCommit message (Collapse)AuthorLines
2021-12-01more fixed issuesb-naber-0/+7
2021-11-30Return ConstStability instead of &ConstStability in Item::const_stabilityGuillaume Gomez-6/+3
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-29rustdoc: show logo in source sub navcynecx-40/+87
2021-11-29rustdoc: rework source sidebarcynecx-47/+57
2021-11-29rustdoc: fix tabs in csscynecx-5/+5
2021-11-29rustdoc: don't use overflow for main, instead make the sidebar stickycynecx-16/+14
2021-11-29rustdoc: make source sidebar collapse by defaultcynecx-1/+1
2021-11-29rustdoc: fix theme colorscynecx-3/+3
2021-11-29rustdoc: merge source sidebar into main sidebarcynecx-51/+41
2021-11-29rustdoc: fix source viewcynecx-11/+61
2021-11-29rustdoc: use flexbox to layout sidebar and main contentcynecx-81/+80
2021-11-27Rollup merge of #91062 - jsha:static-file-replace, r=jyn514,GuillaumeGomezMatthias Krüger-129/+112
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-26Rollup merge of #91223 - GuillaumeGomez:headings-indent, r=jshaMatthias Krüger-4/+6
Fix headings indent Fixes #91200. Screenshots with the fix: ![Screenshot from 2021-11-25 15-32-35](https://user-images.githubusercontent.com/3050060/143462481-f7e9ea13-72d5-46fe-90e0-9527e74599e3.png) ![Screenshot from 2021-11-25 15-32-49](https://user-images.githubusercontent.com/3050060/143462485-c010716a-0276-421b-a777-afff19c81c96.png) If the first element of a top docblock is a heading, we still need to keep the indent, but only on this one (I added a test to check it). We need it because otherwise the anchor will go over the `[-]` toggle. cc `@camelid` r? `@jsha`
2021-11-26Rollup merge of #91197 - camelid:rename-resolvedpath, r=GuillaumeGomez,jyn514Matthias Krüger-11/+10
rustdoc: Rename `Type::ResolvedPath` to `Type::Path` and don't re-export it The new name is shorter, simpler, and consistent with `hir::Ty`. It can't be re-exported since the name would conflict with the `clean::Path` struct. But usually enum variants are referred to using their qualified names in Rust anyway (and parts of rustdoc already do that with `clean::Type`), so this is also more consistent with the language. r? `@GuillaumeGomez` cc `@jyn514`
2021-11-26Rename `Type::ResolvedPath` to `Type::Path`Noah Lev-19/+19
At last! The new name is shorter, simpler, and consistent with `hir::Ty`.
2021-11-26Update the first heading indent rule so it is only applied on the first ↵Guillaume Gomez-4/+6
heading of the top doc block
2021-11-26Rollup merge of #91225 - GuillaumeGomez:source-page-scrollbar, r=jshaMatthias Krüger-0/+4
Fix invalid scrollbar display on source code page Fixes bug introduced in #90983: ![Screenshot from 2021-11-25 17-01-08](https://user-images.githubusercontent.com/3050060/143473753-c2e7c43c-ce3f-474d-9d2a-922e63189c51.png) ![Screenshot from 2021-11-25 17-07-08](https://user-images.githubusercontent.com/3050060/143473757-eecaaf2b-f4f0-49e0-a159-ab485e3f7122.png) To fix it, I simply unset the `overflow-y` on the source code page so it's not displayed anymore. r? ``@jsha``
2021-11-25Stop re-exporting `Type::ResolvedPath`Noah Lev-16/+15
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-25Fix invalid scrollbar display on source code pageGuillaume Gomez-0/+4
2021-11-25Auto merge of #91195 - camelid:path-did, r=jyn514bors-10/+23
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-25Auto merge of #88781 - estebank:emoji-idents, r=oli-obkbors-1/+1
Tokenize emoji as if they were valid identifiers In the lexer, consider emojis to be valid identifiers and reject them later to avoid knock down parse errors. Partially address #86102.
2021-11-24Consistentize the system for image URLs in CSS.Jacob Hoffman-Andrews-36/+35
2021-11-24Move themes and version into rustdoc-varsJacob Hoffman-Andrews-49/+37
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-48/+44
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-24Auto merge of #91203 - GuillaumeGomez:rollup-kwtqvb1, r=GuillaumeGomezbors-20/+8
Rollup of 7 pull requests Successful merges: - #89542 (Partially stabilize `duration_consts_2`) - #90044 (Restrict aarch64 outline atomics to glibc for now.) - #90420 (Create rustdoc_internals feature gate) - #91075 (Reduce prominence of item-infos) - #91151 (Fix test in std::process on android) - #91179 (Fix more <a> color) - #91199 (rustdoc: Add test for mixing doc comments and attrs) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
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``