Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions src/error-index-generator/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,7 @@ fn load_all_errors(metadata_dir: &Path) -> Result<ErrorMetadataMap, Box<Error>>
let path = try!(entry).path();

let mut metadata_str = String::new();
try!(
File::open(&path).and_then(|mut f|
f.read_to_string(&mut metadata_str))
);
try!(File::open(&path).and_then(|mut f| f.read_to_string(&mut metadata_str)));

let some_errors: ErrorMetadataMap = try!(json::decode(&metadata_str));

Expand Down Expand Up @@ -78,24 +75,23 @@ r##"<!DOCTYPE html>
// Enclose each error in a div so they can be shown/hidden en masse.
let desc_desc = match info.description {
Some(_) => "error-described",
None => "error-undescribed"
None => "error-undescribed",
};
let use_desc = match info.use_site {
Some(_) => "error-used",
None => "error-unused"
None => "error-unused",
};
try!(write!(&mut output_file, "<div class=\"{} {}\">", desc_desc, use_desc));

// Error title (with self-link).
try!(write!(&mut output_file,
"<h2 id=\"{0}\" class=\"section-header\"><a href=\"#{0}\">{0}</a></h2>\n",
err_code
));
"<h2 id=\"{0}\" class=\"section-header\"><a href=\"#{0}\">{0}</a></h2>\n",
err_code));

// Description rendered as markdown.
match info.description {
Some(ref desc) => try!(write!(&mut output_file, "{}", Markdown(desc))),
None => try!(write!(&mut output_file, "<p>No description.</p>\n"))
None => try!(write!(&mut output_file, "<p>No description.</p>\n")),
}

try!(write!(&mut output_file, "</div>\n"));
Expand Down