rustdoc: Use more descriptive description metadata.
This text appears in and improves search results. cc #12466
This commit is contained in:
parent
efe1f7ee9e
commit
08d44f5512
2 changed files with 22 additions and 2 deletions
|
@ -26,6 +26,7 @@ pub struct Page<'a> {
|
||||||
pub title: &'a str,
|
pub title: &'a str,
|
||||||
pub ty: &'a str,
|
pub ty: &'a str,
|
||||||
pub root_path: &'a str,
|
pub root_path: &'a str,
|
||||||
|
pub description: &'a str
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn render<T: fmt::Show, S: fmt::Show>(
|
pub fn render<T: fmt::Show, S: fmt::Show>(
|
||||||
|
@ -38,8 +39,8 @@ r##"<!DOCTYPE html>
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<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="generator" content="rustdoc">
|
||||||
|
<meta name="description" content="{description}">
|
||||||
|
|
||||||
<title>{title}</title>
|
<title>{title}</title>
|
||||||
|
|
||||||
|
@ -135,6 +136,7 @@ r##"<!DOCTYPE html>
|
||||||
layout.logo)
|
layout.logo)
|
||||||
},
|
},
|
||||||
title = page.title,
|
title = page.title,
|
||||||
|
description = page.description,
|
||||||
favicon = if layout.favicon.len() == 0 {
|
favicon = if layout.favicon.len() == 0 {
|
||||||
"".to_string()
|
"".to_string()
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -742,8 +742,10 @@ impl<'a> SourceCollector<'a> {
|
||||||
let mut w = BufferedWriter::new(try!(File::create(&cur)));
|
let mut w = BufferedWriter::new(try!(File::create(&cur)));
|
||||||
|
|
||||||
let title = format!("{} -- source", cur.filename_display());
|
let title = format!("{} -- source", cur.filename_display());
|
||||||
|
let desc = format!("Source to the Rust file `{}`.", filename);
|
||||||
let page = layout::Page {
|
let page = layout::Page {
|
||||||
title: title.as_slice(),
|
title: title.as_slice(),
|
||||||
|
description: desc.as_slice(),
|
||||||
ty: "source",
|
ty: "source",
|
||||||
root_path: root_path.as_slice(),
|
root_path: root_path.as_slice(),
|
||||||
};
|
};
|
||||||
|
@ -1072,8 +1074,11 @@ impl Context {
|
||||||
try!(stability.encode(&mut json::Encoder::new(&mut json_out)));
|
try!(stability.encode(&mut json::Encoder::new(&mut json_out)));
|
||||||
|
|
||||||
let title = stability.name.clone().append(" - Stability dashboard");
|
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 {
|
let page = layout::Page {
|
||||||
ty: "mod",
|
ty: "mod",
|
||||||
|
description: desc.as_slice(),
|
||||||
root_path: this.root_path.as_slice(),
|
root_path: this.root_path.as_slice(),
|
||||||
title: title.as_slice(),
|
title: title.as_slice(),
|
||||||
};
|
};
|
||||||
|
@ -1120,8 +1125,21 @@ impl Context {
|
||||||
title.push_str(it.name.get_ref().as_slice());
|
title.push_str(it.name.get_ref().as_slice());
|
||||||
}
|
}
|
||||||
title.push_str(" - Rust");
|
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 {
|
let page = layout::Page {
|
||||||
ty: shortty(it).to_static_str(),
|
ty: tyname,
|
||||||
|
description: desc.as_slice(),
|
||||||
root_path: cx.root_path.as_slice(),
|
root_path: cx.root_path.as_slice(),
|
||||||
title: title.as_slice(),
|
title: title.as_slice(),
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue