Skip to content

Fix UI issues with Rustdoc scrape-examples feature. #104967

New issue

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

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

Already on GitHub? # to your account

Merged
merged 3 commits into from
Dec 6, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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: 3 additions & 1 deletion src/librustdoc/html/static/css/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -2015,7 +2015,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;
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/html/static/js/scrape-examples.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
});
});

example.querySelector("next")
example.querySelector(".next")
.addEventListener("click", () => {
onChangeLoc(() => {
locIndex = (locIndex + 1) % locs.length;
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/html/static_files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
15 changes: 14 additions & 1 deletion src/test/rustdoc-gui/scrape-examples-button-focus.goml
Original file line number Diff line number Diff line change
@@ -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|
Expand All @@ -11,4 +24,4 @@ assert-property-false: (".scraped-example-list > .scraped-example pre", {
store-property: (fullOffsetHeight, ".scraped-example-list > .scraped-example pre", "offsetHeight")
assert-property: (".scraped-example-list > .scraped-example pre", {
"scrollHeight": |fullOffsetHeight|
})
})
1 change: 1 addition & 0 deletions src/test/rustdoc-gui/src/scrape_examples/examples/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ fn main() {
println!("hello world!");
println!("hello world!");
}
scrape_examples::test();
}