Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Manishearth committed May 20, 2016
1 parent 74633b0 commit 9ce018b
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 21 deletions.
32 changes: 17 additions & 15 deletions src/librustdoc/html/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1660,7 +1660,8 @@ fn document(w: &mut fmt::Formatter, cx: &Context, item: &clean::Item) -> fmt::Re
fn document_short(w: &mut fmt::Formatter, item: &clean::Item, link: AssocItemLink) -> fmt::Result {
if let Some(s) = item.doc_value() {
let markdown = if s.contains('\n') {
format!("{} [Read more]({})", &plain_summary_line(Some(s)), naive_assoc_href(item, link))
format!("{} [Read more]({})",
&plain_summary_line(Some(s)), naive_assoc_href(item, link))
} else {
format!("{}", &plain_summary_line(Some(s)))
};
Expand Down Expand Up @@ -2619,25 +2620,26 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi
_ => panic!("can't make docs for trait item with name {:?}", item.name)
}

if !is_default_item && (!is_static || render_static) {
if !is_static || render_static {
if !is_default_item {

if item.doc_value().is_some() {
document(w, cx, item)
} else {
// In case the item isn't documented,
// provide short documentation from the trait
if let Some(t) = trait_ {
if let Some(it) = t.items.iter()
.find(|i| i.name == item.name) {
document_short(w, it, link)?;
if item.doc_value().is_some() {
document(w, cx, item)?;
} else {
// In case the item isn't documented,
// provide short documentation from the trait
if let Some(t) = trait_ {
if let Some(it) = t.items.iter()
.find(|i| i.name == item.name) {
document_short(w, it, link)?;
}
}
}
Ok(())
} else {
document_short(w, item, link)?;
}
} else {
document_short(w, item, link)?;
Ok(())
}
Ok(())
}

let traits = &cache().traits;
Expand Down
25 changes: 19 additions & 6 deletions src/test/rustdoc/manual_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,24 @@ pub trait T {
fn b_method(&self) -> usize {
self.a_method()
}

/// Docs associated with the trait c_method definition.
///
/// There is another line
fn c_method(&self) -> usize {
self.a_method()
}
}

// @has manual_impl/struct.S1.html '//*[@class="trait"]' 'T'
// @has - '//*[@class="docblock"]' 'Docs associated with the S1 trait implementation.'
// @has - '//*[@class="docblock"]' 'Docs associated with the S1 trait a_method implementation.'
// @!has - '//*[@class="docblock"]' 'Docs associated with the trait a_method definition.'
// @!has - '//*[@class="docblock"]' 'Docs associated with the trait b_method definition.'
// @has - '//*[@class="docblock"]' 'Docs associated with the trait b_method definition.'
// @has - '//*[@class="docblock"]' 'Docs associated with the trait b_method definition.'
// @has - '//*[@class="docblock"]' 'Docs associated with the trait c_method definition.'
// @!has - '//*[@class="docblock"]' 'There is another line'
// @has - '//*[@class="docblock"]' 'Read more'
pub struct S1(usize);

/// Docs associated with the S1 trait implementation.
Expand All @@ -41,9 +52,11 @@ impl T for S1 {
// @has manual_impl/struct.S2.html '//*[@class="trait"]' 'T'
// @has - '//*[@class="docblock"]' 'Docs associated with the S2 trait implementation.'
// @has - '//*[@class="docblock"]' 'Docs associated with the S2 trait a_method implementation.'
// @has - '//*[@class="docblock"]' 'Docs associated with the S2 trait b_method implementation.'
// @has - '//*[@class="docblock"]' 'Docs associated with the S2 trait c_method implementation.'
// @!has - '//*[@class="docblock"]' 'Docs associated with the trait a_method definition.'
// @!has - '//*[@class="docblock"]' 'Docs associated with the trait b_method definition.'
// @!has - '//*[@class="docblock"]' 'Docs associated with the trait c_method definition.'
// @has - '//*[@class="docblock"]' 'Docs associated with the trait b_method definition.'
// @!has - '//*[@class="docblock"]' 'Read more'
pub struct S2(usize);

/// Docs associated with the S2 trait implementation.
Expand All @@ -53,16 +66,16 @@ impl T for S2 {
self.0
}

/// Docs associated with the S2 trait b_method implementation.
fn b_method(&self) -> usize {
/// Docs associated with the S2 trait c_method implementation.
fn c_method(&self) -> usize {
5
}
}

// @has manual_impl/struct.S3.html '//*[@class="trait"]' 'T'
// @has - '//*[@class="docblock"]' 'Docs associated with the S3 trait implementation.'
// @has - '//*[@class="docblock"]' 'Docs associated with the S3 trait b_method implementation.'
// @!has - '//*[@class="docblock"]' 'Docs associated with the trait a_method definition.'
// @has - '//*[@class="docblock"]' 'Docs associated with the trait a_method definition.'
pub struct S3(usize);

/// Docs associated with the S3 trait implementation.
Expand Down

0 comments on commit 9ce018b

Please sign in to comment.