Skip to content

Commit

Permalink
Fix wrong padding for expanded scraped example
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Sep 2, 2024
1 parent e3af6dc commit 55bc638
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/librustdoc/html/static/css/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -789,11 +789,18 @@ both the code example and the line numbers, so we need to remove the radius in t
}

.rustdoc:not(.src) .scraped-example:not(.expanded) .src-line-numbers,
.rustdoc:not(.src) .scraped-example:not(.expanded) .src-line-numbers > pre,
.rustdoc:not(.src) .scraped-example:not(.expanded) pre.rust {
padding-bottom: 0;
/* See above comment, should be the same max-height. */
overflow: auto hidden;
}
.rustdoc:not(.src) .scraped-example .src-line-numbers {
padding-top: 0;
}
.rustdoc:not(.src) .scraped-example.expanded .src-line-numbers {
padding-bottom: 0;
}

.rustdoc:not(.src) .example-wrap pre {
overflow: auto;
Expand Down
4 changes: 2 additions & 2 deletions tests/rustdoc-gui/scrape-examples-button-focus.goml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ assert-property: (".scraped-example-list > .scraped-example .rust", {

// The expand button increases the scrollHeight of the minimized code viewport
store-property: (".scraped-example-list > .scraped-example pre", {"offsetHeight": smallOffsetHeight})
assert-property-false: (".scraped-example-list > .scraped-example .src-line-numbers", {
assert-property: (".scraped-example-list > .scraped-example .src-line-numbers", {
"scrollHeight": |smallOffsetHeight|
}, NEAR)
assert-property-false: (".scraped-example-list > .scraped-example .rust", {
assert-property: (".scraped-example-list > .scraped-example .rust", {
"scrollHeight": |smallOffsetHeight|
}, NEAR)
focus: ".scraped-example-list > .scraped-example .expand"
Expand Down
19 changes: 19 additions & 0 deletions tests/rustdoc-gui/scrape-examples-layout.goml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,25 @@ assert-position: (".scraped-example .scraped-example-title", {
"y": |y| + |height| - |title_height| - 8,
})

// Check that the expand button works and also that line number aligns with code.
move-cursor-to: ".scraped-example .rust"
click: ".scraped-example .button-holder .expand"
wait-for: ".scraped-example.expanded"
// They should have the same y position.
compare-elements-position: (
".scraped-example.expanded .src-line-numbers pre span",
".scraped-example.expanded .rust code",
["y"],
)
// And they should have the same height.
compare-elements-size: (
".scraped-example.expanded .src-line-numbers",
".scraped-example.expanded .rust",
["height"],
)
// Collapse code again.
click: ".scraped-example .button-holder .expand"

// Check that for both mobile and desktop sizes, the buttons in scraped examples are displayed
// correctly.

Expand Down

0 comments on commit 55bc638

Please sign in to comment.