rustdoc: Convert fn return type to retdoc record

This commit is contained in:
Brian Anderson 2012-01-16 14:02:46 -08:00
parent 63dcc64275
commit e77b8db707
3 changed files with 14 additions and 6 deletions

View File

@ -112,7 +112,10 @@ fn parse_fn_(
name: name,
brief: _brief,
desc: desc,
return: return,
return: some({
desc: return,
ty: none,
}),
args: argdocs }
}
@ -176,7 +179,7 @@ fn parse_fn_should_parse_the_return_value_description() {
let source = "#[doc(return = \"return value\")]";
let attrs = parse_attributes(source);
let doc = parse_fn("f", 0, attrs);
assert doc.return == some("return value");
assert option::get(doc.return).desc == some("return value");
}
#[test]

View File

@ -15,10 +15,15 @@
name: str,
brief: str,
desc: option::t<str>,
return: option::t<str>,
return: option<retdoc>,
args: [(str, str)]
};
type retdoc = {
desc: option<str>,
ty: option<str>
};
// Just to break the structural recursive types
tag modlist = [moddoc];
tag fnlist = [fndoc];

View File

@ -100,12 +100,12 @@ fn write_fndoc(ctxt: ctxt, ident: str, doc: doc::fndoc, decl: ast::fn_decl) {
}
for (arg, desc) in doc.args {
ctxt.w.write_str("### Argument `" + arg + "`: ");
ctxt.w.write_str(desc);
ctxt.w.write_str(desc)
}
ctxt.w.write_line("### Returns `" + pprust::ty_to_str(decl.output) + "`");
alt doc.return {
some(_r) { ctxt.w.write_line(_r); }
none. { }
some({desc: some(d), _}) { ctxt.w.write_line(d); }
_ { }
}
}