@@ -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
@@ -1880,10 +1880,17 @@ fn render_markdown(
1880
1880
fn document_short (
1881
1881
w : & mut Buffer ,
1882
1882
item : & clean:: Item ,
1883
+ cx : & Context ,
1883
1884
link : AssocItemLink < ' _ > ,
1884
1885
prefix : & str ,
1885
1886
is_hidden : bool ,
1887
+ parent : Option < & clean:: Item > ,
1888
+ show_def_docs : bool ,
1886
1889
) {
1890
+ document_item_info ( w, cx, item, is_hidden, parent) ;
1891
+ if !show_def_docs {
1892
+ return ;
1893
+ }
1887
1894
if let Some ( s) = item. doc_value ( ) {
1888
1895
let mut summary_html = MarkdownSummaryLine ( s, & item. links ( ) ) . into_string ( ) ;
1889
1896
@@ -1928,18 +1935,23 @@ fn document_full(w: &mut Buffer, item: &clean::Item, cx: &Context, prefix: &str,
1928
1935
}
1929
1936
}
1930
1937
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 (
1932
1944
w : & mut Buffer ,
1933
1945
cx : & Context ,
1934
1946
item : & clean:: Item ,
1935
1947
is_hidden : bool ,
1936
1948
parent : Option < & clean:: Item > ,
1937
1949
) {
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 ) ;
1943
1955
}
1944
1956
write ! ( w, "</div>" ) ;
1945
1957
}
@@ -2194,7 +2206,7 @@ fn item_module(w: &mut Buffer, cx: &Context, item: &clean::Item, items: &[clean:
2194
2206
<td class=\" docblock-short\" >{stab_tags}{docs}</td>\
2195
2207
</tr>",
2196
2208
name = * myitem. name. as_ref( ) . unwrap( ) ,
2197
- stab_tags = stability_tags ( myitem, item) ,
2209
+ stab_tags = extra_info_tags ( myitem, item) ,
2198
2210
docs = MarkdownSummaryLine ( doc_value, & myitem. links( ) ) . into_string( ) ,
2199
2211
class = myitem. type_( ) ,
2200
2212
add = add,
@@ -2216,9 +2228,9 @@ fn item_module(w: &mut Buffer, cx: &Context, item: &clean::Item, items: &[clean:
2216
2228
}
2217
2229
}
2218
2230
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 {
2222
2234
let mut tags = String :: new ( ) ;
2223
2235
2224
2236
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
2271
2283
Some ( format ! ( "<div class=\" stab portability\" >{}</div>" , cfg?. render_long_html( ) ) )
2272
2284
}
2273
2285
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 ! [ ] ;
2278
2290
let error_codes = cx. shared . codes ;
2279
2291
2280
2292
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
2301
2313
) ;
2302
2314
message. push_str ( & format ! ( ": {}" , html. into_string( ) ) ) ;
2303
2315
}
2304
- stability . push ( format ! (
2316
+ extra_info . push ( format ! (
2305
2317
"<div class=\" stab deprecated\" ><span class=\" emoji\" >👎</span> {}</div>" ,
2306
2318
message,
2307
2319
) ) ;
@@ -2345,14 +2357,14 @@ fn short_stability(item: &clean::Item, cx: &Context, parent: Option<&clean::Item
2345
2357
) ;
2346
2358
}
2347
2359
2348
- stability . push ( format ! ( "<div class=\" stab unstable\" >{}</div>" , message) ) ;
2360
+ extra_info . push ( format ! ( "<div class=\" stab unstable\" >{}</div>" , message) ) ;
2349
2361
}
2350
2362
2351
2363
if let Some ( portability) = portability ( item, parent) {
2352
- stability . push ( portability) ;
2364
+ extra_info . push ( portability) ;
2353
2365
}
2354
2366
2355
- stability
2367
+ extra_info
2356
2368
}
2357
2369
2358
2370
fn item_constant ( w : & mut Buffer , cx : & Context , it : & clean:: Item , c : & clean:: Constant ) {
@@ -3703,7 +3715,7 @@ fn render_impl(
3703
3715
3704
3716
if trait_. is_some ( ) {
3705
3717
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) ;
3707
3719
}
3708
3720
}
3709
3721
@@ -3801,26 +3813,32 @@ fn render_impl(
3801
3813
if let Some ( it) = t. items . iter ( ) . find ( |i| i. name == item. name ) {
3802
3814
// We need the stability of the item from the trait
3803
3815
// because impls can't have a stability.
3804
- document_stability ( w, cx, it, is_hidden, Some ( parent) ) ;
3805
3816
if item. doc_value ( ) . is_some ( ) {
3817
+ document_item_info ( w, cx, it, is_hidden, Some ( parent) ) ;
3806
3818
document_full ( w, item, cx, "" , is_hidden) ;
3807
- } else if show_def_docs {
3819
+ } else {
3808
3820
// In case the item isn't documented,
3809
3821
// 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
+ ) ;
3811
3832
}
3812
3833
}
3813
3834
} else {
3814
- document_stability ( w, cx, item, is_hidden, Some ( parent) ) ;
3835
+ document_item_info ( w, cx, item, is_hidden, Some ( parent) ) ;
3815
3836
if show_def_docs {
3816
3837
document_full ( w, item, cx, "" , is_hidden) ;
3817
3838
}
3818
3839
}
3819
3840
} 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) ;
3824
3842
}
3825
3843
}
3826
3844
}
0 commit comments