Skip to content

Commit 8c1c7a7

Browse files
authored
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``
2 parents 2b53ec3 + 6c80deb commit 8c1c7a7

File tree

3 files changed

+24
-5
lines changed

3 files changed

+24
-5
lines changed

src/librustdoc/html/static/rustdoc.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -1353,7 +1353,7 @@ h4 > .notable-traits {
13531353
to prevent an overlay between the "collapse toggle" and the information tooltip.
13541354
However, it's not needed with smaller screen width because the doc/code block is always put
13551355
"one line" below. */
1356-
.information:first-child > .tooltip {
1356+
.docblock > .information:first-child > .tooltip {
13571357
margin-top: 16px;
13581358
}
13591359
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
goto: file://|DOC_PATH|/index.html
2+
goto: ./fn.check_list_code_block.html
3+
// If the codeblock is the first element of the docblock, the information tooltip must have
4+
// have some top margin to avoid going over the toggle (the "[+]").
5+
assert: (".docblock > .information > .compile_fail", { "margin-top": "16px" })
6+
// Checks that the other codeblocks don't have this top margin.
7+
assert: ("ol > li > .information > .compile_fail", { "margin-top": "0px" })
8+
assert: ("ol > li > .information > .ignore", { "margin-top": "0px" })
9+
assert: (".docblock > .information > .ignore", { "margin-top": "0px" })

src/test/rustdoc-gui/lib.rs

+14-4
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,26 @@ pub trait AnotherOne {
6262
fn hello();
6363
}
6464

65+
/// ```compile_fail
66+
/// whatever
67+
/// ```
68+
///
6569
/// Check for "i" signs in lists!
6670
///
6771
/// 1. elem 1
68-
/// 2.test 1
69-
/// ```compile_fail
70-
/// fn foo() {}
71-
/// ```
72+
/// 2. test 1
73+
/// ```compile_fail
74+
/// fn foo() {}
75+
/// ```
7276
/// 3. elem 3
7377
/// 4. ```ignore (it's a test)
7478
/// fn foo() {}
7579
/// ```
7680
/// 5. elem 5
81+
///
82+
/// Final one:
83+
///
84+
/// ```ignore (still a test)
85+
/// let x = 12;
86+
/// ```
7787
pub fn check_list_code_block() {}

0 commit comments

Comments
 (0)