@@ -43,6 +43,8 @@ use std::sync::Arc;
4343
4444use externalfiles:: ExternalHtml ;
4545
46+ use serialize:: json;
47+ use serialize:: Encodable ;
4648use serialize:: json:: ToJson ;
4749use syntax:: ast;
4850use syntax:: ast_util;
@@ -59,6 +61,7 @@ use html::item_type;
5961use html:: layout;
6062use html:: markdown:: Markdown ;
6163use html:: markdown;
64+ use stability_summary;
6265
6366/// Major driving force in all rustdoc rendering. This contains information
6467/// 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) ->
249252
250253 try!( mkdir ( & cx. dst ) ) ;
251254
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+
252260 // Crawl the crate attributes looking for attributes which control how we're
253261 // going to emit HTML
254262 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) ->
361369 let krate = try!( render_sources ( & mut cx, krate) ) ;
362370
363371 // And finally render the whole crate's documentation
364- cx. krate ( krate)
372+ cx. krate ( krate, summary )
365373}
366374
367375fn build_index ( krate : & clean:: Crate , cache : & mut Cache ) -> io:: IoResult < String > {
@@ -1045,13 +1053,34 @@ impl Context {
10451053 ///
10461054 /// This currently isn't parallelized, but it'd be pretty easy to add
10471055 /// 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 < ( ) > {
10491058 let mut item = match krate. module . take ( ) {
10501059 Some ( i) => i,
10511060 None => return Ok ( ( ) )
10521061 } ;
10531062 item. name = Some ( krate. name ) ;
10541063
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
10551084 let mut work = vec ! ( ( self , item) ) ;
10561085 loop {
10571086 match work. pop ( ) {
@@ -1061,6 +1090,7 @@ impl Context {
10611090 None => break ,
10621091 }
10631092 }
1093+
10641094 Ok ( ( ) )
10651095 }
10661096
@@ -1233,6 +1263,8 @@ impl<'a> Item<'a> {
12331263 }
12341264}
12351265
1266+
1267+
12361268impl < ' a > fmt:: Show for Item < ' a > {
12371269 fn fmt ( & self , fmt : & mut fmt:: Formatter ) -> fmt:: Result {
12381270 // Write the breadcrumb trail header for the top
@@ -1269,6 +1301,17 @@ impl<'a> fmt::Show for Item<'a> {
12691301 // Write stability level
12701302 try!( write ! ( fmt, "{}" , Stability ( & self . item. stability) ) ) ;
12711303
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+
12721315 // Write `src` tag
12731316 //
12741317 // 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> {
12781321 if self . cx . include_sources && !is_primitive {
12791322 match self . href ( ) {
12801323 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>" ,
12841325 self . item. def_id. node, l) ) ;
12851326 }
12861327 None => { }
12871328 }
12881329 }
1330+
1331+ try!( write ! ( fmt, "</span>" ) ) ;
1332+
12891333 try!( write ! ( fmt, "</h1>\n " ) ) ;
12901334
12911335 match self . item . inner {
@@ -1355,6 +1399,7 @@ fn document(w: &mut fmt::Formatter, item: &clean::Item) -> fmt::Result {
13551399fn item_module ( w : & mut fmt:: Formatter , cx : & Context ,
13561400 item : & clean:: Item , items : & [ clean:: Item ] ) -> fmt:: Result {
13571401 try!( document ( w, item) ) ;
1402+
13581403 let mut indices = range ( 0 , items. len ( ) ) . filter ( |i| {
13591404 !ignore_private_item ( & items[ * i] )
13601405 } ) . collect :: < Vec < uint > > ( ) ;
@@ -1514,6 +1559,7 @@ fn item_module(w: &mut fmt::Formatter, cx: &Context,
15141559 }
15151560 }
15161561 }
1562+
15171563 write ! ( w, "</table>" )
15181564}
15191565
0 commit comments