@@ -75,6 +75,11 @@ fn moddoc_from_mod(
75
75
ifacedoc_from_iface ( methods, item. ident , item. id )
76
76
) )
77
77
}
78
+ ast:: item_impl ( _, _, _, methods) {
79
+ some ( doc:: impltag (
80
+ impldoc_from_impl ( methods, item. ident , item. id )
81
+ ) )
82
+ }
78
83
_ {
79
84
none
80
85
}
@@ -275,6 +280,67 @@ fn should_extract_iface_method_args() {
275
280
assert doc. topmod . ifaces ( ) [ 0 ] . methods [ 0 ] . args [ 0 ] . name == "a" ;
276
281
}
277
282
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
+
278
344
#[ cfg( test) ]
279
345
mod tests {
280
346
0 commit comments