Skip to content

Commit fe12aa1

Browse files
authored
Unrolled build for rust-lang#130619
Rollup merge of rust-lang#130619 - GuillaumeGomez:scraped-examples-height, r=notriddle Fix scraped examples height Fixes [rust-lang#130562](rust-lang#130562). You can test it [here](https://rustdoc.crud.net/imperio/scraped-examples-height/doc/scrape_examples/fn.test_many.html). I also used this opportunity to reduce the padding on line numbers: | before | after | | - | - | | ![Screenshot from 2024-09-20 16-20-40](https://github.com/user-attachments/assets/9434704c-afe0-4ec3-a1dc-6f3c16d03b3b) | ![Screenshot from 2024-09-20 16-20-13](https://github.com/user-attachments/assets/f3bd01bf-760a-4acd-ba34-8e7db083245a) | r? `@notriddle`
2 parents 5ba6db1 + 55058b6 commit fe12aa1

File tree

3 files changed

+79
-3
lines changed

3 files changed

+79
-3
lines changed

Diff for: src/librustdoc/html/static/css/rustdoc.css

+9-2
Original file line numberDiff line numberDiff line change
@@ -801,6 +801,9 @@ both the code example and the line numbers, so we need to remove the radius in t
801801
* and we include additional 10px for padding. */
802802
max-height: calc(1.5em * 5 + 10px);
803803
}
804+
.more-scraped-examples .scraped-example:not(.expanded) .example-wrap {
805+
max-height: calc(1.5em * 10 + 10px);
806+
}
804807

805808
.rustdoc:not(.src) .scraped-example:not(.expanded) .src-line-numbers,
806809
.rustdoc:not(.src) .scraped-example:not(.expanded) .src-line-numbers > pre,
@@ -828,10 +831,14 @@ both the code example and the line numbers, so we need to remove the radius in t
828831
-webkit-user-select: none;
829832
user-select: none;
830833
padding: 14px 8px;
834+
padding-right: 2px;
831835
color: var(--src-line-numbers-span-color);
832836
}
833837

834-
.rustdoc .scraped-example .src-line-numbers {
838+
.rustdoc .scraped-example .example-wrap .src-line-numbers {
839+
padding: 0;
840+
}
841+
.rustdoc .src-line-numbers pre {
835842
padding: 14px 0;
836843
}
837844
.src-line-numbers a, .src-line-numbers span {
@@ -890,7 +897,7 @@ both the code example and the line numbers, so we need to remove the radius in t
890897
}
891898

892899
.docblock code, .docblock-short code,
893-
pre, .rustdoc.src .example-wrap {
900+
pre, .rustdoc.src .example-wrap, .example-wrap .src-line-numbers {
894901
background-color: var(--code-block-background-color);
895902
}
896903

Diff for: tests/rustdoc-gui/docblock-code-block-line-number.goml

+62-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ define-function: (
3939
{
4040
"color": |color|,
4141
"margin": "0px",
42-
"padding": "14px 8px",
42+
"padding-top": "14px",
43+
"padding-bottom": "14px",
44+
"padding-left": "8px",
45+
"padding-right": "2px",
4346
"text-align": "right",
4447
// There should not be a radius on the right of the line numbers.
4548
"border-top-left-radius": "6px",
@@ -141,3 +144,61 @@ assert-css: (
141144
},
142145
ALL,
143146
)
147+
148+
// Checking line numbers on scraped code examples.
149+
go-to: "file://" + |DOC_PATH| + "/scrape_examples/fn.test_many.html"
150+
151+
define-function: (
152+
"check-padding",
153+
[path, padding_bottom],
154+
block {
155+
assert-css: (|path| + " .src-line-numbers", {
156+
"padding-top": "0px",
157+
"padding-bottom": "0px",
158+
"padding-left": "0px",
159+
"padding-right": "0px",
160+
})
161+
assert-css: (|path| + " .src-line-numbers > pre", {
162+
"padding-top": "14px",
163+
"padding-bottom": |padding_bottom|,
164+
"padding-left": "0px",
165+
"padding-right": "0px",
166+
})
167+
assert-css: (|path| + " .src-line-numbers > pre > span", {
168+
"padding-top": "0px",
169+
"padding-bottom": "0px",
170+
"padding-left": "8px",
171+
"padding-right": "8px",
172+
})
173+
},
174+
)
175+
176+
call-function: ("check-padding", {
177+
"path": ".scraped-example .example-wrap",
178+
"padding_bottom": "0px",
179+
})
180+
181+
move-cursor-to: ".scraped-example .example-wrap .rust"
182+
wait-for: ".scraped-example .example-wrap .button-holder .expand"
183+
click: ".scraped-example .example-wrap .button-holder .expand"
184+
wait-for: ".scraped-example.expanded"
185+
186+
call-function: ("check-padding", {
187+
"path": ".scraped-example.expanded .example-wrap",
188+
"padding_bottom": "14px",
189+
})
190+
191+
// Now checking the line numbers in the source code page.
192+
click: ".src"
193+
assert-css: (".src-line-numbers", {
194+
"padding-top": "20px",
195+
"padding-bottom": "20px",
196+
"padding-left": "4px",
197+
"padding-right": "0px",
198+
})
199+
assert-css: (".src-line-numbers > a", {
200+
"padding-top": "0px",
201+
"padding-bottom": "0px",
202+
"padding-left": "8px",
203+
"padding-right": "8px",
204+
})

Diff for: tests/rustdoc-gui/scrape-examples-layout.goml

+8
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ assert-property: (
3737

3838
// The "title" should be located at the right bottom corner of the code example.
3939
store-position: (".scraped-example .example-wrap", {"x": x, "y": y})
40+
assert-size: (".scraped-example .example-wrap", {"height": 130})
4041
store-size: (".scraped-example .example-wrap", {"width": width, "height": height})
4142
store-size: (".scraped-example .scraped-example-title", {
4243
"width": title_width,
@@ -47,6 +48,13 @@ assert-position: (".scraped-example .scraped-example-title", {
4748
"y": |y| + |height| - |title_height| - 8,
4849
})
4950

51+
store-size: (".more-scraped-examples .scraped-example .example-wrap", {"height": more_height})
52+
assert: |more_height| > |height|
53+
assert-size: (".more-scraped-examples .scraped-example .example-wrap", {
54+
"height": 250,
55+
"width": |width|,
56+
})
57+
5058
// Check that the expand button works and also that line number aligns with code.
5159
move-cursor-to: ".scraped-example .rust"
5260
click: ".scraped-example .button-holder .expand"

0 commit comments

Comments
 (0)