diff options
| author | bors <bors@rust-lang.org> | 2023-08-21 09:26:02 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-08-21 09:26:02 +0000 |
| commit | 5e9d3d8a03fadf1877286528e5c9d0c056ac82b5 (patch) | |
| tree | 0e0cca951a100efb438f09aabfd61021f3016419 /tests | |
| parent | c40cfcf0494ff7506e753e750adb00eeea839f9c (diff) | |
| parent | 1d42913058d4005655ea51b2d9dde707791c6541 (diff) | |
| download | rust-5e9d3d8a03fadf1877286528e5c9d0c056ac82b5.tar.gz rust-5e9d3d8a03fadf1877286528e5c9d0c056ac82b5.zip | |
Auto merge of #106561 - GuillaumeGomez:warning-block, r=rustdoc
Add warning block support in rustdoc Fixes https://github.com/rust-lang/rust/issues/79710. You can test it [here](https://rustdoc.crud.net/imperio/warning-block/foo/struct.Foo.html). It currently looks like this:  So a few things to note: * Since it's a new add and it's changing the UI, we'll need to go through an FCP. * Does the UI looks good? * Is the way picked to add a warning block ok for everyone? The discussion on the issue seemed to be in favour of this solution but it doesn't hurt to double-check. cc `@rust-lang/rustdoc`
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/rustdoc-gui/src/test_docs/lib.rs | 12 | ||||
| -rw-r--r-- | tests/rustdoc-gui/warning-block.goml | 45 |
2 files changed, 57 insertions, 0 deletions
diff --git a/tests/rustdoc-gui/src/test_docs/lib.rs b/tests/rustdoc-gui/src/test_docs/lib.rs index 49484ee0869..38180aef762 100644 --- a/tests/rustdoc-gui/src/test_docs/lib.rs +++ b/tests/rustdoc-gui/src/test_docs/lib.rs @@ -65,6 +65,18 @@ impl Foo { pub fn must_use(&self) -> bool { 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 { diff --git a/tests/rustdoc-gui/warning-block.goml b/tests/rustdoc-gui/warning-block.goml new file mode 100644 index 00000000000..2a935bd1a9b --- /dev/null +++ b/tests/rustdoc-gui/warning-block.goml @@ -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)", +}) |
