diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 88240e844edc2..2d77eaf2effd5 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -552,6 +552,14 @@ impl ItemEnum { _ => return None, }) } + + pub fn is_associated(&self) -> bool { + match *self { + ItemEnum::TypedefItem(_, _) | + ItemEnum::AssociatedTypeItem(_, _) => true, + _ => false, + } + } } #[derive(Clone, RustcEncodable, RustcDecodable, Debug)] diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 3f0ef61f375c0..8ba299d229885 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -2322,8 +2322,8 @@ fn document(w: &mut fmt::Formatter, cx: &Context, item: &clean::Item) -> fmt::Re if let Some(ref name) = item.name { info!("Documenting {}", name); } - document_stability(w, cx, item)?; - document_full(w, item, cx, "")?; + document_stability(w, cx, item, false)?; + document_full(w, item, cx, "", false)?; Ok(()) } @@ -2332,15 +2332,19 @@ fn render_markdown(w: &mut fmt::Formatter, cx: &Context, md_text: &str, links: Vec<(String, String)>, - prefix: &str) + prefix: &str, + is_hidden: bool) -> fmt::Result { let mut ids = cx.id_map.borrow_mut(); - write!(w, "
{}{}
", - prefix, Markdown(md_text, &links, RefCell::new(&mut ids), cx.codes)) + write!(w, "
{}{}
", + if is_hidden { " hidden" } else { "" }, + prefix, + Markdown(md_text, &links, RefCell::new(&mut ids), + cx.codes)) } fn document_short(w: &mut fmt::Formatter, cx: &Context, item: &clean::Item, link: AssocItemLink, - prefix: &str) -> fmt::Result { + prefix: &str, is_hidden: bool) -> fmt::Result { if let Some(s) = item.doc_value() { let markdown = if s.contains('\n') { format!("{} [Read more]({})", @@ -2348,28 +2352,33 @@ fn document_short(w: &mut fmt::Formatter, cx: &Context, item: &clean::Item, link } else { plain_summary_line(Some(s)) }; - render_markdown(w, cx, &markdown, item.links(), prefix)?; + render_markdown(w, cx, &markdown, item.links(), prefix, is_hidden)?; } else if !prefix.is_empty() { - write!(w, "
{}
", prefix)?; + write!(w, "
{}
", + if is_hidden { " hidden" } else { "" }, + prefix)?; } Ok(()) } fn document_full(w: &mut fmt::Formatter, item: &clean::Item, - cx: &Context, prefix: &str) -> fmt::Result { + cx: &Context, prefix: &str, is_hidden: bool) -> fmt::Result { if let Some(s) = cx.shared.maybe_collapsed_doc_value(item) { debug!("Doc block: =====\n{}\n=====", s); - render_markdown(w, cx, &*s, item.links(), prefix)?; + render_markdown(w, cx, &*s, item.links(), prefix, is_hidden)?; } else if !prefix.is_empty() { - write!(w, "
{}
", prefix)?; + write!(w, "
{}
", + if is_hidden { " hidden" } else { "" }, + prefix)?; } Ok(()) } -fn document_stability(w: &mut fmt::Formatter, cx: &Context, item: &clean::Item) -> fmt::Result { +fn document_stability(w: &mut fmt::Formatter, cx: &Context, item: &clean::Item, + is_hidden: bool) -> fmt::Result { let stabilities = short_stability(item, cx, true); if !stabilities.is_empty() { - write!(w, "
")?; + write!(w, "
", if is_hidden { " hidden" } else { "" })?; for stability in stabilities { write!(w, "{}", stability)?; } @@ -3934,14 +3943,21 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi RenderMode::ForDeref { mut_: deref_mut_ } => should_render_item(&item, deref_mut_), }; + let (is_hidden, extra_class) = if trait_.is_none() || + item.doc_value().is_some() || + item.inner.is_associated() { + (false, "") + } else { + (true, " hidden") + }; match item.inner { clean::MethodItem(clean::Method { ref decl, .. }) | - clean::TyMethodItem(clean::TyMethod{ ref decl, .. }) => { + clean::TyMethodItem(clean::TyMethod { ref decl, .. }) => { // Only render when the method is not static or we allow static methods if render_method_item { let id = cx.derive_id(format!("{}.{}", item_type, name)); let ns_id = cx.derive_id(format!("{}.{}", name, item_type.name_space())); - write!(w, "

", id, item_type)?; + write!(w, "

", id, item_type, extra_class)?; write!(w, "{}", spotlight_decl(decl)?)?; write!(w, "