Make rustdoc display extern crate statements correctly

This commit is contained in:
P1start 2014-11-22 19:07:54 +13:00
parent 2f0249b3a8
commit 6b5655cb84
2 changed files with 8 additions and 6 deletions

View File

@ -1923,7 +1923,7 @@ impl Clean<ViewItemInner> for ast::ViewItem_ {
#[deriving(Clone, Encodable, Decodable)]
pub enum ViewPath {
// use str = source;
// use source as str;
SimpleImport(String, ImportSource),
// use source::*;
GlobImport(ImportSource),

View File

@ -1582,12 +1582,14 @@ fn item_module(w: &mut fmt::Formatter, cx: &Context,
clean::ViewItemItem(ref item) => {
match item.inner {
clean::ExternCrate(ref name, ref src, _) => {
try!(write!(w, "<tr><td><code>extern crate {}",
name.as_slice()));
match *src {
Some(ref src) => try!(write!(w, " = \"{}\"",
src.as_slice())),
None => {}
Some(ref src) =>
try!(write!(w, "<tr><td><code>extern crate \"{}\" as {}",
src.as_slice(),
name.as_slice())),
None =>
try!(write!(w, "<tr><td><code>extern crate {}",
name.as_slice())),
}
try!(write!(w, ";</code></td></tr>"));
}