Skip to content

[rustdoc] Improve display of prev/next scraped examples buttons #136870

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/librustdoc/html/static/css/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -1697,6 +1697,10 @@ instead, we check that it's not a "finger" cursor.
.example-wrap .button-holder > *:not(:first-child) {
margin-left: var(--button-left-margin);
}
.example-wrap .button-holder .prev,
.example-wrap .button-holder .next {
font-size: 1.3em;
}
.example-wrap .button-holder .copy-button {
padding: 2px 0 0 4px;
}
Expand Down
4 changes: 2 additions & 2 deletions src/librustdoc/html/static/js/scrape-examples.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@

const locs = example.locs;
if (locs.length > 1) {
const next = createScrapeButton(buttonHolder, "next", "");
const prev = createScrapeButton(buttonHolder, "prev", "");
const next = createScrapeButton(buttonHolder, "next", ">");
const prev = createScrapeButton(buttonHolder, "prev", "<");
Comment on lines +63 to +64
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the past, we've tried to move away from using punctuation as icons, because it looks confusingly like syntax. We could use the same unicode icons as the expand buttons, or we could use SVG. #136950

Suggested change
const next = createScrapeButton(buttonHolder, "next", ">");
const prev = createScrapeButton(buttonHolder, "prev", "<");
const next = createScrapeButton(buttonHolder, "next", "");
const prev = createScrapeButton(buttonHolder, "prev", "");


// Toggle through list of examples in a given file
const onChangeLoc = changeIndex => {
Expand Down
4 changes: 4 additions & 0 deletions tests/rustdoc-gui/scrape-examples-button-focus.goml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ assert-property: (".scraped-example-list > .scraped-example .rust", {
"scrollTop": |initialScrollTop|,
})
focus: ".scraped-example-list > .scraped-example .next"
assert-text: (".scraped-example-list > .scraped-example .next", ">")
assert-css: (".scraped-example-list > .scraped-example .next", { "font-size": "20.8px" })
press-key: "Enter"
assert-property-false: (".scraped-example-list > .scraped-example .src-line-numbers", {
"scrollTop": |initialScrollTop|
Expand All @@ -19,6 +21,8 @@ assert-property-false: (".scraped-example-list > .scraped-example .rust", {
"scrollTop": |initialScrollTop|
}, NEAR)
focus: ".scraped-example-list > .scraped-example .prev"
assert-css: (".scraped-example-list > .scraped-example .next", { "font-size": "20.8px" })
assert-text: (".scraped-example-list > .scraped-example .prev", "<")
press-key: "Enter"
assert-property: (".scraped-example-list > .scraped-example .src-line-numbers", {
"scrollTop": |initialScrollTop|
Expand Down
Loading