@@ -1658,6 +1658,19 @@ fn document(w: &mut fmt::Formatter, cx: &Context, item: &clean::Item) -> fmt::Re
1658
1658
Ok ( ( ) )
1659
1659
}
1660
1660
1661
+ fn document_short ( w : & mut fmt:: Formatter , item : & clean:: Item , link : AssocItemLink ) -> fmt:: Result {
1662
+ if let Some ( s) = item. doc_value ( ) {
1663
+ let markdown = if s. contains ( '\n' ) {
1664
+ format ! ( "{} [Read more]({})" ,
1665
+ & plain_summary_line( Some ( s) ) , naive_assoc_href( item, link) )
1666
+ } else {
1667
+ format ! ( "{}" , & plain_summary_line( Some ( s) ) )
1668
+ } ;
1669
+ write ! ( w, "<div class='docblock'>{}</div>" , Markdown ( & markdown) ) ?;
1670
+ }
1671
+ Ok ( ( ) )
1672
+ }
1673
+
1661
1674
fn item_module ( w : & mut fmt:: Formatter , cx : & Context ,
1662
1675
item : & clean:: Item , items : & [ clean:: Item ] ) -> fmt:: Result {
1663
1676
document ( w, cx, item) ?;
@@ -2555,8 +2568,9 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi
2555
2568
}
2556
2569
2557
2570
fn doctraititem ( w : & mut fmt:: Formatter , cx : & Context , item : & clean:: Item ,
2558
- link : AssocItemLink , render_static : bool , is_default_item : bool ,
2559
- outer_version : Option < & str > ) -> fmt:: Result {
2571
+ link : AssocItemLink , render_static : bool ,
2572
+ is_default_item : bool , outer_version : Option < & str > ,
2573
+ trait_ : Option < & clean:: Trait > ) -> fmt:: Result {
2560
2574
let shortty = shortty ( item) ;
2561
2575
let name = item. name . as_ref ( ) . unwrap ( ) ;
2562
2576
@@ -2607,16 +2621,35 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi
2607
2621
_ => panic ! ( "can't make docs for trait item with name {:?}" , item. name)
2608
2622
}
2609
2623
2610
- if !is_default_item && ( !is_static || render_static) {
2611
- document ( w, cx, item)
2612
- } else {
2613
- Ok ( ( ) )
2624
+ if !is_static || render_static {
2625
+ if !is_default_item {
2626
+
2627
+ if item. doc_value ( ) . is_some ( ) {
2628
+ document ( w, cx, item) ?;
2629
+ } else {
2630
+ // In case the item isn't documented,
2631
+ // provide short documentation from the trait
2632
+ if let Some ( t) = trait_ {
2633
+ if let Some ( it) = t. items . iter ( )
2634
+ . find ( |i| i. name == item. name ) {
2635
+ document_short ( w, it, link) ?;
2636
+ }
2637
+ }
2638
+ }
2639
+ } else {
2640
+ document_short ( w, item, link) ?;
2641
+ }
2614
2642
}
2643
+ Ok ( ( ) )
2615
2644
}
2616
2645
2646
+ let traits = & cache ( ) . traits ;
2647
+ let trait_ = i. trait_did ( ) . and_then ( |did| traits. get ( & did) ) ;
2648
+
2617
2649
write ! ( w, "<div class='impl-items'>" ) ?;
2618
2650
for trait_item in & i. inner_impl ( ) . items {
2619
- doctraititem ( w, cx, trait_item, link, render_header, false , outer_version) ?;
2651
+ doctraititem ( w, cx, trait_item, link, render_header,
2652
+ false , outer_version, trait_) ?;
2620
2653
}
2621
2654
2622
2655
fn render_default_items ( w : & mut fmt:: Formatter ,
@@ -2634,17 +2667,15 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi
2634
2667
let assoc_link = AssocItemLink :: GotoSource ( did, & i. provided_trait_methods ) ;
2635
2668
2636
2669
doctraititem ( w, cx, trait_item, assoc_link, render_static, true ,
2637
- outer_version) ?;
2670
+ outer_version, None ) ?;
2638
2671
}
2639
2672
Ok ( ( ) )
2640
2673
}
2641
2674
2642
2675
// If we've implemented a trait, then also emit documentation for all
2643
2676
// default items which weren't overridden in the implementation block.
2644
- if let Some ( did) = i. trait_did ( ) {
2645
- if let Some ( t) = cache ( ) . traits . get ( & did) {
2646
- render_default_items ( w, cx, t, & i. inner_impl ( ) , render_header, outer_version) ?;
2647
- }
2677
+ if let Some ( t) = trait_ {
2678
+ render_default_items ( w, cx, t, & i. inner_impl ( ) , render_header, outer_version) ?;
2648
2679
}
2649
2680
write ! ( w, "</div>" ) ?;
2650
2681
Ok ( ( ) )
0 commit comments