@@ -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
@@ -1928,18 +1928,23 @@ fn document_full(w: &mut Buffer, item: &clean::Item, cx: &Context, prefix: &str,
19281928 }
19291929}
19301930
1931- fn document_stability (
1931+ /// Add extra information about an item such as:
1932+ ///
1933+ /// * Stability
1934+ /// * Deprecated
1935+ /// * Required features (through the `doc_cfg` feature)
1936+ fn document_item_info (
19321937 w : & mut Buffer ,
19331938 cx : & Context ,
19341939 item : & clean:: Item ,
19351940 is_hidden : bool ,
19361941 parent : Option < & clean:: Item > ,
19371942) {
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 ) ;
1943+ let item_infos = short_item_info ( item, cx, parent) ;
1944+ if !item_infos . is_empty ( ) {
1945+ write ! ( w, "<div class=\" item-info {}\" >" , if is_hidden { " hidden" } else { "" } ) ;
1946+ for info in item_infos {
1947+ write ! ( w, "{}" , info ) ;
19431948 }
19441949 write ! ( w, "</div>" ) ;
19451950 }
@@ -2194,7 +2199,7 @@ fn item_module(w: &mut Buffer, cx: &Context, item: &clean::Item, items: &[clean:
21942199 <td class=\" docblock-short\" >{stab_tags}{docs}</td>\
21952200 </tr>",
21962201 name = * myitem. name. as_ref( ) . unwrap( ) ,
2197- stab_tags = stability_tags ( myitem, item) ,
2202+ stab_tags = extra_info_tags ( myitem, item) ,
21982203 docs = MarkdownSummaryLine ( doc_value, & myitem. links( ) ) . into_string( ) ,
21992204 class = myitem. type_( ) ,
22002205 add = add,
@@ -2216,9 +2221,9 @@ fn item_module(w: &mut Buffer, cx: &Context, item: &clean::Item, items: &[clean:
22162221 }
22172222}
22182223
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 {
2224+ /// Render the stability, deprecation and portability tags that are displayed in the item's summary
2225+ /// at the module level.
2226+ fn extra_info_tags ( item : & clean:: Item , parent : & clean:: Item ) -> String {
22222227 let mut tags = String :: new ( ) ;
22232228
22242229 fn tag_html ( class : & str , title : & str , contents : & str ) -> String {
@@ -2271,10 +2276,10 @@ fn portability(item: &clean::Item, parent: Option<&clean::Item>) -> Option<Strin
22712276 Some ( format ! ( "<div class=\" stab portability\" >{}</div>" , cfg?. render_long_html( ) ) )
22722277}
22732278
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 ! [ ] ;
2279+ /// Render the stability, deprecation and portability information that is displayed at the top of
2280+ /// the item's documentation.
2281+ fn short_item_info ( item : & clean:: Item , cx : & Context , parent : Option < & clean:: Item > ) -> Vec < String > {
2282+ let mut extra_info = vec ! [ ] ;
22782283 let error_codes = cx. shared . codes ;
22792284
22802285 if let Some ( Deprecation { ref note, ref since, is_since_rustc_version } ) = item. deprecation {
@@ -2301,7 +2306,7 @@ fn short_stability(item: &clean::Item, cx: &Context, parent: Option<&clean::Item
23012306 ) ;
23022307 message. push_str ( & format ! ( ": {}" , html. into_string( ) ) ) ;
23032308 }
2304- stability . push ( format ! (
2309+ extra_info . push ( format ! (
23052310 "<div class=\" stab deprecated\" ><span class=\" emoji\" >👎</span> {}</div>" ,
23062311 message,
23072312 ) ) ;
@@ -2345,14 +2350,14 @@ fn short_stability(item: &clean::Item, cx: &Context, parent: Option<&clean::Item
23452350 ) ;
23462351 }
23472352
2348- stability . push ( format ! ( "<div class=\" stab unstable\" >{}</div>" , message) ) ;
2353+ extra_info . push ( format ! ( "<div class=\" stab unstable\" >{}</div>" , message) ) ;
23492354 }
23502355
23512356 if let Some ( portability) = portability ( item, parent) {
2352- stability . push ( portability) ;
2357+ extra_info . push ( portability) ;
23532358 }
23542359
2355- stability
2360+ extra_info
23562361}
23572362
23582363fn item_constant ( w : & mut Buffer , cx : & Context , it : & clean:: Item , c : & clean:: Constant ) {
@@ -3703,7 +3708,7 @@ fn render_impl(
37033708
37043709 if trait_. is_some ( ) {
37053710 if let Some ( portability) = portability ( & i. impl_item , Some ( parent) ) {
3706- write ! ( w, "<div class=\" stability \" >{}</div>" , portability) ;
3711+ write ! ( w, "<div class=\" item-info \" >{}</div>" , portability) ;
37073712 }
37083713 }
37093714
@@ -3801,7 +3806,7 @@ fn render_impl(
38013806 if let Some ( it) = t. items . iter ( ) . find ( |i| i. name == item. name ) {
38023807 // We need the stability of the item from the trait
38033808 // because impls can't have a stability.
3804- document_stability ( w, cx, it, is_hidden, Some ( parent) ) ;
3809+ document_item_info ( w, cx, it, is_hidden, Some ( parent) ) ;
38053810 if item. doc_value ( ) . is_some ( ) {
38063811 document_full ( w, item, cx, "" , is_hidden) ;
38073812 } else if show_def_docs {
@@ -3811,13 +3816,13 @@ fn render_impl(
38113816 }
38123817 }
38133818 } else {
3814- document_stability ( w, cx, item, is_hidden, Some ( parent) ) ;
3819+ document_item_info ( w, cx, item, is_hidden, Some ( parent) ) ;
38153820 if show_def_docs {
38163821 document_full ( w, item, cx, "" , is_hidden) ;
38173822 }
38183823 }
38193824 } else {
3820- document_stability ( w, cx, item, is_hidden, Some ( parent) ) ;
3825+ document_item_info ( w, cx, item, is_hidden, Some ( parent) ) ;
38213826 if show_def_docs {
38223827 document_short ( w, item, link, "" , is_hidden) ;
38233828 }
0 commit comments