Skip to content

Commit

Permalink
Rollup merge of #82962 - notriddle:cleanup-index, r=jyn514
Browse files Browse the repository at this point in the history
Treat header as first paragraph for shortened markdown descriptions

"The Rust Standard LibraryThe Rust Standard Library is the …" is an awful description.
  • Loading branch information
Dylan-DPC committed Mar 10, 2021
2 parents b9a2570 + 66b6504 commit 5c62a18
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/librustdoc/html/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down
1 change: 1 addition & 0 deletions src/librustdoc/html/markdown/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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```", "");
Expand Down
6 changes: 1 addition & 5 deletions src/librustdoc/html/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down

0 comments on commit 5c62a18

Please sign in to comment.