about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDylan DPC <dylan.dpc@gmail.com>2021-03-24 01:52:32 +0100
committerGitHub <noreply@github.com>2021-03-24 01:52:32 +0100
commit8c1c7a73963d9cd842197f2aaa180efe3b961ab3 (patch)
tree69e601b97b8e56d6e2d34a67b41535c0fe5676cf
parent2b53ec3d1e2acc416b069278dd55169452037850 (diff)
parent6c80deb4a5b8e9ec6dcf03e504461ec71eab69f1 (diff)
downloadrust-8c1c7a73963d9cd842197f2aaa180efe3b961ab3.tar.gz
rust-8c1c7a73963d9cd842197f2aaa180efe3b961ab3.zip
Rollup merge of #83393 - GuillaumeGomez:codeblock-tooltip-position, r=Nemo157
Codeblock tooltip position

The codeblocks tooltips were misplaced. Normally, there is no top margin applied to a tooltip unless the codeblock is the first element of the doc block. The CSS rule was too vague though, applying it to all tooltips where the codeblock was the first child of its parent. Which can be easily seen with lists:

Before:

![Screenshot from 2021-03-22 22-05-16](https://user-images.githubusercontent.com/3050060/112059812-a667ba80-8b5c-11eb-88dd-1c598ceb3766.png)

After:

![Screenshot from 2021-03-22 22-06-31](https://user-images.githubusercontent.com/3050060/112059815-a7005100-8b5c-11eb-9e40-8fc57513e498.png)

r? ``@Nemo157``
-rw-r--r--src/librustdoc/html/static/rustdoc.css2
-rw-r--r--src/test/rustdoc-gui/check_info_sign_position.goml9
-rw-r--r--src/test/rustdoc-gui/lib.rs18
3 files changed, 24 insertions, 5 deletions
diff --git a/src/librustdoc/html/static/rustdoc.css b/src/librustdoc/html/static/rustdoc.css
index a65b4ce3a03..2842bf4ba7f 100644
--- a/src/librustdoc/html/static/rustdoc.css
+++ b/src/librustdoc/html/static/rustdoc.css
@@ -1353,7 +1353,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;
 	}
 }
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 00000000000..9aa72a3ad53
--- /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 c5d9f0c5a68..c1e161e1235 100644
--- a/src/test/rustdoc-gui/lib.rs
+++ b/src/test/rustdoc-gui/lib.rs
@@ -62,16 +62,26 @@ pub trait AnotherOne {
     fn hello();
 }
 
+/// ```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() {}