Skip to content

Commit c46f3ff

Browse files
author
Ulrik Sverdrup
committed
rustdoc: Add Associated Constants section
Section only visible if there are assoc. consts. present.
1 parent ff4e061 commit c46f3ff

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/librustdoc/html/render.rs

+11
Original file line numberDiff line numberDiff line change
@@ -1862,6 +1862,17 @@ fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
18621862
try!(write!(w, "</div>"));
18631863
}
18641864

1865+
if !consts.is_empty() {
1866+
try!(write!(w, "
1867+
<h2 id='associated-const'>Associated Constants</h2>
1868+
<div class='methods'>
1869+
"));
1870+
for t in &consts {
1871+
try!(trait_item(w, *t));
1872+
}
1873+
try!(write!(w, "</div>"));
1874+
}
1875+
18651876
// Output the documentation for each function individually
18661877
if !required.is_empty() {
18671878
try!(write!(w, "

src/test/rustdoc/assoc-consts.rs

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
pub trait Foo {
1414
// @has assoc_consts/trait.Foo.html '//*[@class="rust trait"]' \
1515
// 'const FOO: usize;'
16+
// @has - '//*[@id="associatedconstant.FOO"]' 'const FOO'
1617
const FOO: usize;
1718
}
1819

0 commit comments

Comments
 (0)