Skip to content

Commit f207331

Browse files
committed
---
yaml --- r: 13941 b: refs/heads/try c: 7d6cf37 h: refs/heads/master i: 13939: 13c5751 v: v3
1 parent 5cc9f33 commit f207331

File tree

2 files changed

+67
-1
lines changed

2 files changed

+67
-1
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: acb11f47dc7b7fb03caeee5ade2c7002cb20cb6f
5+
refs/heads/try: 7d6cf37a8d813bc4231e833f27e6242ac9c88a87
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

branches/try/src/rustdoc/extract.rs

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ fn moddoc_from_mod(
7575
ifacedoc_from_iface(methods, item.ident, item.id)
7676
))
7777
}
78+
ast::item_impl(_, _, _, methods) {
79+
some(doc::impltag(
80+
impldoc_from_impl(methods, item.ident, item.id)
81+
))
82+
}
7883
_ {
7984
none
8085
}
@@ -275,6 +280,67 @@ fn should_extract_iface_method_args() {
275280
assert doc.topmod.ifaces()[0].methods[0].args[0].name == "a";
276281
}
277282

283+
fn impldoc_from_impl(
284+
methods: [@ast::method],
285+
name: str,
286+
id: ast::node_id
287+
) -> doc::impldoc {
288+
{
289+
id: id,
290+
name: name,
291+
brief: none,
292+
desc: none,
293+
iface_ty: none,
294+
for_ty: none,
295+
methods: vec::map(methods) {|method|
296+
{
297+
name: method.ident,
298+
brief: none,
299+
desc: none,
300+
args: argdocs_from_args(method.decl.inputs),
301+
return: {
302+
desc: none,
303+
ty: none
304+
},
305+
failure: none,
306+
sig: none
307+
}
308+
}
309+
}
310+
}
311+
312+
#[test]
313+
fn should_extract_impls_with_names() {
314+
let source = "impl i for int { fn a() { } }";
315+
let ast = parse::from_str(source);
316+
let doc = extract(ast, "");
317+
assert doc.topmod.impls()[0].name == "i";
318+
}
319+
320+
#[test]
321+
fn should_extract_impls_without_names() {
322+
let source = "impl of i for int { fn a() { } }";
323+
let ast = parse::from_str(source);
324+
let doc = extract(ast, "");
325+
assert doc.topmod.impls()[0].name == "i";
326+
}
327+
328+
#[test]
329+
fn should_extract_impl_methods() {
330+
let source = "impl i for int { fn f() { } }";
331+
let ast = parse::from_str(source);
332+
let doc = extract(ast, "");
333+
assert doc.topmod.impls()[0].methods[0].name == "f";
334+
}
335+
336+
#[test]
337+
fn should_extract_impl_method_args() {
338+
let source = "impl i for int { fn f(a: bool) { } }";
339+
let ast = parse::from_str(source);
340+
let doc = extract(ast, "");
341+
assert doc.topmod.impls()[0].methods[0].args[0].name == "a";
342+
}
343+
278344
#[cfg(test)]
279345
mod tests {
280346

0 commit comments

Comments
 (0)