Skip to content

Update rustdoc code blocks so they use grid: display #105894

New issue

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

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

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
16 changes: 13 additions & 3 deletions src/test/rustdoc-gui/code-blocks-overflow.goml
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
// This test ensures that codeblocks content don't overflow.
goto: "file://" + |DOC_PATH| + "/lib2/sub_mod/struct.Foo.html"
size: (1080, 600)
// There should be two codeblocks: a rust one and a non-rust one.
assert-count: (".docblock > .example-wrap", 2)
// There should be three codeblocks: two rust ones and a non-rust one.
assert-count: (".docblock > .example-wrap", 3)
assert: ".docblock > .example-wrap > .language-txt"
assert: ".docblock > .example-wrap > .rust-example-rendered"
assert-css: (".docblock > .example-wrap > pre", {"width": "796px", "overflow-x": "auto"}, ALL)

// We confirm that we don't display line numbers currently.
assert-local-storage-false: {"rustdoc-line-numbers": "true"}

assert-css: (".docblock > .example-wrap", {"width": "796px", "overflow-x": "auto"}, ALL)
assert-css: (".docblock > .example-wrap > pre", {"width": "1756px"})

// Confirm that there is no change when line numbers are displayed.
local-storage: {"rustdoc-line-numbers": "true"}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test only works if you reload the page.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, thanks!

assert-css: (".docblock > .example-wrap", {"width": "796px", "overflow-x": "auto"}, ALL)
assert-css: (".docblock > .example-wrap > pre", {"width": "1756px"})
5 changes: 3 additions & 2 deletions src/test/rustdoc-gui/source-anchor-scroll.goml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// We check that when the anchor changes and is output of the displayed content,
// the page is scrolled to it.
goto: "file://" + |DOC_PATH| + "/src/link_to_definition/lib.rs.html"
show-text: true

// We reduce the window size to make it easier to make an element "out of the page".
size: (600, 800)
Expand All @@ -12,9 +13,9 @@ assert-property: ("html", {"scrollTop": "125"})
click: '//a[text() = "bar"]'
assert-property: ("html", {"scrollTop": "156"})
click: '//a[text() = "sub_fn"]'
assert-property: ("html", {"scrollTop": "53"})
assert-property: ("html", {"scrollTop": "76"})

// We now check that clicking on lines doesn't change the scroll
// Extra information: the "sub_fn" function header is on line 1.
click: '//*[@id="6"]'
assert-property: ("html", {"scrollTop": "53"})
assert-property: ("html", {"scrollTop": "76"})
4 changes: 4 additions & 0 deletions src/test/rustdoc-gui/src/lib2/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ pub mod sub_mod {
/// ```
/// aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
/// ```
///
/// ```
/// foo();
/// ```
pub struct Foo;
}

Expand Down