Skip to content

Commit 0820bb2

Browse files
authored
Rollup merge of #105756 - notriddle:notriddle/example-wrap-tooltip, r=GuillaumeGomez
rustdoc: simplify CSS for codeblock tooltips Instead of making its parts `display: none` and then changing it on hover, just make the pseudo-element itself on hover.
2 parents 1ad070a + f28a8ca commit 0820bb2

File tree

2 files changed

+9
-15
lines changed

2 files changed

+9
-15
lines changed

src/librustdoc/html/static/css/rustdoc.css

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,8 +1118,7 @@ pre.rust .doccomment {
11181118
top: 5px;
11191119
}
11201120

1121-
.example-wrap .tooltip::after {
1122-
display: none;
1121+
.example-wrap .tooltip:hover::after {
11231122
text-align: center;
11241123
padding: 5px 3px 3px 3px;
11251124
border-radius: 6px;
@@ -1134,35 +1133,30 @@ pre.rust .doccomment {
11341133
color: var(--tooltip-color);
11351134
}
11361135

1137-
.example-wrap .tooltip::before {
1136+
.example-wrap .tooltip:hover::before {
11381137
content: " ";
11391138
position: absolute;
11401139
top: 50%;
11411140
left: 16px;
11421141
margin-top: -5px;
1143-
display: none;
11441142
z-index: 1;
11451143
border: 5px solid transparent;
11461144
border-right-color: var(--tooltip-background-color);
11471145
}
11481146

1149-
.example-wrap.ignore .tooltip::after {
1147+
.example-wrap.ignore .tooltip:hover::after {
11501148
content: "This example is not tested";
11511149
}
1152-
.example-wrap.compile_fail .tooltip::after {
1150+
.example-wrap.compile_fail .tooltip:hover::after {
11531151
content: "This example deliberately fails to compile";
11541152
}
1155-
.example-wrap.should_panic .tooltip::after {
1153+
.example-wrap.should_panic .tooltip:hover::after {
11561154
content: "This example panics";
11571155
}
1158-
.example-wrap.edition .tooltip::after {
1156+
.example-wrap.edition .tooltip:hover::after {
11591157
content: "This code runs with edition " attr(data-edition);
11601158
}
11611159

1162-
.example-wrap .tooltip:hover::before, .example-wrap .tooltip:hover::after {
1163-
display: inline;
1164-
}
1165-
11661160
.example-wrap.compile_fail .tooltip,
11671161
.example-wrap.should_panic .tooltip,
11681162
.example-wrap.ignore .tooltip {

src/test/rustdoc-gui/codeblock-tooltip.goml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ define-function: (
2020
{"border-left": "2px solid rgba(255, 0, 0, 0.5)"},
2121
)),
2222

23-
("move-cursor-to", ".docblock .example-wrap.compile_fail"),
23+
("move-cursor-to", ".docblock .example-wrap.compile_fail .tooltip"),
2424

2525
("assert-css", (
2626
".docblock .example-wrap.compile_fail .tooltip",
@@ -60,7 +60,7 @@ define-function: (
6060
{"border-left": "2px solid rgba(255, 0, 0, 0.5)"},
6161
)),
6262

63-
("move-cursor-to", ".docblock .example-wrap.should_panic"),
63+
("move-cursor-to", ".docblock .example-wrap.should_panic .tooltip"),
6464

6565
("assert-css", (
6666
".docblock .example-wrap.should_panic .tooltip",
@@ -100,7 +100,7 @@ define-function: (
100100
{"border-left": "2px solid rgba(255, 142, 0, 0.6)"},
101101
)),
102102

103-
("move-cursor-to", ".docblock .example-wrap.ignore"),
103+
("move-cursor-to", ".docblock .example-wrap.ignore .tooltip"),
104104

105105
("assert-css", (
106106
".docblock .example-wrap.ignore .tooltip",

0 commit comments

Comments
 (0)