File tree Expand file tree Collapse file tree 3 files changed +28
-4
lines changed Expand file tree Collapse file tree 3 files changed +28
-4
lines changed Original file line number Diff line number Diff line change @@ -154,11 +154,23 @@ fn fold_fn(
154
154
}
155
155
156
156
fn merge_arg_attrs (
157
- doc : [ doc:: argdoc ] ,
158
- _attrs : [ attr_parser:: arg_attrs ]
157
+ docs : [ doc:: argdoc ] ,
158
+ attrs : [ attr_parser:: arg_attrs ]
159
159
) -> [ doc:: argdoc ] {
160
- // FIXME
161
- doc
160
+ vec:: map ( docs) { |doc|
161
+ alt vec:: find ( attrs) { |attr|
162
+ attr. name == doc. name
163
+ } {
164
+ some ( attr) {
165
+ ~{
166
+ desc: some ( attr. desc )
167
+ with * doc
168
+ }
169
+ }
170
+ none. { doc }
171
+ }
172
+ }
173
+ // FIXME: Warning when documenting a non-existant arg
162
174
}
163
175
164
176
fn merge_ret_attrs (
@@ -179,3 +191,13 @@ fn fold_fn_should_extract_fn_attributes() {
179
191
let doc = fold_fn ( fold, doc. topmod . fns [ 0 ] ) ;
180
192
assert doc. desc == some ( "test" ) ;
181
193
}
194
+
195
+ #[ test]
196
+ fn fold_fn_should_extract_arg_attributes ( ) {
197
+ let source = "#[doc(args(a = \" b\" ))] fn c(a: bool) { }" ;
198
+ let srv = astsrv:: mk_srv_from_str ( source) ;
199
+ let doc = extract:: from_srv ( srv, "" ) ;
200
+ let fold = fold:: default_seq_fold ( srv) ;
201
+ let doc = fold_fn ( fold, doc. topmod . fns [ 0 ] ) ;
202
+ assert doc. args [ 0 ] . desc == some ( "b" ) ;
203
+ }
Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ type fndoc = ~{
26
26
27
27
type argdoc = ~{
28
28
name : str ,
29
+ desc : option < str > ,
29
30
ty: option < str >
30
31
} ;
31
32
Original file line number Diff line number Diff line change @@ -100,6 +100,7 @@ fn argdocs_from_args(args: [ast::arg]) -> [doc::argdoc] {
100
100
fn argdoc_from_arg ( arg : ast:: arg ) -> doc:: argdoc {
101
101
~{
102
102
name: arg. ident ,
103
+ desc: none,
103
104
ty: none
104
105
}
105
106
}
You can’t perform that action at this time.
0 commit comments