Skip to content

Commit d12b269

Browse files
committed
---
yaml --- r: 11738 b: refs/heads/master c: 0905ad2 h: refs/heads/master v: v3
1 parent 371e5a9 commit d12b269

13 files changed

+38
-1245
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 9f4c0d71e521112e8113e552c06739440fb193d7
2+
refs/heads/master: 0905ad2bbe66d11e73a6bef723d14c0e022c0943
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf

trunk/src/rustdoc/attr_parser.rs

Lines changed: 2 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,8 @@ import rustc::syntax::ast;
99
import rustc::front::attr;
1010
import core::tuple;
1111

12-
export crate_attrs, basic_attrs, fn_attrs, arg_attrs,
13-
variant_attrs, res_attrs, method_attrs;
14-
export parse_crate, parse_basic, parse_fn,
15-
parse_variant, parse_res, parse_method;
12+
export crate_attrs, basic_attrs, variant_attrs;
13+
export parse_crate, parse_basic, parse_variant;
1614
export parse_hidden;
1715

1816
type crate_attrs = {
@@ -24,27 +22,10 @@ type basic_attrs = {
2422
desc: option<str>
2523
};
2624

27-
type fn_attrs = {
28-
args: [arg_attrs],
29-
return: option<str>,
30-
failure: option<str>
31-
};
32-
33-
type arg_attrs = {
34-
name: str,
35-
desc: str
36-
};
37-
3825
type variant_attrs = {
3926
desc: option<str>
4027
};
4128

42-
type res_attrs = {
43-
args: [arg_attrs]
44-
};
45-
46-
type method_attrs = fn_attrs;
47-
4829
#[cfg(test)]
4930
mod test {
5031

@@ -231,72 +212,6 @@ fn parse_long_doc<T>(
231212
}
232213
}
233214

234-
fn parse_fn(attrs: [ast::attribute]) -> fn_attrs {
235-
parse_long_doc(attrs, parse_fn_long_doc)
236-
}
237-
238-
fn parse_fn_long_doc(items: [@ast::meta_item]) -> fn_attrs {
239-
let return = attr::meta_item_value_from_list(items, "return");
240-
let failure = attr::meta_item_value_from_list(items, "failure");
241-
let args = parse_args(items);
242-
243-
{
244-
args: args,
245-
return: return,
246-
failure: failure
247-
}
248-
}
249-
250-
fn parse_args(items: [@ast::meta_item]) -> [arg_attrs] {
251-
alt attr::meta_item_list_from_list(items, "args") {
252-
some(items) {
253-
vec::filter_map(items) {|item|
254-
option::map(attr::name_value_str_pair(item)) { |pair|
255-
{
256-
name: tuple::first(pair),
257-
desc: tuple::second(pair)
258-
}
259-
}
260-
}
261-
}
262-
none { [] }
263-
}
264-
}
265-
266-
#[test]
267-
fn parse_fn_should_handle_undocumented_functions() {
268-
let source = "";
269-
let attrs = test::parse_attributes(source);
270-
let attrs = parse_fn(attrs);
271-
assert attrs.return == none;
272-
assert vec::len(attrs.args) == 0u;
273-
}
274-
275-
#[test]
276-
fn parse_fn_should_parse_the_return_value_description() {
277-
let source = "#[doc(return = \"return value\")]";
278-
let attrs = test::parse_attributes(source);
279-
let attrs = parse_fn(attrs);
280-
assert attrs.return == some("return value");
281-
}
282-
283-
#[test]
284-
fn parse_fn_should_parse_the_argument_descriptions() {
285-
let source = "#[doc(args(a = \"arg a\", b = \"arg b\"))]";
286-
let attrs = test::parse_attributes(source);
287-
let attrs = parse_fn(attrs);
288-
assert attrs.args[0] == {name: "a", desc: "arg a"};
289-
assert attrs.args[1] == {name: "b", desc: "arg b"};
290-
}
291-
292-
#[test]
293-
fn parse_fn_should_parse_failure_conditions() {
294-
let source = "#[doc(failure = \"it's the fail\")]";
295-
let attrs = test::parse_attributes(source);
296-
let attrs = parse_fn(attrs);
297-
assert attrs.failure == some("it's the fail");
298-
}
299-
300215
fn parse_variant(attrs: [ast::attribute]) -> variant_attrs {
301216
parse_short_doc_or(
302217
attrs,
@@ -342,29 +257,6 @@ fn should_parse_variant_long_doc() {
342257
assert attrs.desc == some("a");
343258
}
344259

345-
fn parse_res(attrs: [ast::attribute]) -> res_attrs {
346-
parse_long_doc(attrs, parse_res_long_doc)
347-
}
348-
349-
fn parse_res_long_doc(items: [@ast::meta_item]) -> res_attrs {
350-
{
351-
args: parse_args(items)
352-
}
353-
}
354-
355-
#[test]
356-
fn shoulde_parse_resource_arg() {
357-
let source = "#[doc(args(a = \"b\"))]";
358-
let attrs = test::parse_attributes(source);
359-
let attrs = parse_res(attrs);
360-
assert attrs.args[0].name == "a";
361-
assert attrs.args[0].desc == "b";
362-
}
363-
364-
fn parse_method(attrs: [ast::attribute]) -> method_attrs {
365-
parse_fn(attrs)
366-
}
367-
368260
fn parse_hidden(attrs: [ast::attribute]) -> bool {
369261
parse_short_doc_or(
370262
attrs,

0 commit comments

Comments
 (0)