@@ -70,6 +70,11 @@ fn moddoc_from_mod(
70
70
resdoc_from_resource ( decl, item. ident , item. id )
71
71
) )
72
72
}
73
+ ast:: item_iface ( _, methods) {
74
+ some ( doc:: ifacetag (
75
+ ifacedoc_from_iface ( methods, item. ident , item. id )
76
+ ) )
77
+ }
73
78
_ {
74
79
none
75
80
}
@@ -219,6 +224,57 @@ fn should_extract_resource_args() {
219
224
assert doc. topmod . resources ( ) [ 0 ] . args [ 0 ] . name == "b" ;
220
225
}
221
226
227
+ fn ifacedoc_from_iface (
228
+ methods : [ ast:: ty_method ] ,
229
+ name : str ,
230
+ id : ast:: node_id
231
+ ) -> doc:: ifacedoc {
232
+ {
233
+ id: id,
234
+ name: name,
235
+ brief: none,
236
+ desc: none,
237
+ methods: vec:: map ( methods) { |method|
238
+ {
239
+ name: method. ident ,
240
+ brief: none,
241
+ desc: none,
242
+ args: argdocs_from_args ( method. decl . inputs ) ,
243
+ return : {
244
+ desc: none,
245
+ ty: none
246
+ } ,
247
+ failure: none,
248
+ sig: none
249
+ }
250
+ }
251
+ }
252
+ }
253
+
254
+ #[ test]
255
+ fn should_extract_ifaces ( ) {
256
+ let source = "iface i { fn f(); }" ;
257
+ let ast = parse:: from_str ( source) ;
258
+ let doc = extract ( ast, "" ) ;
259
+ assert doc. topmod . ifaces ( ) [ 0 ] . name == "i" ;
260
+ }
261
+
262
+ #[ test]
263
+ fn should_extract_iface_methods ( ) {
264
+ let source = "iface i { fn f(); }" ;
265
+ let ast = parse:: from_str ( source) ;
266
+ let doc = extract ( ast, "" ) ;
267
+ assert doc. topmod . ifaces ( ) [ 0 ] . methods [ 0 ] . name == "f" ;
268
+ }
269
+
270
+ #[ test]
271
+ fn should_extract_iface_method_args ( ) {
272
+ let source = "iface i { fn f(a: bool); }" ;
273
+ let ast = parse:: from_str ( source) ;
274
+ let doc = extract ( ast, "" ) ;
275
+ assert doc. topmod . ifaces ( ) [ 0 ] . methods [ 0 ] . args [ 0 ] . name == "a" ;
276
+ }
277
+
222
278
#[ cfg( test) ]
223
279
mod tests {
224
280
0 commit comments