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 f9e1f6ffdf).
* CSS selector in JS has a typo (introduced in 14897180ae).
* 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.
This commit is contained in:
Yuki Okushi 2022-12-06 12:48:50 +09:00 committed by GitHub
commit 532fe7b8e0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 19 additions and 3 deletions

View file

@ -1978,7 +1978,9 @@ in storage.js
}
.scraped-example .code-wrapper .example-wrap {
flex: 1;
display: grid;
grid-template-columns: max-content auto;
width: 100%;
overflow-x: auto;
overflow-y: hidden;
margin-bottom: 0;

View file

@ -57,7 +57,7 @@
});
});
example.querySelector("next")
example.querySelector(".next")
.addEventListener("click", () => {
onChangeLoc(() => {
locIndex = (locIndex + 1) % locs.length;

View file

@ -130,4 +130,4 @@ static_files! {
nanum_barun_gothic_license => "static/fonts/NanumBarunGothic-LICENSE.txt",
}
pub(crate) static SCRAPE_EXAMPLES_HELP_MD: &str = include_str!("static/js/scrape-examples.js");
pub(crate) static SCRAPE_EXAMPLES_HELP_MD: &str = include_str!("static/scrape-examples-help.md");

View file

@ -1,4 +1,17 @@
goto: "file://" + |DOC_PATH| + "/scrape_examples/fn.test.html"
store-property: (initialScrollTop, ".scraped-example-list > .scraped-example pre", "scrollTop")
focus: ".scraped-example-list > .scraped-example .next"
press-key: "Enter"
assert-property-false: (".scraped-example-list > .scraped-example pre", {
"scrollTop": |initialScrollTop|
})
focus: ".scraped-example-list > .scraped-example .prev"
press-key: "Enter"
assert-property: (".scraped-example-list > .scraped-example pre", {
"scrollTop": |initialScrollTop|
})
store-property: (smallOffsetHeight, ".scraped-example-list > .scraped-example pre", "offsetHeight")
assert-property-false: (".scraped-example-list > .scraped-example pre", {
"scrollHeight": |smallOffsetHeight|

View file

@ -22,4 +22,5 @@ fn main() {
println!("hello world!");
println!("hello world!");
}
scrape_examples::test();
}