From 38e179769e096fe9d42729447dbe444ef2cf9a57 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Tue, 17 May 2016 06:50:39 +0530 Subject: [PATCH] rustdoc: Add doc snippets for trait impls, with a read more link Fixes #33672 --- src/librustdoc/html/render.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 005e25b07d42..fc91fd2ac62a 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -1657,6 +1657,17 @@ fn document(w: &mut fmt::Formatter, cx: &Context, item: &clean::Item) -> fmt::Re Ok(()) } +fn document_short(w: &mut fmt::Formatter, item: &clean::Item, link: AssocItemLink) -> fmt::Result { + if let Some(s) = item.doc_value() { + write!(w, "
{}", Markdown(&plain_summary_line(Some(s))))?; + if s.contains('\n') { + write!(w, "Read more", naive_assoc_href(item, link))?; + } + write!(w, "
")?; + } + Ok(()) +} + fn item_module(w: &mut fmt::Formatter, cx: &Context, item: &clean::Item, items: &[clean::Item]) -> fmt::Result { document(w, cx, item)?; @@ -2609,6 +2620,7 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi if !is_default_item && (!is_static || render_static) { document(w, cx, item) } else { + document_short(w, item, link)?; Ok(()) } }