diff options
| author | Brian Anderson <banderson@mozilla.com> | 2012-01-24 18:02:33 -0800 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2012-01-24 18:02:33 -0800 |
| commit | 6d8058451b71f3e5a8178ca21856b529655df032 (patch) | |
| tree | ba4c819900c23ff1c11a803c0242b2aeb71be51b /src | |
| parent | fc64aefe0aebe547322e86b3e5daa4564d038e63 (diff) | |
| download | rust-6d8058451b71f3e5a8178ca21856b529655df032.tar.gz rust-6d8058451b71f3e5a8178ca21856b529655df032.zip | |
rustdoc: Parse fn failure conditions
Diffstat (limited to 'src')
| -rw-r--r-- | src/rustdoc/attr_parser.rs | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/rustdoc/attr_parser.rs b/src/rustdoc/attr_parser.rs index 2427dfa1784..8823cb4ebf0 100644 --- a/src/rustdoc/attr_parser.rs +++ b/src/rustdoc/attr_parser.rs @@ -25,7 +25,8 @@ type fn_attrs = { brief: option<str>, desc: option<str>, args: [arg_attrs], - return: option<str> + return: option<str>, + failure: option<str> }; type arg_attrs = { @@ -193,7 +194,8 @@ fn parse_fn( brief: none, desc: desc, args: [], - return: none + return: none, + failure: none } }, parse_fn_long_doc @@ -206,7 +208,7 @@ fn parse_fn_long_doc( desc: option<str> ) -> fn_attrs { let return = attr::meta_item_value_from_list(items, "return"); - + let failure = attr::meta_item_value_from_list(items, "failure"); let args = alt attr::meta_item_list_from_list(items, "args") { some(items) { vec::filter_map(items) {|item| @@ -225,7 +227,8 @@ fn parse_fn_long_doc( brief: brief, desc: desc, args: args, - return: return + return: return, + failure: failure } } @@ -281,6 +284,14 @@ fn parse_fn_should_parse_the_argument_descriptions() { assert attrs.args[1] == {name: "b", desc: "arg b"}; } +#[test] +fn parse_fn_should_parse_failure_conditions() { + let source = "#[doc(failure = \"it's the fail\")]"; + let attrs = test::parse_attributes(source); + let attrs = parse_fn(attrs); + assert attrs.failure == some("it's the fail"); +} + fn parse_const(attrs: [ast::attribute]) -> const_attrs { parse_short_doc_or( attrs, |
