about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMichael Howell <michael@notriddle.com>2021-02-20 14:43:25 -0700
committerMichael Howell <michael@notriddle.com>2021-02-20 16:48:37 -0700
commit553852806dfea7b9d8fb03a1ca4f51d8e31b3a3c (patch)
tree2065500bb615adfd4c725b0e99ba9191b93b1773
parente7c23ab933ebc1f205c3b59f4ebc85d40f67d404 (diff)
downloadrust-553852806dfea7b9d8fb03a1ca4f51d8e31b3a3c.tar.gz
rust-553852806dfea7b9d8fb03a1ca4f51d8e31b3a3c.zip
Use the first paragraph, instead of cookie-cutter text, for rustdoc descriptions
Fixes #82283
-rw-r--r--src/librustdoc/html/render/mod.rs12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs
index f5eb92c1bb5..d7d69bc29f8 100644
--- a/src/librustdoc/html/render/mod.rs
+++ b/src/librustdoc/html/render/mod.rs
@@ -534,12 +534,17 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
         if !root_path.ends_with('/') {
             root_path.push('/');
         }
+        let description = krate
+            .module
+            .as_ref()
+            .and_then(|item| Some(plain_text_summary(item.doc_value()?.as_str())))
+            .unwrap_or_else(|| String::from("List of all items in this crate"));
         let mut page = layout::Page {
             title: "List of all items in this crate",
             css_class: "mod",
             root_path: "../",
             static_root_path: self.shared.static_root_path.as_deref(),
-            description: "List of all items in this crate",
+            description: description.as_str(),
             keywords: BASIC_KEYWORDS,
             resource_suffix: &self.shared.resource_suffix,
             extra_scripts: &[],
@@ -1548,7 +1553,10 @@ impl Context<'_> {
         }
         title.push_str(" - Rust");
         let tyname = it.type_();
-        let desc = if it.is_crate() {
+        let desc = it.doc_value().as_ref().map(|doc| plain_text_summary(&doc));
+        let desc = if let Some(desc) = desc {
+            desc
+        } else if it.is_crate() {
             format!("API documentation for the Rust `{}` crate.", self.shared.layout.krate)
         } else {
             format!(