rustdoc: Parse fn failure conditions
This commit is contained in:
parent
fc64aefe0a
commit
6d8058451b
1 changed files with 15 additions and 4 deletions
|
@ -25,7 +25,8 @@ type fn_attrs = {
|
||||||
brief: option<str>,
|
brief: option<str>,
|
||||||
desc: option<str>,
|
desc: option<str>,
|
||||||
args: [arg_attrs],
|
args: [arg_attrs],
|
||||||
return: option<str>
|
return: option<str>,
|
||||||
|
failure: option<str>
|
||||||
};
|
};
|
||||||
|
|
||||||
type arg_attrs = {
|
type arg_attrs = {
|
||||||
|
@ -193,7 +194,8 @@ fn parse_fn(
|
||||||
brief: none,
|
brief: none,
|
||||||
desc: desc,
|
desc: desc,
|
||||||
args: [],
|
args: [],
|
||||||
return: none
|
return: none,
|
||||||
|
failure: none
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
parse_fn_long_doc
|
parse_fn_long_doc
|
||||||
|
@ -206,7 +208,7 @@ fn parse_fn_long_doc(
|
||||||
desc: option<str>
|
desc: option<str>
|
||||||
) -> fn_attrs {
|
) -> fn_attrs {
|
||||||
let return = attr::meta_item_value_from_list(items, "return");
|
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") {
|
let args = alt attr::meta_item_list_from_list(items, "args") {
|
||||||
some(items) {
|
some(items) {
|
||||||
vec::filter_map(items) {|item|
|
vec::filter_map(items) {|item|
|
||||||
|
@ -225,7 +227,8 @@ fn parse_fn_long_doc(
|
||||||
brief: brief,
|
brief: brief,
|
||||||
desc: desc,
|
desc: desc,
|
||||||
args: args,
|
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"};
|
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 {
|
fn parse_const(attrs: [ast::attribute]) -> const_attrs {
|
||||||
parse_short_doc_or(
|
parse_short_doc_or(
|
||||||
attrs,
|
attrs,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue