Remove short doc where it starts with a codeblock
This commit is contained in:
parent
653da4fd00
commit
3030cbea95
4 changed files with 78 additions and 35 deletions
|
|
@ -399,7 +399,6 @@ impl<'a, I: Iterator<Item = Event<'a>>> SummaryLine<'a, I> {
|
|||
fn check_if_allowed_tag(t: &Tag) -> bool {
|
||||
match *t {
|
||||
Tag::Paragraph
|
||||
| Tag::CodeBlock(_)
|
||||
| Tag::Item
|
||||
| Tag::Emphasis
|
||||
| Tag::Strong
|
||||
|
|
@ -420,29 +419,36 @@ impl<'a, I: Iterator<Item = Event<'a>>> Iterator for SummaryLine<'a, I> {
|
|||
if !self.started {
|
||||
self.started = true;
|
||||
}
|
||||
let event = self.inner.next();
|
||||
let mut is_start = true;
|
||||
let is_allowed_tag = match event {
|
||||
Some(Event::Start(ref c)) => {
|
||||
self.depth += 1;
|
||||
check_if_allowed_tag(c)
|
||||
}
|
||||
Some(Event::End(ref c)) => {
|
||||
self.depth -= 1;
|
||||
is_start = false;
|
||||
check_if_allowed_tag(c)
|
||||
}
|
||||
_ => true,
|
||||
};
|
||||
if is_allowed_tag == false {
|
||||
if is_start {
|
||||
Some(Event::Start(Tag::Paragraph))
|
||||
while let Some(event) = self.inner.next() {
|
||||
let mut is_start = true;
|
||||
let is_allowed_tag = match event {
|
||||
Event::Start(Tag::CodeBlock(_)) | Event::End(Tag::CodeBlock(_)) => {
|
||||
return None;
|
||||
}
|
||||
Event::Start(ref c) => {
|
||||
self.depth += 1;
|
||||
check_if_allowed_tag(c)
|
||||
}
|
||||
Event::End(ref c) => {
|
||||
self.depth -= 1;
|
||||
is_start = false;
|
||||
check_if_allowed_tag(c)
|
||||
}
|
||||
_ => {
|
||||
true
|
||||
}
|
||||
};
|
||||
return if is_allowed_tag == false {
|
||||
if is_start {
|
||||
Some(Event::Start(Tag::Paragraph))
|
||||
} else {
|
||||
Some(Event::End(Tag::Paragraph))
|
||||
}
|
||||
} else {
|
||||
Some(Event::End(Tag::Paragraph))
|
||||
}
|
||||
} else {
|
||||
event
|
||||
Some(event)
|
||||
};
|
||||
}
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2584,24 +2584,39 @@ fn item_module(w: &mut fmt::Formatter, cx: &Context,
|
|||
_ => "",
|
||||
};
|
||||
|
||||
let stab = myitem.stability_class();
|
||||
let add = if stab.is_some() {
|
||||
" "
|
||||
} else {
|
||||
""
|
||||
};
|
||||
|
||||
let doc_value = myitem.doc_value().unwrap_or("");
|
||||
write!(w, "
|
||||
<tr class='{stab} module-item'>
|
||||
<td><a class=\"{class}\" href=\"{href}\"
|
||||
title='{title_type} {title}'>{name}</a>{unsafety_flag}</td>
|
||||
<td class='docblock-short'>
|
||||
{stab_docs} {docs}
|
||||
</td>
|
||||
write!(w, "\
|
||||
<tr class='{stab}{add}module-item'>\
|
||||
<td><a class=\"{class}\" href=\"{href}\" \
|
||||
title='{title}'>{name}</a>{unsafety_flag}</td>\
|
||||
<td class='docblock-short'>{stab_docs}{docs}\
|
||||
</td>\
|
||||
</tr>",
|
||||
name = *myitem.name.as_ref().unwrap(),
|
||||
stab_docs = stab_docs,
|
||||
docs = MarkdownSummaryLine(doc_value, &myitem.links()),
|
||||
class = myitem.type_(),
|
||||
stab = myitem.stability_class().unwrap_or(String::new()),
|
||||
add = add,
|
||||
stab = stab.unwrap_or_else(|| String::new()),
|
||||
unsafety_flag = unsafety_flag,
|
||||
href = item_path(myitem.type_(), myitem.name.as_ref().unwrap()),
|
||||
title_type = myitem.type_(),
|
||||
title = full_path(cx, myitem))?;
|
||||
title = [full_path(cx, myitem), myitem.type_().to_string()]
|
||||
.iter()
|
||||
.filter_map(|s| if !s.is_empty() {
|
||||
Some(s.as_str())
|
||||
} else {
|
||||
None
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
.join(" "),
|
||||
)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue