rustdoc: Add fn arg descriptions to the doc tree
This commit is contained in:
parent
515fdb2863
commit
266cc7b0c3
@ -154,11 +154,23 @@ fn fold_fn(
|
||||
}
|
||||
|
||||
fn merge_arg_attrs(
|
||||
doc: [doc::argdoc],
|
||||
_attrs: [attr_parser::arg_attrs]
|
||||
docs: [doc::argdoc],
|
||||
attrs: [attr_parser::arg_attrs]
|
||||
) -> [doc::argdoc] {
|
||||
// FIXME
|
||||
doc
|
||||
vec::map(docs) {|doc|
|
||||
alt vec::find(attrs) {|attr|
|
||||
attr.name == doc.name
|
||||
} {
|
||||
some(attr) {
|
||||
~{
|
||||
desc: some(attr.desc)
|
||||
with *doc
|
||||
}
|
||||
}
|
||||
none. { doc }
|
||||
}
|
||||
}
|
||||
// FIXME: Warning when documenting a non-existant arg
|
||||
}
|
||||
|
||||
fn merge_ret_attrs(
|
||||
@ -179,3 +191,13 @@ fn fold_fn_should_extract_fn_attributes() {
|
||||
let doc = fold_fn(fold, doc.topmod.fns[0]);
|
||||
assert doc.desc == some("test");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn fold_fn_should_extract_arg_attributes() {
|
||||
let source = "#[doc(args(a = \"b\"))] fn c(a: bool) { }";
|
||||
let srv = astsrv::mk_srv_from_str(source);
|
||||
let doc = extract::from_srv(srv, "");
|
||||
let fold = fold::default_seq_fold(srv);
|
||||
let doc = fold_fn(fold, doc.topmod.fns[0]);
|
||||
assert doc.args[0].desc == some("b");
|
||||
}
|
@ -26,6 +26,7 @@ type fndoc = ~{
|
||||
|
||||
type argdoc = ~{
|
||||
name: str,
|
||||
desc: option<str>,
|
||||
ty: option<str>
|
||||
};
|
||||
|
||||
|
@ -100,6 +100,7 @@ fn argdocs_from_args(args: [ast::arg]) -> [doc::argdoc] {
|
||||
fn argdoc_from_arg(arg: ast::arg) -> doc::argdoc {
|
||||
~{
|
||||
name: arg.ident,
|
||||
desc: none,
|
||||
ty: none
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user