mirror of https://github.com/rust-lang/rust.git
rustdoc: Make doc::retdoc non-optional
This commit is contained in:
parent
6222e98dda
commit
fdbe206a76
|
@ -158,20 +158,12 @@ fn fold_fn(
|
|||
}
|
||||
|
||||
fn merge_ret_attrs(
|
||||
doc: option<doc::retdoc>,
|
||||
doc: doc::retdoc,
|
||||
attrs: option<str>
|
||||
) -> option<doc::retdoc> {
|
||||
alt doc {
|
||||
some(doc) {
|
||||
some({
|
||||
desc: attrs
|
||||
with doc
|
||||
})
|
||||
}
|
||||
none {
|
||||
// FIXME: Warning about documenting nil?
|
||||
none
|
||||
}
|
||||
) -> doc::retdoc {
|
||||
{
|
||||
desc: attrs
|
||||
with doc
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -204,7 +196,7 @@ fn fold_fn_should_extract_return_attributes() {
|
|||
let doc = tystr_pass::mk_pass()(srv, doc);
|
||||
let fold = fold::default_seq_fold(srv);
|
||||
let doc = fold_fn(fold, doc.topmod.fns[0]);
|
||||
assert option::get(doc.return).desc == some("what");
|
||||
assert doc.return.desc == some("what");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -22,7 +22,7 @@ type fndoc = ~{
|
|||
brief: option<str>,
|
||||
desc: option<str>,
|
||||
args: [argdoc],
|
||||
return: option<retdoc>,
|
||||
return: retdoc,
|
||||
sig: option<str>
|
||||
};
|
||||
|
||||
|
|
|
@ -80,7 +80,10 @@ fn fndoc_from_fn(
|
|||
brief: none,
|
||||
desc: none,
|
||||
args: argdocs_from_args(decl.inputs),
|
||||
return: none,
|
||||
return: {
|
||||
desc: none,
|
||||
ty: none
|
||||
},
|
||||
sig: none
|
||||
}
|
||||
}
|
||||
|
|
|
@ -222,23 +222,18 @@ fn should_write_argument_description() {
|
|||
|
||||
fn write_return(
|
||||
ctxt: ctxt,
|
||||
return: option<doc::retdoc>
|
||||
doc: doc::retdoc
|
||||
) {
|
||||
alt return {
|
||||
some(doc) {
|
||||
alt doc.ty {
|
||||
some(ty) {
|
||||
ctxt.w.write_line(#fmt("Returns `%s`", ty));
|
||||
alt doc.ty {
|
||||
some(ty) {
|
||||
ctxt.w.write_line(#fmt("Returns `%s`", ty));
|
||||
ctxt.w.write_line("");
|
||||
alt doc.desc {
|
||||
some(d) {
|
||||
ctxt.w.write_line(d);
|
||||
ctxt.w.write_line("");
|
||||
alt doc.desc {
|
||||
some(d) {
|
||||
ctxt.w.write_line(d);
|
||||
ctxt.w.write_line("");
|
||||
}
|
||||
none { }
|
||||
}
|
||||
}
|
||||
none { fail "unimplemented"; }
|
||||
none { }
|
||||
}
|
||||
}
|
||||
none { }
|
||||
|
|
|
@ -32,7 +32,7 @@ fn fold_fn(
|
|||
fold.ctxt.have_docs =
|
||||
doc.brief != none
|
||||
|| doc.desc != none
|
||||
|| doc.return != none;
|
||||
|| doc.return.desc != none;
|
||||
ret doc;
|
||||
}
|
||||
|
||||
|
|
|
@ -62,23 +62,16 @@ fn should_add_fn_sig() {
|
|||
fn merge_ret_ty(
|
||||
srv: astsrv::srv,
|
||||
fn_id: doc::ast_id,
|
||||
doc: option<doc::retdoc>
|
||||
) -> option<doc::retdoc> {
|
||||
alt doc {
|
||||
some(doc) {
|
||||
fail "unimplemented";
|
||||
}
|
||||
none {
|
||||
alt get_ret_ty(srv, fn_id) {
|
||||
some(ty) {
|
||||
some({
|
||||
desc: none,
|
||||
ty: some(ty)
|
||||
})
|
||||
}
|
||||
none { none }
|
||||
doc: doc::retdoc
|
||||
) -> doc::retdoc {
|
||||
alt get_ret_ty(srv, fn_id) {
|
||||
some(ty) {
|
||||
{
|
||||
ty: some(ty)
|
||||
with doc
|
||||
}
|
||||
}
|
||||
none { doc }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -105,7 +98,7 @@ fn should_add_fn_ret_types() {
|
|||
let srv = astsrv::mk_srv_from_str(source);
|
||||
let doc = extract::from_srv(srv, "");
|
||||
let doc = run(srv, doc);
|
||||
assert option::get(doc.topmod.fns[0].return).ty == some("int");
|
||||
assert doc.topmod.fns[0].return.ty == some("int");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -114,7 +107,7 @@ fn should_not_add_nil_ret_type() {
|
|||
let srv = astsrv::mk_srv_from_str(source);
|
||||
let doc = extract::from_srv(srv, "");
|
||||
let doc = run(srv, doc);
|
||||
assert doc.topmod.fns[0].return == none;
|
||||
assert doc.topmod.fns[0].return.ty == none;
|
||||
}
|
||||
|
||||
fn merge_arg_tys(
|
||||
|
|
Loading…
Reference in New Issue