Skip to content

Commit

Permalink
Fix run button positionning in case of scrolling
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Jan 26, 2020
1 parent 3bf71b3 commit 85079f8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
11 changes: 4 additions & 7 deletions src/librustdoc/html/highlight.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 { "" })
}
4 changes: 3 additions & 1 deletion src/librustdoc/html/static/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -305,6 +305,7 @@ nav.sub {
.rustdoc:not(.source) .example-wrap {
display: inline-flex;
margin-bottom: 10px;
position: relative;
}

.example-wrap {
Expand Down Expand Up @@ -878,6 +879,7 @@ a.test-arrow {
font-size: 130%;
top: 5px;
right: 5px;
z-index: 1;
}
a.test-arrow:hover{
text-decoration: none;
Expand Down

0 comments on commit 85079f8

Please sign in to comment.