Skip to content

Commit

Permalink
Rollup merge of rust-lang#92058 - jsha:run-on-hover, r=GuillaumeGomez
Browse files Browse the repository at this point in the history
Make Run button visible on hover

This slightly reduces the noisiness of doc pages, making them easier to read.

Demo: https://rustdoc.crud.net/jsha/run-on-hover/std/string/struct.String.html

[Discussed on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/.22Run.22.20button.20visible.20on.20hover).

Part of rust-lang#59845
  • Loading branch information
matthiaskrgr authored Jan 6, 2022
2 parents f1ce0e6 + 6409f0d commit 50d5e38
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/librustdoc/html/static/css/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -1117,6 +1117,7 @@ pre.rust .question-mark {

a.test-arrow {
display: inline-block;
visibility: hidden;
position: absolute;
padding: 5px 10px 5px 10px;
border-radius: 5px;
Expand All @@ -1125,10 +1126,12 @@ a.test-arrow {
right: 5px;
z-index: 1;
}
.example-wrap:hover .test-arrow {
visibility: visible;
}
a.test-arrow:hover{
text-decoration: none;
}

.section-header:hover a:before {
position: absolute;
left: -25px;
Expand Down
7 changes: 7 additions & 0 deletions src/test/rustdoc-gui/run-on-hover.goml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Example code blocks sometimes have a "Run" button to run them on the
// Playground. That button is hidden until the user hovers over the code block.
// This test checks that it is hidden, and that it shows on hover.
goto: file://|DOC_PATH|/test_docs/fn.foo.html
assert-css: (".test-arrow", {"visibility": "hidden"})
move-cursor-to: ".example-wrap"
assert-css: (".test-arrow", {"visibility": "visible"})
1 change: 1 addition & 0 deletions src/test/rustdoc-gui/src/test_docs/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! The point of this crate is to be able to have enough different "kinds" of
//! documentation generated so we can test each different features.
#![doc(html_playground_url="https://play.rust-lang.org/")]

#![crate_name = "test_docs"]
#![feature(rustdoc_internals)]
Expand Down

0 comments on commit 50d5e38

Please sign in to comment.