@@ -1844,7 +1844,7 @@ fn document(w: &mut Buffer, cx: &Context, item: &clean::Item, parent: Option<&cl
18441844 if let Some ( ref name) = item. name {
18451845 info ! ( "Documenting {}" , name) ;
18461846 }
1847- document_stability ( w, cx, item, false , parent) ;
1847+ document_item_info ( w, cx, item, false , parent) ;
18481848 document_full ( w, item, cx, "" , false ) ;
18491849}
18501850
@@ -1880,10 +1880,17 @@ fn render_markdown(
18801880fn document_short (
18811881 w : & mut Buffer ,
18821882 item : & clean:: Item ,
1883+ cx : & Context ,
18831884 link : AssocItemLink < ' _ > ,
18841885 prefix : & str ,
18851886 is_hidden : bool ,
1887+ parent : Option < & clean:: Item > ,
1888+ show_def_docs : bool ,
18861889) {
1890+ document_item_info ( w, cx, item, is_hidden, parent) ;
1891+ if !show_def_docs {
1892+ return ;
1893+ }
18871894 if let Some ( s) = item. doc_value ( ) {
18881895 let mut summary_html = MarkdownSummaryLine ( s, & item. links ( ) ) . into_string ( ) ;
18891896
@@ -1928,18 +1935,23 @@ fn document_full(w: &mut Buffer, item: &clean::Item, cx: &Context, prefix: &str,
19281935 }
19291936}
19301937
1931- fn document_stability (
1938+ /// Add extra information about an item such as:
1939+ ///
1940+ /// * Stability
1941+ /// * Deprecated
1942+ /// * Required features (through the `doc_cfg` feature)
1943+ fn document_item_info (
19321944 w : & mut Buffer ,
19331945 cx : & Context ,
19341946 item : & clean:: Item ,
19351947 is_hidden : bool ,
19361948 parent : Option < & clean:: Item > ,
19371949) {
1938- let stabilities = short_stability ( item, cx, parent) ;
1939- if !stabilities . is_empty ( ) {
1940- write ! ( w, "<div class=\" stability {}\" >" , if is_hidden { " hidden" } else { "" } ) ;
1941- for stability in stabilities {
1942- write ! ( w, "{}" , stability ) ;
1950+ let item_infos = short_item_info ( item, cx, parent) ;
1951+ if !item_infos . is_empty ( ) {
1952+ write ! ( w, "<div class=\" item-info {}\" >" , if is_hidden { " hidden" } else { "" } ) ;
1953+ for info in item_infos {
1954+ write ! ( w, "{}" , info ) ;
19431955 }
19441956 write ! ( w, "</div>" ) ;
19451957 }
@@ -2194,7 +2206,7 @@ fn item_module(w: &mut Buffer, cx: &Context, item: &clean::Item, items: &[clean:
21942206 <td class=\" docblock-short\" >{stab_tags}{docs}</td>\
21952207 </tr>",
21962208 name = * myitem. name. as_ref( ) . unwrap( ) ,
2197- stab_tags = stability_tags ( myitem, item) ,
2209+ stab_tags = extra_info_tags ( myitem, item) ,
21982210 docs = MarkdownSummaryLine ( doc_value, & myitem. links( ) ) . into_string( ) ,
21992211 class = myitem. type_( ) ,
22002212 add = add,
@@ -2216,9 +2228,9 @@ fn item_module(w: &mut Buffer, cx: &Context, item: &clean::Item, items: &[clean:
22162228 }
22172229}
22182230
2219- /// Render the stability and deprecation tags that are displayed in the item's summary at the
2220- /// module level.
2221- fn stability_tags ( item : & clean:: Item , parent : & clean:: Item ) -> String {
2231+ /// Render the stability, deprecation and portability tags that are displayed in the item's summary
2232+ /// at the module level.
2233+ fn extra_info_tags ( item : & clean:: Item , parent : & clean:: Item ) -> String {
22222234 let mut tags = String :: new ( ) ;
22232235
22242236 fn tag_html ( class : & str , title : & str , contents : & str ) -> String {
@@ -2271,10 +2283,10 @@ fn portability(item: &clean::Item, parent: Option<&clean::Item>) -> Option<Strin
22712283 Some ( format ! ( "<div class=\" stab portability\" >{}</div>" , cfg?. render_long_html( ) ) )
22722284}
22732285
2274- /// Render the stability and/or deprecation warning that is displayed at the top of the item's
2275- /// documentation.
2276- fn short_stability ( item : & clean:: Item , cx : & Context , parent : Option < & clean:: Item > ) -> Vec < String > {
2277- let mut stability = vec ! [ ] ;
2286+ /// Render the stability, deprecation and portability information that is displayed at the top of
2287+ /// the item's documentation.
2288+ fn short_item_info ( item : & clean:: Item , cx : & Context , parent : Option < & clean:: Item > ) -> Vec < String > {
2289+ let mut extra_info = vec ! [ ] ;
22782290 let error_codes = cx. shared . codes ;
22792291
22802292 if let Some ( Deprecation { ref note, ref since, is_since_rustc_version } ) = item. deprecation {
@@ -2301,7 +2313,7 @@ fn short_stability(item: &clean::Item, cx: &Context, parent: Option<&clean::Item
23012313 ) ;
23022314 message. push_str ( & format ! ( ": {}" , html. into_string( ) ) ) ;
23032315 }
2304- stability . push ( format ! (
2316+ extra_info . push ( format ! (
23052317 "<div class=\" stab deprecated\" ><span class=\" emoji\" >👎</span> {}</div>" ,
23062318 message,
23072319 ) ) ;
@@ -2345,14 +2357,14 @@ fn short_stability(item: &clean::Item, cx: &Context, parent: Option<&clean::Item
23452357 ) ;
23462358 }
23472359
2348- stability . push ( format ! ( "<div class=\" stab unstable\" >{}</div>" , message) ) ;
2360+ extra_info . push ( format ! ( "<div class=\" stab unstable\" >{}</div>" , message) ) ;
23492361 }
23502362
23512363 if let Some ( portability) = portability ( item, parent) {
2352- stability . push ( portability) ;
2364+ extra_info . push ( portability) ;
23532365 }
23542366
2355- stability
2367+ extra_info
23562368}
23572369
23582370fn item_constant ( w : & mut Buffer , cx : & Context , it : & clean:: Item , c : & clean:: Constant ) {
@@ -3703,7 +3715,7 @@ fn render_impl(
37033715
37043716 if trait_. is_some ( ) {
37053717 if let Some ( portability) = portability ( & i. impl_item , Some ( parent) ) {
3706- write ! ( w, "<div class=\" stability \" >{}</div>" , portability) ;
3718+ write ! ( w, "<div class=\" item-info \" >{}</div>" , portability) ;
37073719 }
37083720 }
37093721
@@ -3801,26 +3813,32 @@ fn render_impl(
38013813 if let Some ( it) = t. items . iter ( ) . find ( |i| i. name == item. name ) {
38023814 // We need the stability of the item from the trait
38033815 // because impls can't have a stability.
3804- document_stability ( w, cx, it, is_hidden, Some ( parent) ) ;
38053816 if item. doc_value ( ) . is_some ( ) {
3817+ document_item_info ( w, cx, it, is_hidden, Some ( parent) ) ;
38063818 document_full ( w, item, cx, "" , is_hidden) ;
3807- } else if show_def_docs {
3819+ } else {
38083820 // In case the item isn't documented,
38093821 // provide short documentation from the trait.
3810- document_short ( w, it, link, "" , is_hidden) ;
3822+ document_short (
3823+ w,
3824+ it,
3825+ cx,
3826+ link,
3827+ "" ,
3828+ is_hidden,
3829+ Some ( parent) ,
3830+ show_def_docs,
3831+ ) ;
38113832 }
38123833 }
38133834 } else {
3814- document_stability ( w, cx, item, is_hidden, Some ( parent) ) ;
3835+ document_item_info ( w, cx, item, is_hidden, Some ( parent) ) ;
38153836 if show_def_docs {
38163837 document_full ( w, item, cx, "" , is_hidden) ;
38173838 }
38183839 }
38193840 } else {
3820- document_stability ( w, cx, item, is_hidden, Some ( parent) ) ;
3821- if show_def_docs {
3822- document_short ( w, item, link, "" , is_hidden) ;
3823- }
3841+ document_short ( w, item, cx, link, "" , is_hidden, Some ( parent) , show_def_docs) ;
38243842 }
38253843 }
38263844 }
0 commit comments