Skip to content

Commit d5922f5

Browse files
committed
---
yaml --- r: 13799 b: refs/heads/try c: e946792 h: refs/heads/master i: 13797: 1784436 13795: f6ee3db 13791: 3f6d19b v: v3
1 parent edb66a0 commit d5922f5

File tree

2 files changed

+57
-2
lines changed

2 files changed

+57
-2
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
refs/heads/master: 61b1875c16de39c166b0f4d54bba19f9c6777d1a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
5-
refs/heads/try: 2999479a2dcb10019558d64c2045fdee31841d31
5+
refs/heads/try: e946792a78590df3972fc4a9827d5e94d333d055
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

branches/try/src/rustdoc/extract.rs

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,17 @@ fn moddoc_from_mod(
7777
}
7878
}
7979
}),
80-
enums: doc::enumlist([])
80+
enums: doc::enumlist(
81+
vec::filter_map(module.items) {|item|
82+
alt item.node {
83+
ast::item_enum(variants, _) {
84+
some(enumdoc_from_enum(item.ident, item.id, variants))
85+
}
86+
_ {
87+
none
88+
}
89+
}
90+
})
8191
}
8292
}
8393

@@ -145,6 +155,51 @@ fn should_extract_const_name_and_id() {
145155
assert doc.topmod.consts[0].name == "a";
146156
}
147157

158+
fn enumdoc_from_enum(
159+
name: ast::ident,
160+
id: ast::node_id,
161+
variants: [ast::variant]
162+
) -> doc::enumdoc {
163+
~{
164+
id: id,
165+
name: name,
166+
brief: none,
167+
desc: none,
168+
variants: variantdocs_from_variants(variants)
169+
}
170+
}
171+
172+
fn variantdocs_from_variants(
173+
variants: [ast::variant]
174+
) -> [doc::variantdoc] {
175+
vec::map(variants, variantdoc_from_variant)
176+
}
177+
178+
fn variantdoc_from_variant(variant: ast::variant) -> doc::variantdoc {
179+
~{
180+
name: variant.node.name,
181+
desc: none,
182+
sig: none
183+
}
184+
}
185+
186+
#[test]
187+
fn should_extract_enums() {
188+
let source = "enum e { v }";
189+
let ast = parse::from_str(source);
190+
let doc = extract(ast, "");
191+
assert doc.topmod.enums[0].id != 0;
192+
assert doc.topmod.enums[0].name == "e";
193+
}
194+
195+
#[test]
196+
fn should_extract_enum_variants() {
197+
let source = "enum e { v }";
198+
let ast = parse::from_str(source);
199+
let doc = extract(ast, "");
200+
assert doc.topmod.enums[0].variants[0].name == "v";
201+
}
202+
148203
#[cfg(test)]
149204
mod tests {
150205

0 commit comments

Comments
 (0)