rustdoc: render derived impls separately
This commit is contained in:
parent
e88387a947
commit
1f937fa79e
2 changed files with 30 additions and 3 deletions
|
@ -1020,11 +1020,23 @@ pub struct Impl {
|
||||||
generics: Generics,
|
generics: Generics,
|
||||||
trait_: Option<Type>,
|
trait_: Option<Type>,
|
||||||
for_: Type,
|
for_: Type,
|
||||||
methods: Vec<Item> ,
|
methods: Vec<Item>,
|
||||||
|
derived: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Clean<Item> for doctree::Impl {
|
impl Clean<Item> for doctree::Impl {
|
||||||
fn clean(&self) -> Item {
|
fn clean(&self) -> Item {
|
||||||
|
let mut derived = false;
|
||||||
|
for attr in self.attrs.iter() {
|
||||||
|
match attr.node.value.node {
|
||||||
|
ast::MetaWord(ref s) => {
|
||||||
|
if s.get() == "automatically_derived" {
|
||||||
|
derived = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
Item {
|
Item {
|
||||||
name: None,
|
name: None,
|
||||||
attrs: self.attrs.clean(),
|
attrs: self.attrs.clean(),
|
||||||
|
@ -1036,6 +1048,7 @@ impl Clean<Item> for doctree::Impl {
|
||||||
trait_: self.trait_.clean(),
|
trait_: self.trait_.clean(),
|
||||||
for_: self.for_.clean(),
|
for_: self.for_.clean(),
|
||||||
methods: self.methods.clean(),
|
methods: self.methods.clean(),
|
||||||
|
derived: derived,
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1517,8 +1517,22 @@ fn render_methods(w: &mut Writer, it: &clean::Item) -> fmt::Result {
|
||||||
if traits.len() > 0 {
|
if traits.len() > 0 {
|
||||||
try!(write!(w, "<h2 id='implementations'>Trait \
|
try!(write!(w, "<h2 id='implementations'>Trait \
|
||||||
Implementations</h2>"));
|
Implementations</h2>"));
|
||||||
for &(ref i, ref dox) in traits.move_iter() {
|
let mut any_derived = false;
|
||||||
try!(render_impl(w, i, dox));
|
for & &(ref i, ref dox) in traits.iter() {
|
||||||
|
if !i.derived {
|
||||||
|
try!(render_impl(w, i, dox));
|
||||||
|
} else {
|
||||||
|
any_derived = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if any_derived {
|
||||||
|
try!(write!(w, "<h3 id='derived_implementations'>Derived Implementations \
|
||||||
|
</h3>"));
|
||||||
|
for &(ref i, ref dox) in traits.move_iter() {
|
||||||
|
if i.derived {
|
||||||
|
try!(render_impl(w, i, dox));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue