Rollup merge of #68553 - GuillaumeGomez:fix-run-button-scroll-pos, r=kinnison

Fix run button positionning in case of scrolling

Fixes #68337.

r? @kinnison
This commit is contained in:
Yuki Okushi 2020-01-29 09:34:47 +09:00 committed by GitHub
commit 85f324004e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 8 deletions

View file

@ -22,7 +22,7 @@ use syntax::token::{self, Token};
pub fn render_with_highlighting(
src: &str,
class: Option<&str>,
extension: Option<&str>,
playground_button: Option<&str>,
tooltip: Option<(&str, &str)>,
) -> String {
debug!("highlighting: ================\n{}\n==============", src);
@ -58,10 +58,7 @@ pub fn render_with_highlighting(
Ok(highlighted_source) => {
write_header(class, &mut out).unwrap();
write!(out, "{}", highlighted_source).unwrap();
if let Some(extension) = extension {
write!(out, "{}", extension).unwrap();
}
write_footer(&mut out).unwrap();
write_footer(&mut out, playground_button).unwrap();
}
Err(()) => {
// 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<()> {
write!(out, "<div class=\"example-wrap\"><pre class=\"rust {}\">\n", class.unwrap_or(""))
}
fn write_footer(out: &mut dyn Write) -> io::Result<()> {
write!(out, "</pre></div>\n")
fn write_footer(out: &mut dyn Write, playground_button: Option<&str>) -> io::Result<()> {
write!(out, "</pre>{}</div>\n", if let Some(button) = playground_button { button } else { "" })
}

View file

@ -136,7 +136,7 @@ summary {
outline: none;
}
code, pre {
code, pre, a.test-arrow {
font-family: "Source Code Pro", monospace;
}
.docblock code, .docblock-short code {
@ -305,6 +305,7 @@ nav.sub {
.rustdoc:not(.source) .example-wrap {
display: inline-flex;
margin-bottom: 10px;
position: relative;
}
.example-wrap {
@ -878,6 +879,7 @@ a.test-arrow {
font-size: 130%;
top: 5px;
right: 5px;
z-index: 1;
}
a.test-arrow:hover{
text-decoration: none;