Skip to content

Commit 85079f8

Browse files
Fix run button positionning in case of scrolling
1 parent 3bf71b3 commit 85079f8

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

src/librustdoc/html/highlight.rs

+4-7
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use syntax::token::{self, Token};
2222
pub fn render_with_highlighting(
2323
src: &str,
2424
class: Option<&str>,
25-
extension: Option<&str>,
25+
playground_button: Option<&str>,
2626
tooltip: Option<(&str, &str)>,
2727
) -> String {
2828
debug!("highlighting: ================\n{}\n==============", src);
@@ -58,10 +58,7 @@ pub fn render_with_highlighting(
5858
Ok(highlighted_source) => {
5959
write_header(class, &mut out).unwrap();
6060
write!(out, "{}", highlighted_source).unwrap();
61-
if let Some(extension) = extension {
62-
write!(out, "{}", extension).unwrap();
63-
}
64-
write_footer(&mut out).unwrap();
61+
write_footer(&mut out, playground_button).unwrap();
6562
}
6663
Err(()) => {
6764
// If errors are encountered while trying to highlight, just emit
@@ -433,6 +430,6 @@ fn write_header(class: Option<&str>, out: &mut dyn Write) -> io::Result<()> {
433430
write!(out, "<div class=\"example-wrap\"><pre class=\"rust {}\">\n", class.unwrap_or(""))
434431
}
435432

436-
fn write_footer(out: &mut dyn Write) -> io::Result<()> {
437-
write!(out, "</pre></div>\n")
433+
fn write_footer(out: &mut dyn Write, playground_button: Option<&str>) -> io::Result<()> {
434+
write!(out, "</pre>{}</div>\n", if let Some(button) = playground_button { button } else { "" })
438435
}

src/librustdoc/html/static/rustdoc.css

+3-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ summary {
136136
outline: none;
137137
}
138138

139-
code, pre {
139+
code, pre, a.test-arrow {
140140
font-family: "Source Code Pro", monospace;
141141
}
142142
.docblock code, .docblock-short code {
@@ -305,6 +305,7 @@ nav.sub {
305305
.rustdoc:not(.source) .example-wrap {
306306
display: inline-flex;
307307
margin-bottom: 10px;
308+
position: relative;
308309
}
309310

310311
.example-wrap {
@@ -878,6 +879,7 @@ a.test-arrow {
878879
font-size: 130%;
879880
top: 5px;
880881
right: 5px;
882+
z-index: 1;
881883
}
882884
a.test-arrow:hover{
883885
text-decoration: none;

0 commit comments

Comments
 (0)