rustdoc: Introduce type doc::argdoc
This commit is contained in:
parent
38852bf0a4
commit
29df58d73b
4 changed files with 17 additions and 12 deletions
|
@ -99,9 +99,9 @@ fn fold_fn(
|
|||
}
|
||||
|
||||
fn merge_arg_attrs(
|
||||
doc: [(str, str)],
|
||||
doc: [doc::argdoc],
|
||||
_attrs: [attr_parser::arg_attrs]
|
||||
) -> [(str, str)] {
|
||||
) -> [doc::argdoc] {
|
||||
// FIXME
|
||||
doc
|
||||
}
|
||||
|
|
|
@ -18,7 +18,11 @@ type fndoc = ~{
|
|||
brief: option<str>,
|
||||
desc: option<str>,
|
||||
return: option<retdoc>,
|
||||
args: [(str, str)]
|
||||
args: [argdoc]
|
||||
};
|
||||
|
||||
type argdoc = ~{
|
||||
name: str
|
||||
};
|
||||
|
||||
type retdoc = {
|
||||
|
|
|
@ -85,16 +85,18 @@ fn should_extract_fn_args() {
|
|||
let ast = parse::from_str(source);
|
||||
let doc = extract(ast, "");
|
||||
let fn_ = doc.topmod.fns[0];
|
||||
assert tuple::first(fn_.args[0]) == "b";
|
||||
assert tuple::first(fn_.args[1]) == "c";
|
||||
assert fn_.args[0].name == "b";
|
||||
assert fn_.args[1].name == "c";
|
||||
}
|
||||
|
||||
fn argdocs_from_args(args: [ast::arg]) -> [(str, str)] {
|
||||
fn argdocs_from_args(args: [ast::arg]) -> [doc::argdoc] {
|
||||
vec::map(args, argdoc_from_arg)
|
||||
}
|
||||
|
||||
fn argdoc_from_arg(arg: ast::arg) -> (str, str) {
|
||||
(arg.ident, "")
|
||||
fn argdoc_from_arg(arg: ast::arg) -> doc::argdoc {
|
||||
~{
|
||||
name: arg.ident
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
|
@ -125,11 +125,10 @@ fn write_desc(
|
|||
|
||||
fn write_args(
|
||||
ctxt: ctxt,
|
||||
args: [(str, str)]
|
||||
args: [doc::argdoc]
|
||||
) {
|
||||
for (arg, desc) in args {
|
||||
ctxt.w.write_str("### Argument `" + arg + "`: ");
|
||||
ctxt.w.write_str(desc)
|
||||
for arg in args {
|
||||
ctxt.w.write_str("### Argument `" + arg.name + "`: ");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue