Skip to content

Commit 38e1797

Browse files
committed
rustdoc: Add doc snippets for trait impls, with a read more link
Fixes rust-lang#33672
1 parent 9743c66 commit 38e1797

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/librustdoc/html/render.rs

+12
Original file line numberDiff line numberDiff line change
@@ -1657,6 +1657,17 @@ fn document(w: &mut fmt::Formatter, cx: &Context, item: &clean::Item) -> fmt::Re
16571657
Ok(())
16581658
}
16591659

1660+
fn document_short(w: &mut fmt::Formatter, item: &clean::Item, link: AssocItemLink) -> fmt::Result {
1661+
if let Some(s) = item.doc_value() {
1662+
write!(w, "<div class='docblock'>{}", Markdown(&plain_summary_line(Some(s))))?;
1663+
if s.contains('\n') {
1664+
write!(w, "<a href='{}'>Read more</a>", naive_assoc_href(item, link))?;
1665+
}
1666+
write!(w, "</div>")?;
1667+
}
1668+
Ok(())
1669+
}
1670+
16601671
fn item_module(w: &mut fmt::Formatter, cx: &Context,
16611672
item: &clean::Item, items: &[clean::Item]) -> fmt::Result {
16621673
document(w, cx, item)?;
@@ -2609,6 +2620,7 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi
26092620
if !is_default_item && (!is_static || render_static) {
26102621
document(w, cx, item)
26112622
} else {
2623+
document_short(w, item, link)?;
26122624
Ok(())
26132625
}
26142626
}

0 commit comments

Comments
 (0)