diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs
index ff6cc56e5b4f5..59395648221c4 100644
--- a/src/librustdoc/html/render.rs
+++ b/src/librustdoc/html/render.rs
@@ -1087,7 +1087,8 @@ impl<'a> SourceCollector<'a> {
href.push_str(component);
href.push('/');
});
- let mut fname = p.file_name().expect("source has no filename")
+ let mut fname = p.file_name()
+ .expect("source has no filename")
.to_os_string();
fname.push(".html");
cur.push(&fname);
@@ -1373,6 +1374,135 @@ impl<'a> Cache {
}
}
+#[derive(Debug, Eq, PartialEq, Hash)]
+struct ItemEntry {
+ url: String,
+ name: String,
+}
+
+impl ItemEntry {
+ fn new(mut url: String, name: String) -> ItemEntry {
+ while url.starts_with('/') {
+ url.remove(0);
+ }
+ ItemEntry {
+ url,
+ name,
+ }
+ }
+}
+
+impl fmt::Display for ItemEntry {
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ write!(f, "{}", self.url, Escape(&self.name))
+ }
+}
+
+impl PartialOrd for ItemEntry {
+ fn partial_cmp(&self, other: &ItemEntry) -> Option<::std::cmp::Ordering> {
+ Some(self.cmp(other))
+ }
+}
+
+impl Ord for ItemEntry {
+ fn cmp(&self, other: &ItemEntry) -> ::std::cmp::Ordering {
+ self.name.cmp(&other.name)
+ }
+}
+
+#[derive(Debug)]
+struct AllTypes {
+ structs: HashSet Crate {} Version {} Back to index ")?;
- match it.inner {
- clean::StructItem(..) => write!(fmt, "Struct ")?,
- clean::TraitItem(..) => write!(fmt, "Trait ")?,
- clean::PrimitiveItem(..) => write!(fmt, "Primitive Type ")?,
- clean::UnionItem(..) => write!(fmt, "Union ")?,
- clean::EnumItem(..) => write!(fmt, "Enum ")?,
- clean::TypedefItem(..) => write!(fmt, "Type Definition ")?,
- clean::ForeignTypeItem => write!(fmt, "Foreign Type ")?,
- clean::ModuleItem(..) => if it.is_crate() {
- write!(fmt, "Crate ")?;
- } else {
- write!(fmt, "Module ")?;
+ write!(fmt, " {}{}{}
{}
",
+ title,
+ Escape(title),
+ class,
+ e.iter().map(|s| format!("\
+ List of all items\
+ \
+ \
+ \
+ [−]\
+ \
+
+
+
")?;
+ print_entries(f, &self.structs, "Structs", "structs")?;
+ print_entries(f, &self.enums, "Enums", "enums")?;
+ print_entries(f, &self.unions, "Unions", "unions")?;
+ print_entries(f, &self.primitives, "Primitives", "primitives")?;
+ print_entries(f, &self.traits, "Traits", "traits")?;
+ print_entries(f, &self.macros, "Macros", "macros")?;
+ print_entries(f, &self.functions, "Functions", "functions")?;
+ print_entries(f, &self.typedefs, "Typedefs", "typedefs")?;
+ print_entries(f, &self.statics, "Statics", "statics")?;
+ print_entries(f, &self.constants, "Constants", "constants")
+ }
+}
+
impl Context {
/// String representation of how to get back to the root path of the 'doc/'
/// folder in terms of a relative URL.
@@ -1414,16 +1544,52 @@ impl Context {
Some(i) => i,
None => return Ok(()),
};
+ let final_file = self.dst.join(&krate.name)
+ .join("all.html");
+ let crate_name = krate.name.clone();
item.name = Some(krate.name);
- // Render the crate documentation
- let mut work = vec![(self, item)];
+ let mut all = AllTypes::new();
- while let Some((mut cx, item)) = work.pop() {
- cx.item(item, |cx, item| {
- work.push((cx.clone(), item))
- })?
+ {
+ // Render the crate documentation
+ let mut work = vec![(self.clone(), item)];
+
+ while let Some((mut cx, item)) = work.pop() {
+ cx.item(item, &mut all, |cx, item| {
+ work.push((cx.clone(), item))
+ })?
+ }
}
+
+ let mut w = BufWriter::new(try_err!(File::create(&final_file), &final_file));
+ let mut root_path = self.dst.to_str().expect("invalid path").to_owned();
+ if !root_path.ends_with('/') {
+ root_path.push('/');
+ }
+ let page = layout::Page {
+ title: "List of all items in this crate",
+ css_class: "mod",
+ root_path: "../",
+ description: "List of all items in this crate",
+ keywords: BASIC_KEYWORDS,
+ resource_suffix: &self.shared.resource_suffix,
+ };
+ let sidebar = if let Some(ref version) = cache().crate_version {
+ format!("
Version {}
\ -See all {}'s items
", + version, + it.name.as_ref().unwrap())?; } } diff --git a/src/librustdoc/html/static/rustdoc.css b/src/librustdoc/html/static/rustdoc.css index 31a501d24e7db..cea1e89363216 100644 --- a/src/librustdoc/html/static/rustdoc.css +++ b/src/librustdoc/html/static/rustdoc.css @@ -1291,3 +1291,21 @@ kbd { font-size: 19px; display: block; } + +#main > ul { + padding-left: 10px; +} +#main > ul > li { + list-style: none; +} +#all-types { + text-align: center; + border: 1px solid; + margin: 0 10px; + margin-bottom: 10px; + display: block; + border-radius: 7px; +} +#all-types > p { + margin: 5px 0; +} \ No newline at end of file diff --git a/src/librustdoc/html/static/themes/dark.css b/src/librustdoc/html/static/themes/dark.css index 2d0fe55f70d26..f43a8598f33ed 100644 --- a/src/librustdoc/html/static/themes/dark.css +++ b/src/librustdoc/html/static/themes/dark.css @@ -389,3 +389,10 @@ kbd { background: #f0f0f0; } } + +#all-types { + background-color: #505050; +} +#all-types:hover { + background-color: #606060; +} diff --git a/src/librustdoc/html/static/themes/light.css b/src/librustdoc/html/static/themes/light.css index 2334a2728554e..e13818b4bd278 100644 --- a/src/librustdoc/html/static/themes/light.css +++ b/src/librustdoc/html/static/themes/light.css @@ -383,3 +383,10 @@ kbd { background: #fff; } } + +#all-types { + background-color: #fff; +} +#all-types:hover { + background-color: #f9f9f9; +} \ No newline at end of file diff --git a/src/test/rustdoc/all.rs b/src/test/rustdoc/all.rs new file mode 100644 index 0000000000000..ec391319b183c --- /dev/null +++ b/src/test/rustdoc/all.rs @@ -0,0 +1,30 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0