diff options
| author | Brian Anderson <banderson@mozilla.com> | 2014-08-04 13:53:33 -0700 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2014-08-04 14:37:06 -0700 |
| commit | 08d44f5512e624eadfedf32d41f19ece13dd5fb4 (patch) | |
| tree | edf8599b1911f58dcf5d71a1b2e02a3a6bf7295f /src | |
| parent | efe1f7ee9efb5da5613f2cff4f9b810d2d5992d4 (diff) | |
| download | rust-08d44f5512e624eadfedf32d41f19ece13dd5fb4.tar.gz rust-08d44f5512e624eadfedf32d41f19ece13dd5fb4.zip | |
rustdoc: Use more descriptive description metadata.
This text appears in and improves search results. cc #12466
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustdoc/html/layout.rs | 4 | ||||
| -rw-r--r-- | src/librustdoc/html/render.rs | 20 |
2 files changed, 22 insertions, 2 deletions
diff --git a/src/librustdoc/html/layout.rs b/src/librustdoc/html/layout.rs index 70e9d004160..35157255069 100644 --- a/src/librustdoc/html/layout.rs +++ b/src/librustdoc/html/layout.rs @@ -26,6 +26,7 @@ pub struct Page<'a> { pub title: &'a str, pub ty: &'a str, pub root_path: &'a str, + pub description: &'a str } pub fn render<T: fmt::Show, S: fmt::Show>( @@ -38,8 +39,8 @@ r##"<!DOCTYPE html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> - <meta name="description" content="The {krate} library documentation."> <meta name="generator" content="rustdoc"> + <meta name="description" content="{description}"> <title>{title}</title> @@ -135,6 +136,7 @@ r##"<!DOCTYPE html> layout.logo) }, title = page.title, + description = page.description, favicon = if layout.favicon.len() == 0 { "".to_string() } else { diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 1700354e329..47e91470612 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -742,8 +742,10 @@ impl<'a> SourceCollector<'a> { let mut w = BufferedWriter::new(try!(File::create(&cur))); let title = format!("{} -- source", cur.filename_display()); + let desc = format!("Source to the Rust file `{}`.", filename); let page = layout::Page { title: title.as_slice(), + description: desc.as_slice(), ty: "source", root_path: root_path.as_slice(), }; @@ -1072,8 +1074,11 @@ impl Context { try!(stability.encode(&mut json::Encoder::new(&mut json_out))); let title = stability.name.clone().append(" - Stability dashboard"); + let desc = format!("API stability overview for the Rust `{}` crate.", + this.layout.krate); let page = layout::Page { ty: "mod", + description: desc.as_slice(), root_path: this.root_path.as_slice(), title: title.as_slice(), }; @@ -1120,8 +1125,21 @@ impl Context { title.push_str(it.name.get_ref().as_slice()); } title.push_str(" - Rust"); + let tyname = shortty(it).to_static_str(); + let is_crate = match it.inner { + clean::ModuleItem(clean::Module { items: _, is_crate: true }) => true, + _ => false + }; + let desc = if is_crate { + format!("API documentation for the Rust `{}` crate.", + cx.layout.krate) + } else { + format!("API documentation for the Rust `{}` {} in crate `{}`.", + it.name.get_ref(), tyname, cx.layout.krate) + }; let page = layout::Page { - ty: shortty(it).to_static_str(), + ty: tyname, + description: desc.as_slice(), root_path: cx.root_path.as_slice(), title: title.as_slice(), }; |
