@@ -1844,7 +1844,7 @@ fn document(w: &mut Buffer, cx: &Context, item: &clean::Item, parent: Option<&cl
1844
1844
if let Some ( ref name) = item. name {
1845
1845
info ! ( "Documenting {}" , name) ;
1846
1846
}
1847
- document_stability ( w, cx, item, false , parent) ;
1847
+ document_item_info ( w, cx, item, false , parent) ;
1848
1848
document_full ( w, item, cx, "" , false ) ;
1849
1849
}
1850
1850
@@ -1928,18 +1928,23 @@ fn document_full(w: &mut Buffer, item: &clean::Item, cx: &Context, prefix: &str,
1928
1928
}
1929
1929
}
1930
1930
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 (
1932
1937
w : & mut Buffer ,
1933
1938
cx : & Context ,
1934
1939
item : & clean:: Item ,
1935
1940
is_hidden : bool ,
1936
1941
parent : Option < & clean:: Item > ,
1937
1942
) {
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 ) ;
1943
1948
}
1944
1949
write ! ( w, "</div>" ) ;
1945
1950
}
@@ -2194,7 +2199,7 @@ fn item_module(w: &mut Buffer, cx: &Context, item: &clean::Item, items: &[clean:
2194
2199
<td class=\" docblock-short\" >{stab_tags}{docs}</td>\
2195
2200
</tr>",
2196
2201
name = * myitem. name. as_ref( ) . unwrap( ) ,
2197
- stab_tags = stability_tags ( myitem, item) ,
2202
+ stab_tags = extra_info_tags ( myitem, item) ,
2198
2203
docs = MarkdownSummaryLine ( doc_value, & myitem. links( ) ) . into_string( ) ,
2199
2204
class = myitem. type_( ) ,
2200
2205
add = add,
@@ -2216,9 +2221,9 @@ fn item_module(w: &mut Buffer, cx: &Context, item: &clean::Item, items: &[clean:
2216
2221
}
2217
2222
}
2218
2223
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 {
2222
2227
let mut tags = String :: new ( ) ;
2223
2228
2224
2229
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
2271
2276
Some ( format ! ( "<div class=\" stab portability\" >{}</div>" , cfg?. render_long_html( ) ) )
2272
2277
}
2273
2278
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 ! [ ] ;
2278
2283
let error_codes = cx. shared . codes ;
2279
2284
2280
2285
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
2301
2306
) ;
2302
2307
message. push_str ( & format ! ( ": {}" , html. into_string( ) ) ) ;
2303
2308
}
2304
- stability . push ( format ! (
2309
+ extra_info . push ( format ! (
2305
2310
"<div class=\" stab deprecated\" ><span class=\" emoji\" >👎</span> {}</div>" ,
2306
2311
message,
2307
2312
) ) ;
@@ -2345,14 +2350,14 @@ fn short_stability(item: &clean::Item, cx: &Context, parent: Option<&clean::Item
2345
2350
) ;
2346
2351
}
2347
2352
2348
- stability . push ( format ! ( "<div class=\" stab unstable\" >{}</div>" , message) ) ;
2353
+ extra_info . push ( format ! ( "<div class=\" stab unstable\" >{}</div>" , message) ) ;
2349
2354
}
2350
2355
2351
2356
if let Some ( portability) = portability ( item, parent) {
2352
- stability . push ( portability) ;
2357
+ extra_info . push ( portability) ;
2353
2358
}
2354
2359
2355
- stability
2360
+ extra_info
2356
2361
}
2357
2362
2358
2363
fn item_constant ( w : & mut Buffer , cx : & Context , it : & clean:: Item , c : & clean:: Constant ) {
@@ -3703,7 +3708,7 @@ fn render_impl(
3703
3708
3704
3709
if trait_. is_some ( ) {
3705
3710
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) ;
3707
3712
}
3708
3713
}
3709
3714
@@ -3801,7 +3806,7 @@ fn render_impl(
3801
3806
if let Some ( it) = t. items . iter ( ) . find ( |i| i. name == item. name ) {
3802
3807
// We need the stability of the item from the trait
3803
3808
// 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) ) ;
3805
3810
if item. doc_value ( ) . is_some ( ) {
3806
3811
document_full ( w, item, cx, "" , is_hidden) ;
3807
3812
} else if show_def_docs {
@@ -3811,13 +3816,13 @@ fn render_impl(
3811
3816
}
3812
3817
}
3813
3818
} else {
3814
- document_stability ( w, cx, item, is_hidden, Some ( parent) ) ;
3819
+ document_item_info ( w, cx, item, is_hidden, Some ( parent) ) ;
3815
3820
if show_def_docs {
3816
3821
document_full ( w, item, cx, "" , is_hidden) ;
3817
3822
}
3818
3823
}
3819
3824
} else {
3820
- document_stability ( w, cx, item, is_hidden, Some ( parent) ) ;
3825
+ document_item_info ( w, cx, item, is_hidden, Some ( parent) ) ;
3821
3826
if show_def_docs {
3822
3827
document_short ( w, item, link, "" , is_hidden) ;
3823
3828
}
0 commit comments