Rollup merge of #82962 - notriddle:cleanup-index, r=jyn514

Treat header as first paragraph for shortened markdown descriptions

"The Rust Standard LibraryThe Rust Standard Library is the …" is an awful description.
This commit is contained in:
Dylan DPC 2021-03-10 17:55:45 +01:00 committed by GitHub
commit 5c62a182a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 5 deletions

View File

@ -1093,6 +1093,7 @@ fn markdown_summary_with_limit(md: &str, length_limit: usize) -> (String, bool)
Tag::Emphasis => s.push_str("</em>"),
Tag::Strong => s.push_str("</strong>"),
Tag::Paragraph => break,
Tag::Heading(..) => break,
_ => {}
},
Event::HardBreak | Event::SoftBreak => {

View File

@ -235,6 +235,7 @@ fn test_short_markdown_summary() {
t("code `let x = i32;` ...", "code <code>let x = i32;</code> …");
t("type `Type<'static>` ...", "type <code>Type<'static></code> …");
t("# top header", "top header");
t("# top header\n\nfollowed by a paragraph", "top header");
t("## header", "header");
t("first paragraph\n\nsecond paragraph", "first paragraph");
t("```\nfn main() {}\n```", "");

View File

@ -286,11 +286,7 @@ impl Serialize for TypeWithKind {
where
S: Serializer,
{
let mut seq = serializer.serialize_seq(None)?;
seq.serialize_element(&self.ty.name)?;
let x: ItemType = self.kind.into();
seq.serialize_element(&x)?;
seq.end()
(&self.ty.name, ItemType::from(self.kind)).serialize(serializer)
}
}