Skip to content

Commit

Permalink
rustdoc: Add doc snippets for trait impls, with a read more link
Browse files Browse the repository at this point in the history
Fixes #33672
  • Loading branch information
Manishearth committed May 18, 2016
1 parent 9743c66 commit 38e1797
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/librustdoc/html/render.rs
Expand Up @@ -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, "<div class='docblock'>{}", Markdown(&plain_summary_line(Some(s))))?;
if s.contains('\n') {
write!(w, "<a href='{}'>Read more</a>", naive_assoc_href(item, link))?;
}
write!(w, "</div>")?;
}
Ok(())
}

fn item_module(w: &mut fmt::Formatter, cx: &Context,
item: &clean::Item, items: &[clean::Item]) -> fmt::Result {
document(w, cx, item)?;
Expand Down Expand Up @@ -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(())
}
}
Expand Down

0 comments on commit 38e1797

Please sign in to comment.