Split rustdoc summary lines in a smarter way
Previously it would fail on a trivial case like /// Summary line /// <trailing space> /// Regular content Compliant markdown preprocessor would render that as two separate paragraphs, but our summary line extractor would interpret both lines as the same paragraph and include both into the short summary.
This commit is contained in:
parent
9eb69abad8
commit
b09e5daa89
1 changed files with 10 additions and 9 deletions
|
@ -407,7 +407,7 @@ fn build_index(krate: &clean::Crate, cache: &mut Cache) -> io::Result<String> {
|
||||||
ty: shortty(item),
|
ty: shortty(item),
|
||||||
name: item.name.clone().unwrap(),
|
name: item.name.clone().unwrap(),
|
||||||
path: fqp[..fqp.len() - 1].connect("::"),
|
path: fqp[..fqp.len() - 1].connect("::"),
|
||||||
desc: shorter(item.doc_value()).to_string(),
|
desc: shorter(item.doc_value()),
|
||||||
parent: Some(did),
|
parent: Some(did),
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -876,7 +876,7 @@ impl DocFolder for Cache {
|
||||||
ty: shortty(&item),
|
ty: shortty(&item),
|
||||||
name: s.to_string(),
|
name: s.to_string(),
|
||||||
path: path.connect("::").to_string(),
|
path: path.connect("::").to_string(),
|
||||||
desc: shorter(item.doc_value()).to_string(),
|
desc: shorter(item.doc_value()),
|
||||||
parent: parent,
|
parent: parent,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1467,13 +1467,14 @@ fn full_path(cx: &Context, item: &clean::Item) -> String {
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
fn shorter<'a>(s: Option<&'a str>) -> &'a str {
|
fn shorter<'a>(s: Option<&'a str>) -> String {
|
||||||
match s {
|
match s {
|
||||||
Some(s) => match s.find("\n\n") {
|
Some(s) => s.lines().take_while(|line|{
|
||||||
Some(pos) => &s[..pos],
|
(*line).chars().any(|chr|{
|
||||||
None => s,
|
!chr.is_whitespace()
|
||||||
},
|
})
|
||||||
None => ""
|
}).collect::<Vec<_>>().connect("\n"),
|
||||||
|
None => "".to_string()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1603,7 +1604,7 @@ fn item_module(w: &mut fmt::Formatter, cx: &Context,
|
||||||
</tr>
|
</tr>
|
||||||
",
|
",
|
||||||
*myitem.name.as_ref().unwrap(),
|
*myitem.name.as_ref().unwrap(),
|
||||||
Markdown(shorter(myitem.doc_value())),
|
Markdown(&shorter(myitem.doc_value())[..]),
|
||||||
class = shortty(myitem),
|
class = shortty(myitem),
|
||||||
href = item_path(myitem),
|
href = item_path(myitem),
|
||||||
title = full_path(cx, myitem),
|
title = full_path(cx, myitem),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue