@@ -1913,6 +1913,7 @@ fn item_function(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
1913
1913
generics = f. generics,
1914
1914
where_clause = WhereClause ( & f. generics) ,
1915
1915
decl = f. decl) ) ;
1916
+ try!( render_stability_since_raw ( w, it. stable_since ( ) , None ) ) ;
1916
1917
document ( w, cx, it)
1917
1918
}
1918
1919
@@ -1992,15 +1993,17 @@ fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
1992
1993
// Trait documentation
1993
1994
try!( document ( w, cx, it) ) ;
1994
1995
1995
- fn trait_item ( w : & mut fmt:: Formatter , cx : & Context , m : & clean:: Item )
1996
+ fn trait_item ( w : & mut fmt:: Formatter , cx : & Context , m : & clean:: Item , t : & clean :: Item )
1996
1997
-> fmt:: Result {
1997
1998
let name = m. name . as_ref ( ) . unwrap ( ) ;
1998
1999
let id = derive_id ( format ! ( "{}.{}" , shortty( m) , name) ) ;
1999
2000
try!( write ! ( w, "<h3 id='{id}' class='method stab {stab}'><code>" ,
2000
2001
id = id,
2001
2002
stab = m. stability_class( ) ) ) ;
2002
2003
try!( render_assoc_item ( w, m, AssocItemLink :: Anchor ) ) ;
2003
- try!( write ! ( w, "</code></h3>" ) ) ;
2004
+ try!( write ! ( w, "</code>" ) ) ;
2005
+ try!( render_stability_since ( w, m, t) ) ;
2006
+ try!( write ! ( w, "</h3>" ) ) ;
2004
2007
try!( document ( w, cx, m) ) ;
2005
2008
Ok ( ( ) )
2006
2009
}
@@ -2011,7 +2014,7 @@ fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
2011
2014
<div class='methods'>
2012
2015
" ) ) ;
2013
2016
for t in & types {
2014
- try!( trait_item ( w, cx, * t) ) ;
2017
+ try!( trait_item ( w, cx, * t, it ) ) ;
2015
2018
}
2016
2019
try!( write ! ( w, "</div>" ) ) ;
2017
2020
}
@@ -2022,7 +2025,7 @@ fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
2022
2025
<div class='methods'>
2023
2026
" ) ) ;
2024
2027
for t in & consts {
2025
- try!( trait_item ( w, cx, * t) ) ;
2028
+ try!( trait_item ( w, cx, * t, it ) ) ;
2026
2029
}
2027
2030
try!( write ! ( w, "</div>" ) ) ;
2028
2031
}
@@ -2034,7 +2037,7 @@ fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
2034
2037
<div class='methods'>
2035
2038
" ) ) ;
2036
2039
for m in & required {
2037
- try!( trait_item ( w, cx, * m) ) ;
2040
+ try!( trait_item ( w, cx, * m, it ) ) ;
2038
2041
}
2039
2042
try!( write ! ( w, "</div>" ) ) ;
2040
2043
}
@@ -2044,13 +2047,13 @@ fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
2044
2047
<div class='methods'>
2045
2048
" ) ) ;
2046
2049
for m in & provided {
2047
- try!( trait_item ( w, cx, * m) ) ;
2050
+ try!( trait_item ( w, cx, * m, it ) ) ;
2048
2051
}
2049
2052
try!( write ! ( w, "</div>" ) ) ;
2050
2053
}
2051
2054
2052
2055
// If there are methods directly on this trait object, render them here.
2053
- try!( render_assoc_items ( w, cx, it. def_id , AssocItemRender :: All ) ) ;
2056
+ try!( render_assoc_items ( w, cx, it, it . def_id , AssocItemRender :: All ) ) ;
2054
2057
2055
2058
let cache = cache ( ) ;
2056
2059
try!( write ! ( w, "
@@ -2106,6 +2109,29 @@ fn assoc_type(w: &mut fmt::Formatter, it: &clean::Item,
2106
2109
Ok ( ( ) )
2107
2110
}
2108
2111
2112
+ fn render_stability_since_raw < ' a > ( w : & mut fmt:: Formatter ,
2113
+ ver : Option < & ' a str > ,
2114
+ containing_ver : Option < & ' a str > ) -> fmt:: Result {
2115
+ if containing_ver != ver {
2116
+ match ver {
2117
+ Some ( v) =>
2118
+ if v. len ( ) > 0 {
2119
+ try!( write ! ( w, "<span class=\" since\" >{}</span>" ,
2120
+ v) )
2121
+ } ,
2122
+ None => { }
2123
+ }
2124
+ }
2125
+
2126
+ Ok ( ( ) )
2127
+ }
2128
+
2129
+ fn render_stability_since ( w : & mut fmt:: Formatter ,
2130
+ item : & clean:: Item ,
2131
+ containing_item : & clean:: Item ) -> fmt:: Result {
2132
+ render_stability_since_raw ( w, item. stable_since ( ) , containing_item. stable_since ( ) )
2133
+ }
2134
+
2109
2135
fn render_assoc_item ( w : & mut fmt:: Formatter , meth : & clean:: Item ,
2110
2136
link : AssocItemLink ) -> fmt:: Result {
2111
2137
fn method ( w : & mut fmt:: Formatter ,
@@ -2178,6 +2204,7 @@ fn item_struct(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
2178
2204
"" ,
2179
2205
true ) ) ;
2180
2206
try!( write ! ( w, "</pre>" ) ) ;
2207
+ try!( render_stability_since_raw ( w, it. stable_since ( ) , None ) ) ;
2181
2208
2182
2209
try!( document ( w, cx, it) ) ;
2183
2210
let mut fields = s. fields . iter ( ) . filter ( |f| {
@@ -2202,7 +2229,7 @@ fn item_struct(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
2202
2229
try!( write ! ( w, "</table>" ) ) ;
2203
2230
}
2204
2231
}
2205
- render_assoc_items ( w, cx, it. def_id , AssocItemRender :: All )
2232
+ render_assoc_items ( w, cx, it, it . def_id , AssocItemRender :: All )
2206
2233
}
2207
2234
2208
2235
fn item_enum ( w : & mut fmt:: Formatter , cx : & Context , it : & clean:: Item ,
@@ -2257,10 +2284,11 @@ fn item_enum(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
2257
2284
try!( write ! ( w, "}}" ) ) ;
2258
2285
}
2259
2286
try!( write ! ( w, "</pre>" ) ) ;
2287
+ try!( render_stability_since_raw ( w, it. stable_since ( ) , None ) ) ;
2260
2288
2261
2289
try!( document ( w, cx, it) ) ;
2262
2290
if !e. variants . is_empty ( ) {
2263
- try!( write ! ( w, "<h2 class='variants'>Variants</h2>\n <table>" ) ) ;
2291
+ try!( write ! ( w, "<h2 class='variants'>Variants</h2>\n <table class='variants_table' >" ) ) ;
2264
2292
for variant in & e. variants {
2265
2293
try!( write ! ( w, "<tr><td id='variant.{name}'><code>{name}</code></td><td>" ,
2266
2294
name = variant. name. as_ref( ) . unwrap( ) ) ) ;
@@ -2296,12 +2324,14 @@ fn item_enum(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
2296
2324
}
2297
2325
_ => ( )
2298
2326
}
2327
+ try!( write ! ( w, "</td><td>" ) ) ;
2328
+ try!( render_stability_since ( w, variant, it) ) ;
2299
2329
try!( write ! ( w, "</td></tr>" ) ) ;
2300
2330
}
2301
2331
try!( write ! ( w, "</table>" ) ) ;
2302
2332
2303
2333
}
2304
- try!( render_assoc_items ( w, cx, it. def_id , AssocItemRender :: All ) ) ;
2334
+ try!( render_assoc_items ( w, cx, it, it . def_id , AssocItemRender :: All ) ) ;
2305
2335
Ok ( ( ) )
2306
2336
}
2307
2337
@@ -2397,6 +2427,7 @@ enum AssocItemRender<'a> {
2397
2427
2398
2428
fn render_assoc_items ( w : & mut fmt:: Formatter ,
2399
2429
cx : & Context ,
2430
+ containing_item : & clean:: Item ,
2400
2431
it : DefId ,
2401
2432
what : AssocItemRender ) -> fmt:: Result {
2402
2433
let c = cache ( ) ;
@@ -2420,7 +2451,8 @@ fn render_assoc_items(w: &mut fmt::Formatter,
2420
2451
}
2421
2452
} ;
2422
2453
for i in & non_trait {
2423
- try!( render_impl ( w, cx, i, AssocItemLink :: Anchor , render_header) ) ;
2454
+ try!( render_impl ( w, cx, i, AssocItemLink :: Anchor , render_header,
2455
+ containing_item. stable_since ( ) ) ) ;
2424
2456
}
2425
2457
}
2426
2458
if let AssocItemRender :: DerefFor { .. } = what {
@@ -2436,7 +2468,7 @@ fn render_assoc_items(w: &mut fmt::Formatter,
2436
2468
}
2437
2469
} ) ;
2438
2470
if let Some ( impl_) = deref_impl {
2439
- try!( render_deref_methods ( w, cx, impl_) ) ;
2471
+ try!( render_deref_methods ( w, cx, impl_, containing_item ) ) ;
2440
2472
}
2441
2473
try!( write ! ( w, "<h2 id='implementations'>Trait \
2442
2474
Implementations</h2>") ) ;
@@ -2445,22 +2477,25 @@ fn render_assoc_items(w: &mut fmt::Formatter,
2445
2477
} ) ;
2446
2478
for i in & manual {
2447
2479
let did = i. trait_did ( ) . unwrap ( ) ;
2448
- try!( render_impl ( w, cx, i, AssocItemLink :: GotoSource ( did) , true ) ) ;
2480
+ try!( render_impl ( w, cx, i, AssocItemLink :: GotoSource ( did) , true ,
2481
+ containing_item. stable_since ( ) ) ) ;
2449
2482
}
2450
2483
if !derived. is_empty ( ) {
2451
2484
try!( write ! ( w, "<h3 id='derived_implementations'>\
2452
2485
Derived Implementations \
2453
2486
</h3>") ) ;
2454
2487
for i in & derived {
2455
2488
let did = i. trait_did ( ) . unwrap ( ) ;
2456
- try!( render_impl ( w, cx, i, AssocItemLink :: GotoSource ( did) , true ) ) ;
2489
+ try!( render_impl ( w, cx, i, AssocItemLink :: GotoSource ( did) , true ,
2490
+ containing_item. stable_since ( ) ) ) ;
2457
2491
}
2458
2492
}
2459
2493
}
2460
2494
Ok ( ( ) )
2461
2495
}
2462
2496
2463
- fn render_deref_methods ( w : & mut fmt:: Formatter , cx : & Context , impl_ : & Impl ) -> fmt:: Result {
2497
+ fn render_deref_methods ( w : & mut fmt:: Formatter , cx : & Context , impl_ : & Impl ,
2498
+ container_item : & clean:: Item ) -> fmt:: Result {
2464
2499
let deref_type = impl_. impl_ . trait_ . as_ref ( ) . unwrap ( ) ;
2465
2500
let target = impl_. impl_ . items . iter ( ) . filter_map ( |item| {
2466
2501
match item. inner {
@@ -2470,12 +2505,12 @@ fn render_deref_methods(w: &mut fmt::Formatter, cx: &Context, impl_: &Impl) -> f
2470
2505
} ) . next ( ) . expect ( "Expected associated type binding" ) ;
2471
2506
let what = AssocItemRender :: DerefFor { trait_ : deref_type, type_ : target } ;
2472
2507
match * target {
2473
- clean:: ResolvedPath { did, .. } => render_assoc_items ( w, cx, did, what) ,
2508
+ clean:: ResolvedPath { did, .. } => render_assoc_items ( w, cx, container_item , did, what) ,
2474
2509
_ => {
2475
2510
if let Some ( prim) = target. primitive_type ( ) {
2476
2511
if let Some ( c) = cache ( ) . primitive_locations . get ( & prim) {
2477
2512
let did = DefId { krate : * c, index : prim. to_def_index ( ) } ;
2478
- try!( render_assoc_items ( w, cx, did, what) ) ;
2513
+ try!( render_assoc_items ( w, cx, container_item , did, what) ) ;
2479
2514
}
2480
2515
}
2481
2516
Ok ( ( ) )
@@ -2487,24 +2522,30 @@ fn render_deref_methods(w: &mut fmt::Formatter, cx: &Context, impl_: &Impl) -> f
2487
2522
// otherwise. If render_header is false, we will avoid rendering static
2488
2523
// methods, since they are not accessible for the type implementing `Deref`
2489
2524
fn render_impl ( w : & mut fmt:: Formatter , cx : & Context , i : & Impl , link : AssocItemLink ,
2490
- render_header : bool ) -> fmt:: Result {
2525
+ render_header : bool , outer_version : Option < & str > ) -> fmt:: Result {
2491
2526
if render_header {
2492
- try!( write ! ( w, "<h3 class='impl'><code>{}</code></h3>" , i. impl_) ) ;
2527
+ try!( write ! ( w, "<h3 class='impl'><code>{}</code>" , i. impl_) ) ;
2528
+ let since = i. stability . as_ref ( ) . map ( |s| & s. since [ ..] ) ;
2529
+ try!( render_stability_since_raw ( w, since, outer_version) ) ;
2530
+ try!( write ! ( w, "</h3>" ) ) ;
2493
2531
if let Some ( ref dox) = i. dox {
2494
2532
try!( write ! ( w, "<div class='docblock'>{}</div>" , Markdown ( dox) ) ) ;
2495
2533
}
2496
2534
}
2497
2535
2498
2536
fn doctraititem ( w : & mut fmt:: Formatter , cx : & Context , item : & clean:: Item ,
2499
- link : AssocItemLink , render_static : bool ) -> fmt:: Result {
2537
+ link : AssocItemLink , render_static : bool ,
2538
+ outer_version : Option < & str > ) -> fmt:: Result {
2500
2539
let name = item. name . as_ref ( ) . unwrap ( ) ;
2501
2540
match item. inner {
2502
2541
clean:: MethodItem ( ..) | clean:: TyMethodItem ( ..) => {
2503
2542
// Only render when the method is not static or we allow static methods
2504
2543
if !is_static_method ( item) || render_static {
2505
2544
let id = derive_id ( format ! ( "method.{}" , name) ) ;
2506
- try!( write ! ( w, "<h4 id='{}' class='{}'><code>" , id, shortty( item) ) ) ;
2507
- try!( render_assoc_item ( w, item, link) ) ;
2545
+ try!( write ! ( w, "<h4 id='{}' class='{}'>" , id, shortty( item) ) ) ;
2546
+ try!( render_stability_since_raw ( w, item. stable_since ( ) , outer_version) ) ;
2547
+ try!( write ! ( w, "<code>" ) ) ;
2548
+ try!( render_assoc_item ( w, item, link) ) ;
2508
2549
try!( write ! ( w, "</code></h4>\n " ) ) ;
2509
2550
}
2510
2551
}
@@ -2556,23 +2597,25 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi
2556
2597
2557
2598
try!( write ! ( w, "<div class='impl-items'>" ) ) ;
2558
2599
for trait_item in & i. impl_ . items {
2559
- try!( doctraititem ( w, cx, trait_item, link, render_header) ) ;
2600
+ try!( doctraititem ( w, cx, trait_item, link, render_header, outer_version ) ) ;
2560
2601
}
2561
2602
2562
2603
fn render_default_items ( w : & mut fmt:: Formatter ,
2563
2604
cx : & Context ,
2564
2605
did : DefId ,
2565
2606
t : & clean:: Trait ,
2566
2607
i : & clean:: Impl ,
2567
- render_static : bool ) -> fmt:: Result {
2608
+ render_static : bool ,
2609
+ outer_version : Option < & str > ) -> fmt:: Result {
2568
2610
for trait_item in & t. items {
2569
2611
let n = trait_item. name . clone ( ) ;
2570
2612
match i. items . iter ( ) . find ( |m| { m. name == n } ) {
2571
2613
Some ( ..) => continue ,
2572
2614
None => { }
2573
2615
}
2574
2616
2575
- try!( doctraititem ( w, cx, trait_item, AssocItemLink :: GotoSource ( did) , render_static) ) ;
2617
+ try!( doctraititem ( w, cx, trait_item, AssocItemLink :: GotoSource ( did) , render_static,
2618
+ outer_version) ) ;
2576
2619
}
2577
2620
Ok ( ( ) )
2578
2621
}
@@ -2583,7 +2626,7 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi
2583
2626
// for them work.
2584
2627
if let Some ( clean:: ResolvedPath { did, .. } ) = i. impl_ . trait_ {
2585
2628
if let Some ( t) = cache ( ) . traits . get ( & did) {
2586
- try!( render_default_items ( w, cx, did, t, & i. impl_ , render_header) ) ;
2629
+ try!( render_default_items ( w, cx, did, t, & i. impl_ , render_header, outer_version ) ) ;
2587
2630
2588
2631
}
2589
2632
}
@@ -2675,14 +2718,15 @@ fn item_macro(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
2675
2718
try!( w. write_str ( & highlight:: highlight ( & t. source ,
2676
2719
Some ( "macro" ) ,
2677
2720
None ) ) ) ;
2721
+ try!( render_stability_since_raw ( w, it. stable_since ( ) , None ) ) ;
2678
2722
document ( w, cx, it)
2679
2723
}
2680
2724
2681
2725
fn item_primitive ( w : & mut fmt:: Formatter , cx : & Context ,
2682
2726
it : & clean:: Item ,
2683
2727
_p : & clean:: PrimitiveType ) -> fmt:: Result {
2684
2728
try!( document ( w, cx, it) ) ;
2685
- render_assoc_items ( w, cx, it. def_id , AssocItemRender :: All )
2729
+ render_assoc_items ( w, cx, it, it . def_id , AssocItemRender :: All )
2686
2730
}
2687
2731
2688
2732
fn get_basic_keywords ( ) -> & ' static str {
0 commit comments