@@ -43,6 +43,8 @@ use std::sync::Arc;
43
43
44
44
use externalfiles:: ExternalHtml ;
45
45
46
+ use serialize:: json;
47
+ use serialize:: Encodable ;
46
48
use serialize:: json:: ToJson ;
47
49
use syntax:: ast;
48
50
use syntax:: ast_util;
@@ -59,6 +61,7 @@ use html::item_type;
59
61
use html:: layout;
60
62
use html:: markdown:: Markdown ;
61
63
use html:: markdown;
64
+ use stability_summary;
62
65
63
66
/// Major driving force in all rustdoc rendering. This contains information
64
67
/// about where in the tree-like hierarchy rendering is occurring and controls
@@ -249,6 +252,11 @@ pub fn run(mut krate: clean::Crate, external_html: &ExternalHtml, dst: Path) ->
249
252
250
253
try!( mkdir ( & cx. dst ) ) ;
251
254
255
+ // Crawl the crate, building a summary of the stability levels. NOTE: this
256
+ // summary *must* be computed with the original `krate`; the folding below
257
+ // removes the impls from their modules.
258
+ let summary = stability_summary:: build ( & krate) ;
259
+
252
260
// Crawl the crate attributes looking for attributes which control how we're
253
261
// going to emit HTML
254
262
match krate. module . as_ref ( ) . map ( |m| m. doc_list ( ) . unwrap_or ( & [ ] ) ) {
@@ -361,7 +369,7 @@ pub fn run(mut krate: clean::Crate, external_html: &ExternalHtml, dst: Path) ->
361
369
let krate = try!( render_sources ( & mut cx, krate) ) ;
362
370
363
371
// And finally render the whole crate's documentation
364
- cx. krate ( krate)
372
+ cx. krate ( krate, summary )
365
373
}
366
374
367
375
fn build_index ( krate : & clean:: Crate , cache : & mut Cache ) -> io:: IoResult < String > {
@@ -1045,13 +1053,34 @@ impl Context {
1045
1053
///
1046
1054
/// This currently isn't parallelized, but it'd be pretty easy to add
1047
1055
/// parallelization to this function.
1048
- fn krate ( self , mut krate : clean:: Crate ) -> io:: IoResult < ( ) > {
1056
+ fn krate ( mut self , mut krate : clean:: Crate ,
1057
+ stability : stability_summary:: ModuleSummary ) -> io:: IoResult < ( ) > {
1049
1058
let mut item = match krate. module . take ( ) {
1050
1059
Some ( i) => i,
1051
1060
None => return Ok ( ( ) )
1052
1061
} ;
1053
1062
item. name = Some ( krate. name ) ;
1054
1063
1064
+ // render stability dashboard
1065
+ try!( self . recurse ( stability. name . clone ( ) , |this| {
1066
+ let json_dst = & this. dst . join ( "stability.json" ) ;
1067
+ let mut json_out = BufferedWriter :: new ( try!( File :: create ( json_dst) ) ) ;
1068
+ try!( stability. encode ( & mut json:: Encoder :: new ( & mut json_out) ) ) ;
1069
+
1070
+ let title = stability. name . clone ( ) . append ( " - Stability dashboard" ) ;
1071
+ let page = layout:: Page {
1072
+ ty : "mod" ,
1073
+ root_path : this. root_path . as_slice ( ) ,
1074
+ title : title. as_slice ( ) ,
1075
+ } ;
1076
+ let html_dst = & this. dst . join ( "stability.html" ) ;
1077
+ let mut html_out = BufferedWriter :: new ( try!( File :: create ( html_dst) ) ) ;
1078
+ layout:: render ( & mut html_out, & this. layout , & page,
1079
+ & Sidebar { cx : this, item : & item } ,
1080
+ & stability)
1081
+ } ) ) ;
1082
+
1083
+ // render the crate documentation
1055
1084
let mut work = vec ! ( ( self , item) ) ;
1056
1085
loop {
1057
1086
match work. pop ( ) {
@@ -1061,6 +1090,7 @@ impl Context {
1061
1090
None => break ,
1062
1091
}
1063
1092
}
1093
+
1064
1094
Ok ( ( ) )
1065
1095
}
1066
1096
@@ -1233,6 +1263,8 @@ impl<'a> Item<'a> {
1233
1263
}
1234
1264
}
1235
1265
1266
+
1267
+
1236
1268
impl < ' a > fmt:: Show for Item < ' a > {
1237
1269
fn fmt ( & self , fmt : & mut fmt:: Formatter ) -> fmt:: Result {
1238
1270
// Write the breadcrumb trail header for the top
@@ -1269,6 +1301,17 @@ impl<'a> fmt::Show for Item<'a> {
1269
1301
// Write stability level
1270
1302
try!( write ! ( fmt, "{}" , Stability ( & self . item. stability) ) ) ;
1271
1303
1304
+ // Links to out-of-band information, i.e. src and stability dashboard
1305
+ try!( write ! ( fmt, "<span class='out-of-band'>" ) ) ;
1306
+
1307
+ // Write stability dashboard link
1308
+ match self . item . inner {
1309
+ clean:: ModuleItem ( ref m) if m. is_crate => {
1310
+ try!( write ! ( fmt, "<a href='stability.html'>[stability dashboard]</a> " ) ) ;
1311
+ }
1312
+ _ => { }
1313
+ } ;
1314
+
1272
1315
// Write `src` tag
1273
1316
//
1274
1317
// When this item is part of a `pub use` in a downstream crate, the
@@ -1278,14 +1321,15 @@ impl<'a> fmt::Show for Item<'a> {
1278
1321
if self . cx . include_sources && !is_primitive {
1279
1322
match self . href ( ) {
1280
1323
Some ( l) => {
1281
- try!( write ! ( fmt,
1282
- "<a class='source' id='src-{}' \
1283
- href='{}'>[src]</a>",
1324
+ try!( write ! ( fmt, "<a id='src-{}' href='{}'>[src]</a>" ,
1284
1325
self . item. def_id. node, l) ) ;
1285
1326
}
1286
1327
None => { }
1287
1328
}
1288
1329
}
1330
+
1331
+ try!( write ! ( fmt, "</span>" ) ) ;
1332
+
1289
1333
try!( write ! ( fmt, "</h1>\n " ) ) ;
1290
1334
1291
1335
match self . item . inner {
@@ -1355,6 +1399,7 @@ fn document(w: &mut fmt::Formatter, item: &clean::Item) -> fmt::Result {
1355
1399
fn item_module ( w : & mut fmt:: Formatter , cx : & Context ,
1356
1400
item : & clean:: Item , items : & [ clean:: Item ] ) -> fmt:: Result {
1357
1401
try!( document ( w, item) ) ;
1402
+
1358
1403
let mut indices = range ( 0 , items. len ( ) ) . filter ( |i| {
1359
1404
!ignore_private_item ( & items[ * i] )
1360
1405
} ) . collect :: < Vec < uint > > ( ) ;
@@ -1514,6 +1559,7 @@ fn item_module(w: &mut fmt::Formatter, cx: &Context,
1514
1559
}
1515
1560
}
1516
1561
}
1562
+
1517
1563
write ! ( w, "</table>" )
1518
1564
}
1519
1565
0 commit comments