rustdoc: wrap stability tags in colored spans
This commit is contained in:
parent
d30b99f9c2
commit
ea2b1b035b
6 changed files with 31 additions and 19 deletions
|
|
@ -2798,9 +2798,13 @@ fn item_module(w: &mut fmt::Formatter, cx: &Context,
|
|||
fn stability_tags(item: &clean::Item) -> String {
|
||||
let mut tags = String::new();
|
||||
|
||||
fn tag_html(class: &str, contents: &str) -> String {
|
||||
format!(r#"<span class="stab {}">{}</span>"#, class, contents)
|
||||
}
|
||||
|
||||
// The trailing space after each tag is to space it properly against the rest of the docs.
|
||||
if item.deprecation().is_some() {
|
||||
tags.push_str("[<div class='stab deprecated'>Deprecated</div>] ");
|
||||
tags += &tag_html("deprecated", "Deprecated");
|
||||
}
|
||||
|
||||
if let Some(stab) = item
|
||||
|
|
@ -2809,17 +2813,14 @@ fn stability_tags(item: &clean::Item) -> String {
|
|||
.filter(|s| s.level == stability::Unstable)
|
||||
{
|
||||
if stab.feature.as_ref().map(|s| &**s) == Some("rustc_private") {
|
||||
tags.push_str("[<div class='stab internal'>Internal</div>] ");
|
||||
tags += &tag_html("internal", "Internal");
|
||||
} else {
|
||||
tags.push_str("[<div class='stab unstable'>Experimental</div>] ");
|
||||
tags += &tag_html("unstable", "Experimental");
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(ref cfg) = item.attrs.cfg {
|
||||
tags.push_str(&format!(
|
||||
"[<div class='stab portability'>{}</div>] ",
|
||||
cfg.render_short_html()
|
||||
));
|
||||
tags += &tag_html("portability", &cfg.render_short_html());
|
||||
}
|
||||
|
||||
tags
|
||||
|
|
|
|||
|
|
@ -767,11 +767,14 @@ body.blur > :not(#help) {
|
|||
}
|
||||
|
||||
.module-item .stab {
|
||||
display: inline;
|
||||
border-width: 0;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
background: inherit !important;
|
||||
border-radius: 3px;
|
||||
display: inline-block;
|
||||
font-size: 80%;
|
||||
line-height: 1.2;
|
||||
margin-bottom: 0;
|
||||
margin-right: .3em;
|
||||
padding: 2px;
|
||||
vertical-align: text-bottom;
|
||||
}
|
||||
|
||||
.module-item.unstable {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue