doc: Fix a number of broken links

cc #14515
This commit is contained in:
Alex Crichton
2014-05-29 09:58:09 -07:00
parent 8c669d7f74
commit c5830a954e
9 changed files with 52 additions and 35 deletions

View File

@@ -278,18 +278,24 @@ fn primitive_link(f: &mut fmt::Formatter,
needs_termination = true;
}
Some(&cnum) => {
let path = m.paths.get(&ast::DefId {
krate: cnum,
node: ast::CRATE_NODE_ID,
});
let loc = match *m.extern_locations.get(&cnum) {
render::Remote(ref s) => Some(s.to_string()),
render::Local => {
let loc = current_location_key.get().unwrap();
Some(("../".repeat(loc.len())).to_string())
Some("../".repeat(loc.len()))
}
render::Unknown => None,
};
match loc {
Some(s) => {
try!(write!(f, "<a href='{}/primitive.{}.html'>",
s, prim.to_url_str()));
Some(root) => {
try!(write!(f, "<a href='{}{}/primitive.{}.html'>",
root,
path.ref0().as_slice().head().unwrap(),
prim.to_url_str()));
needs_termination = true;
}
None => {}

View File

@@ -1380,8 +1380,13 @@ fn item_module(w: &mut fmt::Formatter, cx: &Context,
if s.len() == 0 { return Ok(()); }
try!(write!(f, "<code> = </code>"));
if s.contains("\n") {
write!(f, "<a href='{}'>[definition]</a>",
item.href())
match item.href() {
Some(url) => {
write!(f, "<a href='{}'>[definition]</a>",
url)
}
None => Ok(()),
}
} else {
write!(f, "<code>{}</code>", s.as_slice())
}
@@ -1547,8 +1552,8 @@ fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
}
try!(write!(w, "</ul>"));
try!(write!(w, r#"<script type="text/javascript" async
src="{root_path}/implementors/{path}/\
{ty}.{name}.js"></script>"#,
src="{root_path}/implementors/{path}/{ty}.{name}.js">
</script>"#,
root_path = Vec::from_elem(cx.current.len(), "..").connect("/"),
path = if ast_util::is_local(it.def_id) {
cx.current.connect("/")