@@ -1628,55 +1628,47 @@ fn plain_summary_line(s: Option<&str>) -> String {
16281628
16291629fn document ( w : & mut fmt:: Formatter , cx : & Context , item : & clean:: Item ) -> fmt:: Result {
16301630 document_stability ( w, cx, item) ?;
1631- document_full ( w, item, cx. render_type ) ?;
1631+ let prefix = render_assoc_const_value ( item) ;
1632+ document_full ( w, item, cx. render_type , & prefix) ?;
16321633 Ok ( ( ) )
16331634}
16341635
16351636fn document_short ( w : & mut fmt:: Formatter , item : & clean:: Item , link : AssocItemLink ,
1636- render_type : RenderType ) -> fmt:: Result {
1637+ render_type : RenderType , prefix : & str ) -> fmt:: Result {
16371638 if let Some ( s) = item. doc_value ( ) {
16381639 let markdown = if s. contains ( '\n' ) {
16391640 format ! ( "{} [Read more]({})" ,
16401641 & plain_summary_line( Some ( s) ) , naive_assoc_href( item, link) )
16411642 } else {
16421643 format ! ( "{}" , & plain_summary_line( Some ( s) ) )
16431644 } ;
1644- write ! ( w, "<div class='docblock'>{}</div>" ,
1645- Markdown ( & markdown, render_type) ) ?;
1645+ write ! ( w, "<div class='docblock'>{}{}</div>" , prefix, Markdown ( & markdown, render_type) ) ?;
1646+ } else if !prefix. is_empty ( ) {
1647+ write ! ( w, "<div class='docblock'>{}</div>" , prefix) ?;
16461648 }
16471649 Ok ( ( ) )
16481650}
16491651
1650- fn md_render_assoc_item ( item : & clean:: Item ) -> String {
1652+ fn render_assoc_const_value ( item : & clean:: Item ) -> String {
16511653 match item. inner {
1652- clean:: AssociatedConstItem ( ref ty, ref default) => {
1653- if let Some ( default) = default. as_ref ( ) {
1654- format ! ( "```\n {}: {:#} = {}\n ```\n \n " , item. name. as_ref( ) . unwrap( ) , ty, default )
1655- } else {
1656- format ! ( "```\n {}: {:#}\n ```\n \n " , item. name. as_ref( ) . unwrap( ) , ty)
1657- }
1654+ clean:: AssociatedConstItem ( ref ty, Some ( ref default) ) => {
1655+ highlight:: render_with_highlighting (
1656+ & format ! ( "{}: {:#} = {}" , item. name. as_ref( ) . unwrap( ) , ty, default ) ,
1657+ None ,
1658+ None ,
1659+ None ,
1660+ )
16581661 }
16591662 _ => String :: new ( ) ,
16601663 }
16611664}
16621665
1663- fn get_doc_value ( item : & clean:: Item ) -> Option < & str > {
1664- let x = item. doc_value ( ) ;
1665- if x. is_none ( ) {
1666- match item. inner {
1667- clean:: AssociatedConstItem ( _, _) => Some ( "" ) ,
1668- _ => None ,
1669- }
1670- } else {
1671- x
1672- }
1673- }
1674-
16751666fn document_full ( w : & mut fmt:: Formatter , item : & clean:: Item ,
1676- render_type : RenderType ) -> fmt:: Result {
1677- if let Some ( s) = get_doc_value ( item) {
1678- write ! ( w, "<div class='docblock'>{}</div>" ,
1679- Markdown ( & format!( "{}{}" , md_render_assoc_item( item) , s) , render_type) ) ?;
1667+ render_type : RenderType , prefix : & str ) -> fmt:: Result {
1668+ if let Some ( s) = item. doc_value ( ) {
1669+ write ! ( w, "<div class='docblock'>{}{}</div>" , prefix, Markdown ( s, render_type) ) ?;
1670+ } else if !prefix. is_empty ( ) {
1671+ write ! ( w, "<div class='docblock'>{}</div>" , prefix) ?;
16801672 }
16811673 Ok ( ( ) )
16821674}
@@ -2960,14 +2952,6 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi
29602952 assoc_const ( w, item, ty, default. as_ref ( ) , link. anchor ( & id) ) ?;
29612953 write ! ( w, "</code></span></h4>\n " ) ?;
29622954 }
2963- clean:: ConstantItem ( ref c) => {
2964- let id = derive_id ( format ! ( "{}.{}" , item_type, name) ) ;
2965- let ns_id = derive_id ( format ! ( "{}.{}" , name, item_type. name_space( ) ) ) ;
2966- write ! ( w, "<h4 id='{}' class=\" {}\" >" , id, item_type) ?;
2967- write ! ( w, "<span id='{}' class='invisible'><code>" , ns_id) ?;
2968- assoc_const ( w, item, & c. type_ , Some ( & c. expr ) , link. anchor ( & id) ) ?;
2969- write ! ( w, "</code></span></h4>\n " ) ?;
2970- }
29712955 clean:: AssociatedTypeItem ( ref bounds, ref default) => {
29722956 let id = derive_id ( format ! ( "{}.{}" , item_type, name) ) ;
29732957 let ns_id = derive_id ( format ! ( "{}.{}" , name, item_type. name_space( ) ) ) ;
@@ -2981,6 +2965,7 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi
29812965 }
29822966
29832967 if render_method_item || render_mode == RenderMode :: Normal {
2968+ let prefix = render_assoc_const_value ( item) ;
29842969 if !is_default_item {
29852970 if let Some ( t) = trait_ {
29862971 // The trait item may have been stripped so we might not
@@ -2989,20 +2974,21 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi
29892974 // We need the stability of the item from the trait
29902975 // because impls can't have a stability.
29912976 document_stability ( w, cx, it) ?;
2992- if get_doc_value ( item) . is_some ( ) {
2993- document_full ( w, item, cx. render_type ) ?;
2977+ if item. doc_value ( ) . is_some ( ) {
2978+ document_full ( w, item, cx. render_type , & prefix ) ?;
29942979 } else {
29952980 // In case the item isn't documented,
29962981 // provide short documentation from the trait.
2997- document_short ( w, it, link, cx. render_type ) ?;
2982+ document_short ( w, it, link, cx. render_type , & prefix ) ?;
29982983 }
29992984 }
30002985 } else {
3001- document ( w, cx, item) ?;
2986+ document_stability ( w, cx, item) ?;
2987+ document_full ( w, item, cx. render_type , & prefix) ?;
30022988 }
30032989 } else {
30042990 document_stability ( w, cx, item) ?;
3005- document_short ( w, item, link, cx. render_type ) ?;
2991+ document_short ( w, item, link, cx. render_type , & prefix ) ?;
30062992 }
30072993 }
30082994 Ok ( ( ) )
0 commit comments