提交 5636ca62 编写于 作者: A Alex Crichton

rustdoc: Start rendering variants (redirect to enum)

This allows reasonable behavior when an enum is clicked in an import.
上级 5c6f8a97
......@@ -589,6 +589,7 @@ fn fmt(it: &Item<'self>, fmt: &mut fmt::Formatter) {
clean::StructItem(ref s) => item_struct(fmt.buf, it.item, s),
clean::EnumItem(ref e) => item_enum(fmt.buf, it.item, e),
clean::TypedefItem(ref t) => item_typedef(fmt.buf, it.item, t),
clean::VariantItem(*) => item_variant(fmt.buf, it.cx, it.item),
_ => {}
}
}
......@@ -930,7 +931,8 @@ fn item_enum(w: &mut io::Writer, it: &clean::Item, e: &clean::Enum) {
} else {
write!(w, " \\{\n");
for v in e.variants.iter() {
let name = v.name.get_ref().as_slice();
let name = format!("<a name='variant.{0}'>{0}</a>",
v.name.get_ref().as_slice());
match v.inner {
clean::VariantItem(ref var) => {
match var.kind {
......@@ -1159,3 +1161,12 @@ fn build_sidebar(m: &clean::Module) -> HashMap<~str, ~[~str]> {
}
return map;
}
fn item_variant(w: &mut io::Writer, cx: &Context, it: &clean::Item) {
write!(w, "<DOCTYPE html><html><head>\
<meta http-equiv='refresh' content='0; \
url=../enum.{}.html\\#variant.{}'>\
</head><body></body></html>",
*cx.current.last(),
it.name.get_ref().as_slice());
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册