1
Fork 0

Rename "stability" CSS class to "item-info"

This commit is contained in:
Guillaume Gomez 2020-11-23 13:20:16 +01:00
parent 53d19b37c5
commit caf6c5790a
8 changed files with 59 additions and 53 deletions

View file

@ -1844,7 +1844,7 @@ fn document(w: &mut Buffer, cx: &Context, item: &clean::Item, parent: Option<&cl
if let Some(ref name) = item.name {
info!("Documenting {}", name);
}
document_stability(w, cx, item, false, parent);
document_item_info(w, cx, item, false, parent);
document_full(w, item, cx, "", false);
}
@ -1928,18 +1928,23 @@ fn document_full(w: &mut Buffer, item: &clean::Item, cx: &Context, prefix: &str,
}
}
fn document_stability(
/// Add extra information about an item such as:
///
/// * Stability
/// * Deprecated
/// * Required features (through the `doc_cfg` feature)
fn document_item_info(
w: &mut Buffer,
cx: &Context,
item: &clean::Item,
is_hidden: bool,
parent: Option<&clean::Item>,
) {
let stabilities = short_stability(item, cx, parent);
if !stabilities.is_empty() {
write!(w, "<div class=\"stability{}\">", if is_hidden { " hidden" } else { "" });
for stability in stabilities {
write!(w, "{}", stability);
let item_infos = short_item_info(item, cx, parent);
if !item_infos.is_empty() {
write!(w, "<div class=\"item-info{}\">", if is_hidden { " hidden" } else { "" });
for info in item_infos {
write!(w, "{}", info);
}
write!(w, "</div>");
}
@ -2194,7 +2199,7 @@ fn item_module(w: &mut Buffer, cx: &Context, item: &clean::Item, items: &[clean:
<td class=\"docblock-short\">{stab_tags}{docs}</td>\
</tr>",
name = *myitem.name.as_ref().unwrap(),
stab_tags = stability_tags(myitem, item),
stab_tags = extra_info_tags(myitem, item),
docs = MarkdownSummaryLine(doc_value, &myitem.links()).into_string(),
class = myitem.type_(),
add = add,
@ -2216,9 +2221,9 @@ fn item_module(w: &mut Buffer, cx: &Context, item: &clean::Item, items: &[clean:
}
}
/// Render the stability and deprecation tags that are displayed in the item's summary at the
/// module level.
fn stability_tags(item: &clean::Item, parent: &clean::Item) -> String {
/// Render the stability, deprecation and portability tags that are displayed in the item's summary
/// at the module level.
fn extra_info_tags(item: &clean::Item, parent: &clean::Item) -> String {
let mut tags = String::new();
fn tag_html(class: &str, title: &str, contents: &str) -> String {
@ -2271,10 +2276,10 @@ fn portability(item: &clean::Item, parent: Option<&clean::Item>) -> Option<Strin
Some(format!("<div class=\"stab portability\">{}</div>", cfg?.render_long_html()))
}
/// Render the stability and/or deprecation warning that is displayed at the top of the item's
/// documentation.
fn short_stability(item: &clean::Item, cx: &Context, parent: Option<&clean::Item>) -> Vec<String> {
let mut stability = vec![];
/// Render the stability, deprecation and portability information that is displayed at the top of
/// the item's documentation.
fn short_item_info(item: &clean::Item, cx: &Context, parent: Option<&clean::Item>) -> Vec<String> {
let mut extra_info = vec![];
let error_codes = cx.shared.codes;
if let Some(Deprecation { ref note, ref since, is_since_rustc_version }) = item.deprecation {
@ -2301,7 +2306,7 @@ fn short_stability(item: &clean::Item, cx: &Context, parent: Option<&clean::Item
);
message.push_str(&format!(": {}", html.into_string()));
}
stability.push(format!(
extra_info.push(format!(
"<div class=\"stab deprecated\"><span class=\"emoji\">👎</span> {}</div>",
message,
));
@ -2345,14 +2350,14 @@ fn short_stability(item: &clean::Item, cx: &Context, parent: Option<&clean::Item
);
}
stability.push(format!("<div class=\"stab unstable\">{}</div>", message));
extra_info.push(format!("<div class=\"stab unstable\">{}</div>", message));
}
if let Some(portability) = portability(item, parent) {
stability.push(portability);
extra_info.push(portability);
}
stability
extra_info
}
fn item_constant(w: &mut Buffer, cx: &Context, it: &clean::Item, c: &clean::Constant) {
@ -3703,7 +3708,7 @@ fn render_impl(
if trait_.is_some() {
if let Some(portability) = portability(&i.impl_item, Some(parent)) {
write!(w, "<div class=\"stability\">{}</div>", portability);
write!(w, "<div class=\"item-info\">{}</div>", portability);
}
}
@ -3801,7 +3806,7 @@ fn render_impl(
if let Some(it) = t.items.iter().find(|i| i.name == item.name) {
// We need the stability of the item from the trait
// because impls can't have a stability.
document_stability(w, cx, it, is_hidden, Some(parent));
document_item_info(w, cx, it, is_hidden, Some(parent));
if item.doc_value().is_some() {
document_full(w, item, cx, "", is_hidden);
} else if show_def_docs {
@ -3811,13 +3816,13 @@ fn render_impl(
}
}
} else {
document_stability(w, cx, item, is_hidden, Some(parent));
document_item_info(w, cx, item, is_hidden, Some(parent));
if show_def_docs {
document_full(w, item, cx, "", is_hidden);
}
}
} else {
document_stability(w, cx, item, is_hidden, Some(parent));
document_item_info(w, cx, item, is_hidden, Some(parent));
if show_def_docs {
document_short(w, item, link, "", is_hidden);
}