Skip to content

Commit 532fe7b

Browse files
author
Yuki Okushi
authored
Rollup merge of #104967 - willcrichton:fix-scrape-examples, r=notriddle
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 f9e1f6f). * CSS selector in JS has a typo (introduced in 1489718). * 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.
2 parents 226202d + f7a7059 commit 532fe7b

File tree

5 files changed

+19
-3
lines changed

5 files changed

+19
-3
lines changed

src/librustdoc/html/static/css/rustdoc.css

+3-1
Original file line numberDiff line numberDiff line change
@@ -1978,7 +1978,9 @@ in storage.js
19781978
}
19791979

19801980
.scraped-example .code-wrapper .example-wrap {
1981-
flex: 1;
1981+
display: grid;
1982+
grid-template-columns: max-content auto;
1983+
width: 100%;
19821984
overflow-x: auto;
19831985
overflow-y: hidden;
19841986
margin-bottom: 0;

src/librustdoc/html/static/js/scrape-examples.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
});
5858
});
5959

60-
example.querySelector("next")
60+
example.querySelector(".next")
6161
.addEventListener("click", () => {
6262
onChangeLoc(() => {
6363
locIndex = (locIndex + 1) % locs.length;

src/librustdoc/html/static_files.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,4 +130,4 @@ static_files! {
130130
nanum_barun_gothic_license => "static/fonts/NanumBarunGothic-LICENSE.txt",
131131
}
132132

133-
pub(crate) static SCRAPE_EXAMPLES_HELP_MD: &str = include_str!("static/js/scrape-examples.js");
133+
pub(crate) static SCRAPE_EXAMPLES_HELP_MD: &str = include_str!("static/scrape-examples-help.md");

src/test/rustdoc-gui/scrape-examples-button-focus.goml

+13
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
11
goto: "file://" + |DOC_PATH| + "/scrape_examples/fn.test.html"
2+
3+
store-property: (initialScrollTop, ".scraped-example-list > .scraped-example pre", "scrollTop")
4+
focus: ".scraped-example-list > .scraped-example .next"
5+
press-key: "Enter"
6+
assert-property-false: (".scraped-example-list > .scraped-example pre", {
7+
"scrollTop": |initialScrollTop|
8+
})
9+
focus: ".scraped-example-list > .scraped-example .prev"
10+
press-key: "Enter"
11+
assert-property: (".scraped-example-list > .scraped-example pre", {
12+
"scrollTop": |initialScrollTop|
13+
})
14+
215
store-property: (smallOffsetHeight, ".scraped-example-list > .scraped-example pre", "offsetHeight")
316
assert-property-false: (".scraped-example-list > .scraped-example pre", {
417
"scrollHeight": |smallOffsetHeight|

src/test/rustdoc-gui/src/scrape_examples/examples/check.rs

+1
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@ fn main() {
2222
println!("hello world!");
2323
println!("hello world!");
2424
}
25+
scrape_examples::test();
2526
}

0 commit comments

Comments
 (0)