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 push(s: &mut String, text_length: &mut usize, text: &str) {
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 t(input: &str, expect: &str) {
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 @@ fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
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)
}
}