1
Fork 0

rustdoc: improvements to stability dashboard

* Makes dashboard width dynamic.
* Colors unmarked items.
* Gives overall crate percentages.
This commit is contained in:
Aaron Turon 2014-07-27 23:03:46 -07:00
parent 79e9f14abf
commit f26011d5a0
3 changed files with 38 additions and 26 deletions

View file

@ -663,31 +663,27 @@ impl fmt::Show for ModuleSummary {
context.push(m.name.as_slice()); context.push(m.name.as_slice());
let path = context.connect("::"); let path = context.connect("::");
// the total width of each row's stability summary, in pixels
let width = 500;
try!(write!(f, "<tr>")); try!(write!(f, "<tr>"));
try!(write!(f, "<td class='summary'>\ try!(write!(f, "<td><a href='{}'>{}</a></td>",
<a class='summary' href='{}'>{}</a></td>",
Vec::from_slice(context.slice_from(1)) Vec::from_slice(context.slice_from(1))
.append_one("index.html").connect("/"), .append_one("index.html").connect("/"),
path)); path));
try!(write!(f, "<td>")); try!(write!(f, "<td class='summary-column'>"));
try!(write!(f, "<span class='summary Stable' \ try!(write!(f, "<span class='summary Stable' \
style='width: {}px; display: inline-block'>&nbsp</span>", style='width: {:.4}%; display: inline-block'>&nbsp</span>",
(width * cnt.stable)/tot)); (100 * cnt.stable) as f64/tot as f64));
try!(write!(f, "<span class='summary Unstable' \ try!(write!(f, "<span class='summary Unstable' \
style='width: {}px; display: inline-block'>&nbsp</span>", style='width: {:.4}%; display: inline-block'>&nbsp</span>",
(width * cnt.unstable)/tot)); (100 * cnt.unstable) as f64/tot as f64));
try!(write!(f, "<span class='summary Experimental' \ try!(write!(f, "<span class='summary Experimental' \
style='width: {}px; display: inline-block'>&nbsp</span>", style='width: {:.4}%; display: inline-block'>&nbsp</span>",
(width * cnt.experimental)/tot)); (100 * cnt.experimental) as f64/tot as f64));
try!(write!(f, "<span class='summary Deprecated' \ try!(write!(f, "<span class='summary Deprecated' \
style='width: {}px; display: inline-block'>&nbsp</span>", style='width: {:.4}%; display: inline-block'>&nbsp</span>",
(width * cnt.deprecated)/tot)); (100 * cnt.deprecated) as f64/tot as f64));
try!(write!(f, "<span class='summary Unmarked' \ try!(write!(f, "<span class='summary Unmarked' \
style='width: {}px; display: inline-block'>&nbsp</span>", style='width: {:.4}%; display: inline-block'>&nbsp</span>",
(width * cnt.unmarked)/tot)); (100 * cnt.unmarked) as f64/tot as f64));
try!(write!(f, "</td></tr>")); try!(write!(f, "</td></tr>"));
for submodule in m.submodules.iter() { for submodule in m.submodules.iter() {
@ -699,20 +695,33 @@ impl fmt::Show for ModuleSummary {
let mut context = Vec::new(); let mut context = Vec::new();
let tot = self.counts.total();
let (stable, unstable, experimental, deprecated, unmarked) = if tot == 0 {
(0, 0, 0, 0, 0)
} else {
((100 * self.counts.stable)/tot,
(100 * self.counts.unstable)/tot,
(100 * self.counts.experimental)/tot,
(100 * self.counts.deprecated)/tot,
(100 * self.counts.unmarked)/tot)
};
try!(write!(f, try!(write!(f,
r"<h1 class='fqn'>Stability dashboard: crate <a class='mod' href='index.html'>{}</a></h1> r"<h1 class='fqn'>Stability dashboard: crate <a class='mod' href='index.html'>{name}</a></h1>
This dashboard summarizes the stability levels for all of the public modules of This dashboard summarizes the stability levels for all of the public modules of
the crate, according to the total number of items at each level in the module and its children: the crate, according to the total number of items at each level in the module and
its children (percentages total for {name}):
<blockquote> <blockquote>
<a class='stability Stable'></a> stable,<br/> <a class='stability Stable'></a> stable ({}%),<br/>
<a class='stability Unstable'></a> unstable,<br/> <a class='stability Unstable'></a> unstable ({}%),<br/>
<a class='stability Experimental'></a> experimental,<br/> <a class='stability Experimental'></a> experimental ({}%),<br/>
<a class='stability Deprecated'></a> deprecated,<br/> <a class='stability Deprecated'></a> deprecated ({}%),<br/>
<a class='stability Unmarked'></a> unmarked <a class='stability Unmarked'></a> unmarked ({}%)
</blockquote> </blockquote>
The counts do not include methods or trait The counts do not include methods or trait
implementations that are visible only through a re-exported type.", implementations that are visible only through a re-exported type.",
self.name)); stable, unstable, experimental, deprecated, unmarked,
name=self.name));
try!(write!(f, "<table>")) try!(write!(f, "<table>"))
try!(fmt_inner(f, &mut context, self)); try!(fmt_inner(f, &mut context, self));
write!(f, "</table>") write!(f, "</table>")

View file

@ -407,7 +407,7 @@ h1 .stability {
.stability.Stable { border-color: #54A759; color: #2D8632; } .stability.Stable { border-color: #54A759; color: #2D8632; }
.stability.Frozen { border-color: #009431; color: #007726; } .stability.Frozen { border-color: #009431; color: #007726; }
.stability.Locked { border-color: #0084B6; color: #00668c; } .stability.Locked { border-color: #0084B6; color: #00668c; }
.stability.Unmarked { border-color: #FFFFFF; } .stability.Unmarked { border-color: #BBBBBB; }
.summary { .summary {
padding-right: 0px; padding-right: 0px;
@ -416,7 +416,7 @@ h1 .stability {
.summary.Experimental { background-color: #D46D6A; } .summary.Experimental { background-color: #D46D6A; }
.summary.Unstable { background-color: #D4B16A; } .summary.Unstable { background-color: #D4B16A; }
.summary.Stable { background-color: #54A759; } .summary.Stable { background-color: #54A759; }
.summary.Unmarked { background-color: #FFFFFF; } .summary.Unmarked { background-color: #BBBBBB; }
:target { background: #FDFFD3; } :target { background: #FDFFD3; }

View file

@ -42,6 +42,9 @@
$('.docblock.short').width(function() { $('.docblock.short').width(function() {
return contentWidth - 40 - $(this).prev().width(); return contentWidth - 40 - $(this).prev().width();
}).addClass('nowrap'); }).addClass('nowrap');
$('.summary-column').width(function() {
return contentWidth - 40 - $(this).prev().width();
})
}, 150); }, 150);
} }
resizeShortBlocks(); resizeShortBlocks();