File tree Expand file tree Collapse file tree 1 file changed +31
-1
lines changed Expand file tree Collapse file tree 1 file changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -66,7 +66,17 @@ fn moddoc_from_mod(
66
66
}
67
67
}
68
68
} ) ,
69
- consts: doc:: constlist ( [ ] )
69
+ consts: doc:: constlist (
70
+ vec:: filter_map ( module. items ) { |item|
71
+ alt item. node {
72
+ ast:: item_const ( _, _) {
73
+ some ( constdoc_from_const ( item. ident , item. id ) )
74
+ }
75
+ _ {
76
+ none
77
+ }
78
+ }
79
+ } )
70
80
}
71
81
}
72
82
@@ -111,6 +121,26 @@ fn argdoc_from_arg(arg: ast::arg) -> doc::argdoc {
111
121
}
112
122
}
113
123
124
+ fn constdoc_from_const (
125
+ name : ast:: ident ,
126
+ id : ast:: node_id
127
+ ) -> doc:: constdoc {
128
+ ~{
129
+ id: id,
130
+ name: name,
131
+ ty: none
132
+ }
133
+ }
134
+
135
+ #[ test]
136
+ fn should_extract_const_name_and_id ( ) {
137
+ let source = "const a: int = 0;" ;
138
+ let ast = parse:: from_str ( source) ;
139
+ let doc = extract ( ast, "" ) ;
140
+ assert doc. topmod . consts [ 0 ] . id != 0 ;
141
+ assert doc. topmod . consts [ 0 ] . name == "a" ;
142
+ }
143
+
114
144
#[ cfg( test) ]
115
145
mod tests {
116
146
You can’t perform that action at this time.
0 commit comments