about summary refs log tree commit diff
path: root/src/librustdoc/html
AgeCommit message (Collapse)AuthorLines
2022-12-09Rollup merge of #105387 - willcrichton:scrape-examples-ui-improvements, ↵Matthias Krüger-22/+73
r=notriddle Improve Rustdoc scrape-examples UI This PR combines a few different improvements to the scrape-examples UI. See a live demo here: https://willcrichton.net/misc/scrape-examples/small-first-example/clap/struct.Arg.html ### 1. The first scraped example now takes up significantly less screen height. Inserting the first scraped example takes up a lot of vertical screen space. I don't want this addition to overwhelm users, so I decided to reduce the height of the initial example in two ways: (A) the default un-expanded height is reduced from 240px (10 LOC) to 120px (5 LOC), and (B) the link to the example is now positioned *over* the example instead of *atop* the example (only on desktop though, not mobile). The changes to `scrape-examples.js` and `rustdoc.css` implement this fix. Here is what an example docblock now looks like: ![Screen Shot 2022-12-06 at 10 02 21 AM](https://user-images.githubusercontent.com/663326/205987450-3940063c-5973-4a34-8579-baff6a43aa9b.png) ### 2. Expanding all docblocks will not expand "More examples". The "More examples blocks" are huge, so fully expanding everything on the page would take up too much vertical space. The changes to `main.js` implement this fix. This is tested in `scrape-examples-toggle.goml`. ### 3. Examples from binary crates are sorted higher than examples from library crates. Code that is written as an example of an API is probably better for learning than code that happens to use an API, but isn't intended for pedagogic purposes. Unfortunately Rustc doesn't know whether a particular crate comes from an example target (only Cargo knows this). But we can at least create a proxy that prefers examples from binary crates over library crates, which we know from `--crate-type`. This change is implemented by adding a new field `bin_crate` in `Options` (see `config.rs`). An `is_bin` field has been added to the scraped examples metadata (see `scrape_examples.rs`). Then the example sorting metric uses `is_bin` as the first entry of a lexicographic sort on `(is_bin, example_size, display_name)` (see `render/mod.rs`). Note that in the future we can consider adding another flag like `--scrape-examples-cargo-target` that would pass target information from Cargo into the example metadata. But I'm proposing a less intrusive change for now. ### 4. The scrape-examples help page has been updated to reflect the latest Cargo interface. See `scrape-examples-help.md`. r? `@notriddle` P.S. once this PR and rust-lang/cargo#11450 are merged, then I think the scrape-examples feature is officially ready for deployment on docs.rs!
2022-12-08rustdoc: remove no-op mobile CSS `#sidebar-toggle { text-align }`Michael Howell-1/+0
Since 8b001b4da0716936e0ca32303cc0e3c5e53e42f8 make the sidebar toggle a flex container, and already centers its content in desktop mode, this rule doesn't do anything.
2022-12-08rustdoc: add GUI test case for docblock table colorsMichael Howell-1/+1
2022-12-07rustdoc: clean up docblock table CSSMichael Howell-10/+7
* The rule `display: block` had no noticeable effect. Technically, because markdown tables have a tbody and thead, they get wrapped in an [anonymous table box] in the CSS tree, nested within the `<table>` element's block layout box. This rule was added in #87230 to make the table side-scrolling, but this same issue was doubly fixed in #88742 by wrapping it in an explicit `<div>` tag. Since accessibility advocates recommend the wrapper div over marking the table as `display: block`, we'll stick with that. https://adrianroselli.com/2020/11/under-engineered-responsive-tables.html * The rule `width: calc(100% - 2px)` had no visible effect, because the anonymous table box was not affected. * The style is tweaked to basically be the same style GitHub uses. In particular, it adds zebra stripes, and removes dotted borders. [anonymous table box]: https://www.w3.org/TR/CSS2/tables.html#anonymous-boxes
2022-12-07Improve code readabilityGuillaume Gomez-1/+1
2022-12-07Improve calculation of scraped example minimized heightWill Crichton-5/+15
2022-12-07Fix rustdoc error with no providec crate-type, fix scrape examples button ↵Will Crichton-0/+1
colors w/ themes
2022-12-07Fix es-checkWill Crichton-1/+1
2022-12-07Update scrape-examples help, fix documentation typosWill Crichton-9/+11
2022-12-07Include additional documentation for scrape-examples changesWill Crichton-2/+8
2022-12-07Only put title over example on large screensWill Crichton-10/+13
2022-12-07Improve several aspects of the Rustdoc scrape-examples UI.Will Crichton-17/+46
* Examples take up less screen height. * Snippets from binary crates are prioritized. * toggle-all-docs does not expand "More examples" sections.
2022-12-07Rollup merge of #105403 - notriddle:notriddle/item-stab-css, r=GuillaumeGomezMatthias Krüger-4/+2
rustdoc: simplify CSS selectors for item table `.stab` The module-item and import-item classes are attached to the item-left. Just target that, instead.
2022-12-06rustdoc: simplify CSS selectors for item table `.stab`Michael Howell-4/+2
The module-item and import-item classes are attached to the item-left. Just target that, instead.
2022-12-06Rollup merge of #105388 - notriddle:notriddle/item-stab-font-size, ↵Matthias Krüger-1/+0
r=GuillaumeGomez rustdoc: remove redundant CSS `.import-item .stab { font-size }` This sets the exact same font size that `.stab` has by default anyway. It used to be slightly different, but dd5ff428edbc7cd4fa600b81f27bbec28589704f made it identical.
2022-12-06rustdoc: remove redundant CSS `.import-item .stab { font-size }`Michael Howell-1/+0
This sets the exact same font size that `.stab` has by default anyway. It used to be slightly different, but dd5ff428edbc7cd4fa600b81f27bbec28589704f made it identical.
2022-12-06Rollup merge of #105320 - notriddle:notriddle/rustdoc-toggle-hideme-2, ↵Matthias Krüger-9/+2
r=GuillaumeGomez rustdoc: simplify CSS selectors on top-doc and non-exhaustive toggles This code uses a special `hideme` class anyway, so just style that.
2022-12-06Rollup merge of #105309 - notriddle:notriddle/sidebar-margin-padding, ↵Yuki Okushi-2/+0
r=GuillaumeGomez rustdoc: remove no-op mobile CSS `.sidebar { margin: 0; padding: 0 }` This isn't overriding anything, because the sidebar never has a margin or padding on it.
2022-12-06Rollup merge of #104967 - willcrichton:fix-scrape-examples, r=notriddleYuki Okushi-3/+5
Fix UI issues with Rustdoc scrape-examples feature. A few regressions have been introduced into scrape-examples in the last few months. This commit fixes those regressions: * Help file was being loaded from the wrong place (introduced in f9e1f6ffdf03ec33cb29e20c88fc7bcc938c7f42). * CSS selector in JS has a typo (introduced in 14897180ae6a0506a5ad0a9f6a30ae1f75916179). * Line numbers in scraped example code snippets are overflowing (not sure if this was ever fixed). Changing from flexbox to grid display fixed this issue.
2022-12-05rustdoc: simplify CSS selectors on top-doc and non-exhaustive togglesMichael Howell-9/+2
This code uses a special `hideme` class anyway, so just style that.
2022-12-05rustdoc: remove no-op mobile CSS `.sidebar { margin: 0; padding: 0 }`Michael Howell-2/+0
This isn't overriding anything, because the sidebar never has a margin or padding on it.
2022-12-03Rollup merge of #105189 - notriddle:notriddle/rustdoc-toggle-hideme, ↵Yuki Okushi-8/+2
r=GuillaumeGomez rustdoc: clean up redundant CSS on `.rustdoc-toggle.hideme`
2022-12-02rustdoc: clean up redundant CSS on `.rustdoc-toggle.hideme`Michael Howell-8/+2
2022-12-02Rollup merge of #105155 - notriddle:notriddle/flexbox-help-settings-buttons, ↵Matthias Krüger-19/+10
r=GuillaumeGomez rustdoc: clean up help and settings button CSS The old version of this code specified a bunch of different numbers that had to line up just right to get the size it wanted. This version uses flexbox centering, specifies the font size, and lets the browser figure out the rest of the layout automatically. Preview: http://notriddle.com/notriddle-rustdoc-demos/flexbox-help-settings-buttons/test_dingus/
2022-12-02Rollup merge of #105143 - notriddle:notriddle/scraped-example-list-font, ↵Matthias Krüger-3/+1
r=GuillaumeGomez rustdoc: use simpler CSS for setting the font on scraped examples
2022-12-02Rollup merge of #105132 - GuillaumeGomez:migrate-summary-toggle-to-var, ↵Matthias Krüger-8/+4
r=notriddle Migrate summary toggle filter to CSS variable r? `@notriddle`
2022-12-02Auto merge of #104963 - petrochenkov:noaddids2, r=cjgillotbors-9/+1
rustc_ast_lowering: Stop lowering imports into multiple items Lower them into a single item with multiple resolutions instead. This also allows to remove additional `NodId`s and `DefId`s related to those additional items.
2022-12-01rustdoc: clean up help and settings button CSSMichael Howell-13/+8
The old version of this code specified a bunch of different numbers that had to line up just right to get the size it wanted. This version uses flexbox centering, specifies the font size, and lets the browser figure out the rest of the layout automatically.
2022-12-01rustdoc: clean up button-hiding mobile CSSMichael Howell-6/+2
2022-12-01rustdoc: use simpler CSS for setting the font on scraped examplesMichael Howell-3/+1
2022-12-01rustc_hir: Change representation of import paths to support multiple resolutionsVadim Petrochenkov-8/+0
2022-12-01Migrate summary toggle filter to CSS variableGuillaume Gomez-8/+4
2022-12-01rustc_hir: Relax lifetime requirements on `Visitor::visit_path`Vadim Petrochenkov-1/+1
2022-12-01Rollup merge of #105088 - notriddle:notriddle/search-results-div-desc, ↵Matthias Krüger-1/+0
r=GuillaumeGomez rustdoc: remove redundant CSS `div.desc { display: block }` DIV tags have block display by default. It is from when this rule used to target a SPAN tag, but became redundant in 4bd6748bb9b73c210558498070ae0b7ed8193ddf.
2022-11-30Rollup merge of #105086 - notriddle:notriddle/sidebar-css, r=GuillaumeGomezMatthias Krüger-7/+5
rustdoc: clean up sidebar link CSS Group `text-overflow: ellipses` along with `white-space: nowrap`. It makes no sense to try to apply it to links with `overflow-wrap: anywhere`, because it can't actually make ellipses when that's turned on. Simplify the selector for the 25rem left padding on sidebar links, to match up with the style for the container left padding that makes room for it.
2022-11-30Rollup merge of #105064 - notriddle:notriddle/main-min-width, r=GuillaumeGomezMatthias Krüger-1/+1
rustdoc: add comment to confusing CSS `main { min-width: 0 }` This CSS was added in cad0fce2053d52b7ba04c458f4c124c8b5c6141e, but the reason why it was necessary was unclear. This comment makes it clear.
2022-11-30rustdoc: remove redundant CSS `div.desc { display: block }`Michael Howell-1/+0
DIV tags have block display by default. It is from when this rule used to target a SPAN tag, but became redundant in 4bd6748bb9b73c210558498070ae0b7ed8193ddf.
2022-11-30rustdoc: clean up sidebar link CSSMichael Howell-7/+5
Group `text-overflow: ellipses` along with `white-space: nowrap`. It makes no sense to try to apply it to links with `overflow-wrap: anywhere`, because it can't actually make ellipses when that's turned on. Simplify the selector for the 25rem left padding on sidebar links, to match up with the style for the container left padding that makes room for it.
2022-11-29rustdoc: add comment to confusing CSS `main { min-width: 0 }`Michael Howell-1/+1
This CSS was added in cad0fce2053d52b7ba04c458f4c124c8b5c6141e, but the reason why it was necessary was unclear. This comment makes it clear.
2022-11-29rustdoc: use shorthand background for rustdoc toggle CSSMichael Howell-6/+2
2022-11-29Rollup merge of #105024 - notriddle:notriddle/fnname, r=jyn514Matthias Krüger-3/+2
rustdoc: remove `fnname` CSS class that's styled exactly like `fn` It's not obvious why this was ever a separate class name, since even in c4219a478354b464079b1b7ab081e071e8e39765 when it was first added, it was styled identically to regular `fn` links.
2022-11-29Rollup merge of #105020 - notriddle:notriddle/rustdoc-toggle, r=GuillaumeGomezMatthias Krüger-8/+1
rustdoc: merge background-image rules in rustdoc-toggle CSS
2022-11-28rustdoc: remove `fnname` CSS class that's styled exactly like `fn`Michael Howell-3/+2
It's not obvious why this was ever a separate class name, since even in c4219a478354b464079b1b7ab081e071e8e39765 when it was first added, it was styled identically to regular `fn` links.
2022-11-28rustdoc: merge background-image rules in rustdoc-toggle CSSMichael Howell-8/+1
2022-11-28Add sentence when rustdoc search is runningGuillaume Gomez-8/+12
2022-11-27Rollup merge of #104946 - notriddle:notriddle/popover-menu-focus, ↵Matthias Krüger-5/+17
r=GuillaumeGomez rustdoc: improve popover focus handling JS This commit fixes a few inconsistencies and erratic behavior from the notable traits, settings, and sidebar popups: * It makes it so that pressing Escape closes the mobile sidebar. This is a bit difficult to do on iPhone, but on other setups like desktop tiling window managers, it's easy and makes sense. * It makes sure that pressing escape while a notable trait popover is open focuses the popover's toggle button, instead of leaving nothing focused, since that makes more sense with keyboard navigation. Clicking the settings, help, or sidebar buttons, however, will not focus the notable trait popover toggle button. * It ensures that notable trait and settings popovers are exclusive with the mobile sidebar. Nothing should ever overlap a popover, and there should never be more than one popover open at once.
2022-11-26Fix UI issues with Rustdoc scrape-examples feature.Will Crichton-3/+5
* Help file was being loaded from the wrong place. * CSS selector in JS has a typo. * Line numbers are overflowing, change to display: grid to fix.
2022-11-26rustdoc: pass "true" to reset focus for notable traitsMichael Howell-11/+7
2022-11-26rustdoc: improve popover focus handling JSMichael Howell-5/+21
This commit fixes a few inconsistencies and erratic behavior from the notable traits, settings, and sidebar popups: * It makes it so that pressing Escape closes the mobile sidebar. This is a bit difficult to do on iPhone, but on other setups like desktop tiling window managers, it's easy and makes sense. * It makes sure that pressing escape while a notable trait popover is open focuses the popover's toggle button, instead of leaving nothing focused, since that makes more sense with keyboard navigation. Clicking the settings, help, or sidebar buttons, however, will not focus the notable trait popover toggle button. * It ensures that notable trait and settings popovers are exclusive with the mobile sidebar. Nothing should ever overlap a popover, and there should never be more than one popover open at once.
2022-11-26Rollup merge of #104928 - notriddle:notriddle/sidebar-toggle-flexbox, ↵Guillaume Gomez-9/+3
r=GuillaumeGomez rustdoc: use flexbox CSS to align sidebar button instead of position This accomplishes the same thing with significantly less code. Preview: https://notriddle.com/notriddle-rustdoc-demos/sidebar-toggle-flexbox/src/test_dingus/lib.rs.html