Skip to content

Commit a2faf54

Browse files
Set run button transparent instead of invisible
1 parent cf0cdc4 commit a2faf54

File tree

5 files changed

+17
-20
lines changed

5 files changed

+17
-20
lines changed

src/librustdoc/html/highlight.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ use syntax::parse;
3333
use syntax_pos::Span;
3434

3535
/// Highlights `src`, returning the HTML output.
36-
pub fn render_with_highlighting(src: &str, class: Option<&str>, id: Option<&str>) -> String {
36+
pub fn render_with_highlighting(src: &str, class: Option<&str>, id: Option<&str>,
37+
extension: Option<&str>) -> String {
3738
debug!("highlighting: ================\n{}\n==============", src);
3839
let sess = parse::ParseSess::new();
3940
let fm = sess.codemap().new_filemap("<stdin>".to_string(), None, src.to_string());
@@ -47,6 +48,9 @@ pub fn render_with_highlighting(src: &str, class: Option<&str>, id: Option<&str>
4748
return format!("<pre>{}</pre>", src);
4849
}
4950

51+
if let Some(extension) = extension {
52+
write!(out, "{}", extension).unwrap();
53+
}
5054
write_footer(&mut out).unwrap();
5155
String::from_utf8_lossy(&out[..]).into_owned()
5256
}

src/librustdoc/html/markdown.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,9 +262,11 @@ pub fn render(w: &mut fmt::Formatter, s: &str, print_toc: bool) -> fmt::Result {
262262
&Default::default());
263263
s.push_str(&format!("<span class='rusttest'>{}</span>", Escape(&test)));
264264
});
265-
s.push_str(&highlight::render_with_highlighting(&text,
266-
Some("rust-example-rendered"),
267-
None));
265+
s.push_str(&highlight::render_with_highlighting(
266+
&text,
267+
Some("rust-example-rendered"),
268+
None,
269+
Some("<a class='test-arrow' target='_blank' href=''>Run</a>")));
268270
let output = CString::new(s).unwrap();
269271
hoedown_buffer_puts(ob, output.as_ptr());
270272
})

src/librustdoc/html/render.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2909,7 +2909,7 @@ impl<'a> fmt::Display for Source<'a> {
29092909
write!(fmt, "<span id=\"{0}\">{0:1$}</span>\n", i, cols)?;
29102910
}
29112911
write!(fmt, "</pre>")?;
2912-
write!(fmt, "{}", highlight::render_with_highlighting(s, None, None))?;
2912+
write!(fmt, "{}", highlight::render_with_highlighting(s, None, None, None))?;
29132913
Ok(())
29142914
}
29152915
}
@@ -2918,6 +2918,7 @@ fn item_macro(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
29182918
t: &clean::Macro) -> fmt::Result {
29192919
w.write_str(&highlight::render_with_highlighting(&t.source,
29202920
Some("macro"),
2921+
None,
29212922
None))?;
29222923
render_stability_since_raw(w, it.stable_since(), None)?;
29232924
document(w, cx, it)

src/librustdoc/html/static/playpen.js

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@ document.addEventListener('DOMContentLoaded', function() {
2727
return;
2828
}
2929

30-
var a = document.createElement('a');
31-
a.setAttribute('class', 'test-arrow');
32-
a.textContent = 'Run';
30+
var a = el.querySelectorAll('a.test-arrow')[0];
3331

3432
var code = el.previousElementSibling.textContent;
3533

@@ -40,17 +38,6 @@ document.addEventListener('DOMContentLoaded', function() {
4038

4139
a.setAttribute('href', window.playgroundUrl + '?code=' +
4240
encodeURIComponent(code) + channel);
43-
a.setAttribute('target', '_blank');
44-
45-
el.appendChild(a);
46-
};
47-
48-
el.onmouseout = function(e) {
49-
if (el.contains(e.relatedTarget)) {
50-
return;
51-
}
52-
53-
el.removeChild(el.querySelectorAll('a.test-arrow')[0]);
5441
};
5542
});
5643
});

src/librustdoc/html/static/rustdoc.css

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,15 +568,18 @@ pre.rust .lifetime { color: #B76514; }
568568
.rusttest { display: none; }
569569
pre.rust { position: relative; }
570570
a.test-arrow {
571+
background-color: rgba(78, 139, 202, 0.2);
571572
display: inline-block;
572573
position: absolute;
573-
background-color: #4e8bca;
574574
padding: 5px 10px 5px 10px;
575575
border-radius: 5px;
576576
font-size: 130%;
577577
top: 5px;
578578
right: 5px;
579579
}
580+
a.test-arrow:hover{
581+
background-color: #4e8bca;
582+
}
580583

581584
.section-header:hover a:after {
582585
content: '\2002\00a7\2002';

0 commit comments

Comments
 (0)