diff --git a/src/librustdoc/html/highlight.rs b/src/librustdoc/html/highlight.rs
index 6cb79d6e8630f..855588a4c3a4b 100644
--- a/src/librustdoc/html/highlight.rs
+++ b/src/librustdoc/html/highlight.rs
@@ -33,7 +33,8 @@ use syntax::parse;
use syntax_pos::Span;
/// Highlights `src`, returning the HTML output.
-pub fn render_with_highlighting(src: &str, class: Option<&str>, id: Option<&str>) -> String {
+pub fn render_with_highlighting(src: &str, class: Option<&str>, id: Option<&str>,
+ extension: Option<&str>) -> String {
debug!("highlighting: ================\n{}\n==============", src);
let sess = parse::ParseSess::new();
let fm = sess.codemap().new_filemap("".to_string(), None, src.to_string());
@@ -47,6 +48,9 @@ pub fn render_with_highlighting(src: &str, class: Option<&str>, id: Option<&str>
return format!("{}
", src);
}
+ if let Some(extension) = extension {
+ write!(out, "{}", extension).unwrap();
+ }
write_footer(&mut out).unwrap();
String::from_utf8_lossy(&out[..]).into_owned()
}
diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs
index 139e1033175ea..aff5a964f75cc 100644
--- a/src/librustdoc/html/markdown.rs
+++ b/src/librustdoc/html/markdown.rs
@@ -262,9 +262,11 @@ pub fn render(w: &mut fmt::Formatter, s: &str, print_toc: bool) -> fmt::Result {
&Default::default());
s.push_str(&format!("{}", Escape(&test)));
});
- s.push_str(&highlight::render_with_highlighting(&text,
- Some("rust-example-rendered"),
- None));
+ s.push_str(&highlight::render_with_highlighting(
+ &text,
+ Some("rust-example-rendered"),
+ None,
+ Some("Run")));
let output = CString::new(s).unwrap();
hoedown_buffer_puts(ob, output.as_ptr());
})
diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs
index 4c6ac56105c67..147710c39f477 100644
--- a/src/librustdoc/html/render.rs
+++ b/src/librustdoc/html/render.rs
@@ -2909,7 +2909,7 @@ impl<'a> fmt::Display for Source<'a> {
write!(fmt, "{0:1$}\n", i, cols)?;
}
write!(fmt, "")?;
- write!(fmt, "{}", highlight::render_with_highlighting(s, None, None))?;
+ write!(fmt, "{}", highlight::render_with_highlighting(s, None, None, None))?;
Ok(())
}
}
@@ -2918,6 +2918,7 @@ fn item_macro(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
t: &clean::Macro) -> fmt::Result {
w.write_str(&highlight::render_with_highlighting(&t.source,
Some("macro"),
+ None,
None))?;
render_stability_since_raw(w, it.stable_since(), None)?;
document(w, cx, it)
diff --git a/src/librustdoc/html/static/playpen.js b/src/librustdoc/html/static/playpen.js
index 8f8a753b06c96..cad97c04e1ac0 100644
--- a/src/librustdoc/html/static/playpen.js
+++ b/src/librustdoc/html/static/playpen.js
@@ -27,9 +27,7 @@ document.addEventListener('DOMContentLoaded', function() {
return;
}
- var a = document.createElement('a');
- a.setAttribute('class', 'test-arrow');
- a.textContent = 'Run';
+ var a = el.querySelectorAll('a.test-arrow')[0];
var code = el.previousElementSibling.textContent;
@@ -40,17 +38,6 @@ document.addEventListener('DOMContentLoaded', function() {
a.setAttribute('href', window.playgroundUrl + '?code=' +
encodeURIComponent(code) + channel);
- a.setAttribute('target', '_blank');
-
- el.appendChild(a);
- };
-
- el.onmouseout = function(e) {
- if (el.contains(e.relatedTarget)) {
- return;
- }
-
- el.removeChild(el.querySelectorAll('a.test-arrow')[0]);
};
});
});
diff --git a/src/librustdoc/html/static/rustdoc.css b/src/librustdoc/html/static/rustdoc.css
index c97cacd10c381..2884320b82ebd 100644
--- a/src/librustdoc/html/static/rustdoc.css
+++ b/src/librustdoc/html/static/rustdoc.css
@@ -568,15 +568,18 @@ pre.rust .lifetime { color: #B76514; }
.rusttest { display: none; }
pre.rust { position: relative; }
a.test-arrow {
+ background-color: rgba(78, 139, 202, 0.2);
display: inline-block;
position: absolute;
- background-color: #4e8bca;
padding: 5px 10px 5px 10px;
border-radius: 5px;
font-size: 130%;
top: 5px;
right: 5px;
}
+a.test-arrow:hover{
+ background-color: #4e8bca;
+}
.section-header:hover a:after {
content: '\2002\00a7\2002';