Add GUI test for warning blocks
This commit is contained in:
parent
57d2b84a57
commit
1d42913058
3 changed files with 59 additions and 1 deletions
|
@ -256,7 +256,8 @@ So, no need to manually enter those Unicode characters!
|
||||||
|
|
||||||
### Adding a warning block
|
### Adding a warning block
|
||||||
|
|
||||||
If you want to make a "warning" stand out in the documentation, you can wrap it like this:
|
If you want to make a warning or similar note stand out in the documentation,
|
||||||
|
you can wrap it like this:
|
||||||
|
|
||||||
```md
|
```md
|
||||||
/// documentation
|
/// documentation
|
||||||
|
|
|
@ -65,6 +65,18 @@ impl Foo {
|
||||||
pub fn must_use(&self) -> bool {
|
pub fn must_use(&self) -> bool {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// hello
|
||||||
|
///
|
||||||
|
/// <div id="doc-warning-1" class="warning">this is a warning</div>
|
||||||
|
///
|
||||||
|
/// done
|
||||||
|
pub fn warning1() {}
|
||||||
|
|
||||||
|
/// Checking there is no bottom margin if "warning" is the last element.
|
||||||
|
///
|
||||||
|
/// <div id="doc-warning-2" class="warning">this is a warning</div>
|
||||||
|
pub fn warning2() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AsRef<str> for Foo {
|
impl AsRef<str> for Foo {
|
||||||
|
|
45
tests/rustdoc-gui/warning-block.goml
Normal file
45
tests/rustdoc-gui/warning-block.goml
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
// Test to check that the "warning blocks" are displayed as expected.
|
||||||
|
go-to: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html"
|
||||||
|
show-text: true
|
||||||
|
|
||||||
|
define-function: (
|
||||||
|
"check-warning",
|
||||||
|
(theme, color, border_color, background_color),
|
||||||
|
block {
|
||||||
|
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
|
||||||
|
reload:
|
||||||
|
|
||||||
|
// The IDs are added directly into the DOM to make writing this test easier.
|
||||||
|
assert-css: ("#doc-warning-1", {
|
||||||
|
"margin-bottom": "12px",
|
||||||
|
"color": |color|,
|
||||||
|
"border-left": "2px solid " + |border_color|,
|
||||||
|
"background-color": |background_color|,
|
||||||
|
})
|
||||||
|
assert-css: ("#doc-warning-2", {
|
||||||
|
"margin-bottom": "0px",
|
||||||
|
"color": |color|,
|
||||||
|
"border-left": "2px solid " + |border_color|,
|
||||||
|
"background-color": |background_color|,
|
||||||
|
})
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
call-function: ("check-warning", {
|
||||||
|
"theme": "ayu",
|
||||||
|
"color": "rgb(197, 197, 197)",
|
||||||
|
"border_color": "rgb(255, 142, 0)",
|
||||||
|
"background_color": "rgba(0, 0, 0, 0)",
|
||||||
|
})
|
||||||
|
call-function: ("check-warning", {
|
||||||
|
"theme": "dark",
|
||||||
|
"color": "rgb(221, 221, 221)",
|
||||||
|
"border_color": "rgb(255, 142, 0)",
|
||||||
|
"background_color": "rgba(0, 0, 0, 0)",
|
||||||
|
})
|
||||||
|
call-function: ("check-warning", {
|
||||||
|
"theme": "light",
|
||||||
|
"color": "rgb(0, 0, 0)",
|
||||||
|
"border_color": "rgb(255, 142, 0)",
|
||||||
|
"background_color": "rgba(0, 0, 0, 0)",
|
||||||
|
})
|
Loading…
Add table
Add a link
Reference in a new issue