Skip to content

Commit 1ec6d17

Browse files
committed
auto merge of #16049 : aturon/rust/stability-dashboard-improvements, r=alexcrichton
* Makes dashboard width dynamic. * Colors unmarked items. * Gives overall crate percentages.
2 parents 7375f4d + f26011d commit 1ec6d17

File tree

3 files changed

+38
-26
lines changed

3 files changed

+38
-26
lines changed

src/librustdoc/html/format.rs

+33-24
Original file line numberDiff line numberDiff line change
@@ -663,31 +663,27 @@ impl fmt::Show for ModuleSummary {
663663
context.push(m.name.as_slice());
664664
let path = context.connect("::");
665665

666-
// the total width of each row's stability summary, in pixels
667-
let width = 500;
668-
669666
try!(write!(f, "<tr>"));
670-
try!(write!(f, "<td class='summary'>\
671-
<a class='summary' href='{}'>{}</a></td>",
667+
try!(write!(f, "<td><a href='{}'>{}</a></td>",
672668
Vec::from_slice(context.slice_from(1))
673669
.append_one("index.html").connect("/"),
674670
path));
675-
try!(write!(f, "<td>"));
671+
try!(write!(f, "<td class='summary-column'>"));
676672
try!(write!(f, "<span class='summary Stable' \
677-
style='width: {}px; display: inline-block'>&nbsp</span>",
678-
(width * cnt.stable)/tot));
673+
style='width: {:.4}%; display: inline-block'>&nbsp</span>",
674+
(100 * cnt.stable) as f64/tot as f64));
679675
try!(write!(f, "<span class='summary Unstable' \
680-
style='width: {}px; display: inline-block'>&nbsp</span>",
681-
(width * cnt.unstable)/tot));
676+
style='width: {:.4}%; display: inline-block'>&nbsp</span>",
677+
(100 * cnt.unstable) as f64/tot as f64));
682678
try!(write!(f, "<span class='summary Experimental' \
683-
style='width: {}px; display: inline-block'>&nbsp</span>",
684-
(width * cnt.experimental)/tot));
679+
style='width: {:.4}%; display: inline-block'>&nbsp</span>",
680+
(100 * cnt.experimental) as f64/tot as f64));
685681
try!(write!(f, "<span class='summary Deprecated' \
686-
style='width: {}px; display: inline-block'>&nbsp</span>",
687-
(width * cnt.deprecated)/tot));
682+
style='width: {:.4}%; display: inline-block'>&nbsp</span>",
683+
(100 * cnt.deprecated) as f64/tot as f64));
688684
try!(write!(f, "<span class='summary Unmarked' \
689-
style='width: {}px; display: inline-block'>&nbsp</span>",
690-
(width * cnt.unmarked)/tot));
685+
style='width: {:.4}%; display: inline-block'>&nbsp</span>",
686+
(100 * cnt.unmarked) as f64/tot as f64));
691687
try!(write!(f, "</td></tr>"));
692688

693689
for submodule in m.submodules.iter() {
@@ -699,20 +695,33 @@ impl fmt::Show for ModuleSummary {
699695

700696
let mut context = Vec::new();
701697

698+
let tot = self.counts.total();
699+
let (stable, unstable, experimental, deprecated, unmarked) = if tot == 0 {
700+
(0, 0, 0, 0, 0)
701+
} else {
702+
((100 * self.counts.stable)/tot,
703+
(100 * self.counts.unstable)/tot,
704+
(100 * self.counts.experimental)/tot,
705+
(100 * self.counts.deprecated)/tot,
706+
(100 * self.counts.unmarked)/tot)
707+
};
708+
702709
try!(write!(f,
703-
r"<h1 class='fqn'>Stability dashboard: crate <a class='mod' href='index.html'>{}</a></h1>
710+
r"<h1 class='fqn'>Stability dashboard: crate <a class='mod' href='index.html'>{name}</a></h1>
704711
This dashboard summarizes the stability levels for all of the public modules of
705-
the crate, according to the total number of items at each level in the module and its children:
712+
the crate, according to the total number of items at each level in the module and
713+
its children (percentages total for {name}):
706714
<blockquote>
707-
<a class='stability Stable'></a> stable,<br/>
708-
<a class='stability Unstable'></a> unstable,<br/>
709-
<a class='stability Experimental'></a> experimental,<br/>
710-
<a class='stability Deprecated'></a> deprecated,<br/>
711-
<a class='stability Unmarked'></a> unmarked
715+
<a class='stability Stable'></a> stable ({}%),<br/>
716+
<a class='stability Unstable'></a> unstable ({}%),<br/>
717+
<a class='stability Experimental'></a> experimental ({}%),<br/>
718+
<a class='stability Deprecated'></a> deprecated ({}%),<br/>
719+
<a class='stability Unmarked'></a> unmarked ({}%)
712720
</blockquote>
713721
The counts do not include methods or trait
714722
implementations that are visible only through a re-exported type.",
715-
self.name));
723+
stable, unstable, experimental, deprecated, unmarked,
724+
name=self.name));
716725
try!(write!(f, "<table>"))
717726
try!(fmt_inner(f, &mut context, self));
718727
write!(f, "</table>")

src/librustdoc/html/static/main.css

+2-2
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ h1 .stability {
407407
.stability.Stable { border-color: #54A759; color: #2D8632; }
408408
.stability.Frozen { border-color: #009431; color: #007726; }
409409
.stability.Locked { border-color: #0084B6; color: #00668c; }
410-
.stability.Unmarked { border-color: #FFFFFF; }
410+
.stability.Unmarked { border-color: #BBBBBB; }
411411

412412
.summary {
413413
padding-right: 0px;
@@ -416,7 +416,7 @@ h1 .stability {
416416
.summary.Experimental { background-color: #D46D6A; }
417417
.summary.Unstable { background-color: #D4B16A; }
418418
.summary.Stable { background-color: #54A759; }
419-
.summary.Unmarked { background-color: #FFFFFF; }
419+
.summary.Unmarked { background-color: #BBBBBB; }
420420

421421
:target { background: #FDFFD3; }
422422

src/librustdoc/html/static/main.js

+3
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@
4242
$('.docblock.short').width(function() {
4343
return contentWidth - 40 - $(this).prev().width();
4444
}).addClass('nowrap');
45+
$('.summary-column').width(function() {
46+
return contentWidth - 40 - $(this).prev().width();
47+
})
4548
}, 150);
4649
}
4750
resizeShortBlocks();

0 commit comments

Comments
 (0)