File tree 4 files changed +49
-1
lines changed
4 files changed +49
-1
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ use its = syntax::parse::token::ident_to_str;
16
16
use syntax;
17
17
use syntax:: ast;
18
18
use syntax:: ast_util;
19
+ use syntax:: attr;
19
20
use syntax:: attr:: AttributeMethods ;
20
21
21
22
use std;
@@ -206,6 +207,25 @@ impl Clean<Attribute> for ast::Attribute {
206
207
}
207
208
}
208
209
210
+ // This is a rough approximation that gets us what we want.
211
+ impl < ' self > attr:: AttrMetaMethods for & ' self Attribute {
212
+ fn name ( & self ) -> @str {
213
+ match * * self {
214
+ Word ( ref n) | List ( ref n, _) | NameValue ( ref n, _) =>
215
+ n. to_managed ( )
216
+ }
217
+ }
218
+
219
+ fn value_str ( & self ) -> Option < @str > {
220
+ match * * self {
221
+ NameValue ( _, ref v) => Some ( v. to_managed ( ) ) ,
222
+ _ => None ,
223
+ }
224
+ }
225
+ fn meta_item_list < ' a > ( & ' a self ) -> Option < & ' a [ @ast:: MetaItem ] > { None }
226
+ fn name_str_pair ( & self ) -> Option < ( @str , @str ) > { None }
227
+ }
228
+
209
229
#[ deriving( Clone , Encodable , Decodable ) ]
210
230
pub struct TyParam {
211
231
name : ~str ,
Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ use extra::json::ToJson;
28
28
use extra:: sort;
29
29
30
30
use syntax:: ast;
31
+ use syntax:: attr;
31
32
32
33
use clean;
33
34
use doctree;
@@ -568,6 +569,18 @@ impl<'self> Item<'self> {
568
569
569
570
impl < ' self > fmt:: Default for Item < ' self > {
570
571
fn fmt ( it : & Item < ' self > , fmt : & mut fmt:: Formatter ) {
572
+ match attr:: find_stability ( it. item . attrs . iter ( ) ) {
573
+ Some ( stability) => {
574
+ write ! ( fmt. buf,
575
+ "<a class='stability {lvl}' title='{reason}'>{lvl}</a>" ,
576
+ lvl = stability. level. to_str( ) ,
577
+ reason = match stability. text {
578
+ Some ( s) => s, None => @"" ,
579
+ } ) ;
580
+ }
581
+ None => { }
582
+ }
583
+
571
584
// Write the breadcrumb trail header for the top
572
585
write ! ( fmt. buf, "<h1 class='fqn'>" ) ;
573
586
match it. item . inner {
Original file line number Diff line number Diff line change 269
269
float : left;
270
270
padding : 20px ;
271
271
}
272
+
273
+ .stability {
274
+ border-left : 5px solid # 000 ;
275
+ border-radius : 3px ;
276
+ padding : 0 3px ;
277
+ float : right;
278
+ background : # fff ;
279
+ text-transform : lowercase;
280
+ }
281
+ .stability .Deprecated { border-color : # D60027 ; color : # 880017 ; }
282
+ .stability .Experimental { border-color : # EC5315 ; color : # a53c0e ; }
283
+ .stability .Unstable { border-color : # FFD700 ; color : # b39800 ; }
284
+ .stability .Stable { border-color : # AEC516 ; color : # 7c8b10 ; }
285
+ .stability .Frozen { border-color : # 009431 ; color : # 007726 ; }
286
+ .stability .Locked { border-color : # 0084B6 ; color : # 00668c ; }
Original file line number Diff line number Diff line change @@ -320,7 +320,7 @@ pub struct Stability {
320
320
}
321
321
322
322
/// The available stability levels.
323
- #[ deriving( Eq , Ord , Clone ) ]
323
+ #[ deriving( Eq , Ord , Clone , ToStr ) ]
324
324
pub enum StabilityLevel {
325
325
Deprecated ,
326
326
Experimental ,
You can’t perform that action at this time.
0 commit comments