From 494e29deeaa9759b71df8183c00abb72a12575d8 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 22 Mar 2021 22:17:21 +0100 Subject: [PATCH 1/2] Fix codeblock tooltip position --- src/librustdoc/html/static/rustdoc.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustdoc/html/static/rustdoc.css b/src/librustdoc/html/static/rustdoc.css index 4f287cde73b1b..f20619765a9dc 100644 --- a/src/librustdoc/html/static/rustdoc.css +++ b/src/librustdoc/html/static/rustdoc.css @@ -1346,7 +1346,7 @@ h4 > .notable-traits { to prevent an overlay between the "collapse toggle" and the information tooltip. However, it's not needed with smaller screen width because the doc/code block is always put "one line" below. */ - .information:first-child > .tooltip { + .docblock > .information:first-child > .tooltip { margin-top: 16px; } } From 6c80deb4a5b8e9ec6dcf03e504461ec71eab69f1 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 22 Mar 2021 22:17:43 +0100 Subject: [PATCH 2/2] Add GUI test to enforce tooltip position --- .../rustdoc-gui/check_info_sign_position.goml | 9 +++++++++ src/test/rustdoc-gui/lib.rs | 18 ++++++++++++++---- 2 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 src/test/rustdoc-gui/check_info_sign_position.goml diff --git a/src/test/rustdoc-gui/check_info_sign_position.goml b/src/test/rustdoc-gui/check_info_sign_position.goml new file mode 100644 index 0000000000000..9aa72a3ad53e7 --- /dev/null +++ b/src/test/rustdoc-gui/check_info_sign_position.goml @@ -0,0 +1,9 @@ +goto: file://|DOC_PATH|/index.html +goto: ./fn.check_list_code_block.html +// If the codeblock is the first element of the docblock, the information tooltip must have +// have some top margin to avoid going over the toggle (the "[+]"). +assert: (".docblock > .information > .compile_fail", { "margin-top": "16px" }) +// Checks that the other codeblocks don't have this top margin. +assert: ("ol > li > .information > .compile_fail", { "margin-top": "0px" }) +assert: ("ol > li > .information > .ignore", { "margin-top": "0px" }) +assert: (".docblock > .information > .ignore", { "margin-top": "0px" }) diff --git a/src/test/rustdoc-gui/lib.rs b/src/test/rustdoc-gui/lib.rs index 15d8dcc6e8444..4c3007e49d93e 100644 --- a/src/test/rustdoc-gui/lib.rs +++ b/src/test/rustdoc-gui/lib.rs @@ -57,16 +57,26 @@ pub trait AnotherOne { fn func3(); } +/// ```compile_fail +/// whatever +/// ``` +/// /// Check for "i" signs in lists! /// /// 1. elem 1 -/// 2.test 1 -/// ```compile_fail -/// fn foo() {} -/// ``` +/// 2. test 1 +/// ```compile_fail +/// fn foo() {} +/// ``` /// 3. elem 3 /// 4. ```ignore (it's a test) /// fn foo() {} /// ``` /// 5. elem 5 +/// +/// Final one: +/// +/// ```ignore (still a test) +/// let x = 12; +/// ``` pub fn check_list_code_block() {}