rustdoc: Don't bother reporting the type of arguments
This is already displayed in the function signature. Simpler this way.
This commit is contained in:
parent
fcde161f4f
commit
5c28b2c1d1
4 changed files with 10 additions and 125 deletions
|
@ -66,8 +66,7 @@ type fndoc = {
|
||||||
|
|
||||||
type argdoc = {
|
type argdoc = {
|
||||||
name: str,
|
name: str,
|
||||||
desc: option<str>,
|
desc: option<str>
|
||||||
ty: option<str>
|
|
||||||
};
|
};
|
||||||
|
|
||||||
type retdoc = {
|
type retdoc = {
|
||||||
|
|
|
@ -161,8 +161,7 @@ fn argdocs_from_args(args: [ast::arg]) -> [doc::argdoc] {
|
||||||
fn argdoc_from_arg(arg: ast::arg) -> doc::argdoc {
|
fn argdoc_from_arg(arg: ast::arg) -> doc::argdoc {
|
||||||
{
|
{
|
||||||
name: arg.ident,
|
name: arg.ident,
|
||||||
desc: none,
|
desc: none
|
||||||
ty: none
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -486,11 +486,9 @@ fn write_args(
|
||||||
}
|
}
|
||||||
|
|
||||||
fn write_arg(ctxt: ctxt, arg: doc::argdoc) {
|
fn write_arg(ctxt: ctxt, arg: doc::argdoc) {
|
||||||
assert option::is_some(arg.ty);
|
|
||||||
ctxt.w.write_str(#fmt(
|
ctxt.w.write_str(#fmt(
|
||||||
"* `%s`: `%s`",
|
"* `%s`",
|
||||||
arg.name,
|
arg.name
|
||||||
option::get(arg.ty)
|
|
||||||
));
|
));
|
||||||
alt arg.desc {
|
alt arg.desc {
|
||||||
some(desc) {
|
some(desc) {
|
||||||
|
@ -509,8 +507,8 @@ fn should_write_argument_list() {
|
||||||
markdown,
|
markdown,
|
||||||
"Arguments:\n\
|
"Arguments:\n\
|
||||||
\n\
|
\n\
|
||||||
* `b`: `int`\n\
|
* `b`\n\
|
||||||
* `c`: `int`\n\
|
* `c`\n\
|
||||||
\n"
|
\n"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -526,7 +524,7 @@ fn should_not_write_arguments_if_none() {
|
||||||
fn should_write_argument_description() {
|
fn should_write_argument_description() {
|
||||||
let source = "#[doc(args(a = \"milk\"))] fn f(a: bool) { }";
|
let source = "#[doc(args(a = \"milk\"))] fn f(a: bool) { }";
|
||||||
let markdown = test::render(source);
|
let markdown = test::render(source);
|
||||||
assert str::contains(markdown, "`a`: `bool` - milk");
|
assert str::contains(markdown, "`a` - milk");
|
||||||
}
|
}
|
||||||
|
|
||||||
fn write_return(
|
fn write_return(
|
||||||
|
@ -740,7 +738,7 @@ fn should_write_resource_signature() {
|
||||||
fn should_write_resource_args() {
|
fn should_write_resource_args() {
|
||||||
let markdown = test::render("#[doc(args(a = \"b\"))]\
|
let markdown = test::render("#[doc(args(a = \"b\"))]\
|
||||||
resource r(a: bool) { }");
|
resource r(a: bool) { }");
|
||||||
assert str::contains(markdown, "Arguments:\n\n* `a`: `bool` - b");
|
assert str::contains(markdown, "Arguments:\n\n* `a` - b");
|
||||||
}
|
}
|
||||||
|
|
||||||
fn write_iface(ctxt: ctxt, doc: doc::ifacedoc) {
|
fn write_iface(ctxt: ctxt, doc: doc::ifacedoc) {
|
||||||
|
@ -812,7 +810,7 @@ fn should_write_iface_method_argument_header() {
|
||||||
fn should_write_iface_method_arguments() {
|
fn should_write_iface_method_arguments() {
|
||||||
let markdown = test::render(
|
let markdown = test::render(
|
||||||
"iface a { fn a(b: int); }");
|
"iface a { fn a(b: int); }");
|
||||||
assert str::contains(markdown, "* `b`: `int`\n");
|
assert str::contains(markdown, "* `b`\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -894,7 +892,7 @@ fn should_write_impl_method_argument_header() {
|
||||||
fn should_write_impl_method_arguments() {
|
fn should_write_impl_method_arguments() {
|
||||||
let markdown = test::render(
|
let markdown = test::render(
|
||||||
"impl a for int { fn a(b: int) { } }");
|
"impl a for int { fn a(b: int) { } }");
|
||||||
assert str::contains(markdown, "* `b`: `int`\n");
|
assert str::contains(markdown, "* `b`\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -40,7 +40,6 @@ fn fold_fn(
|
||||||
let srv = fold.ctxt;
|
let srv = fold.ctxt;
|
||||||
|
|
||||||
{
|
{
|
||||||
args: merge_arg_tys(srv, doc.id(), doc.args),
|
|
||||||
return: merge_ret_ty(srv, doc.id(), doc.return),
|
return: merge_ret_ty(srv, doc.id(), doc.return),
|
||||||
sig: get_fn_sig(srv, doc.id())
|
sig: get_fn_sig(srv, doc.id())
|
||||||
with doc
|
with doc
|
||||||
|
@ -134,22 +133,6 @@ fn should_add_native_fn_ret_types() {
|
||||||
assert doc.cratemod().nmods()[0].fns[0].return.ty == some("int");
|
assert doc.cratemod().nmods()[0].fns[0].return.ty == some("int");
|
||||||
}
|
}
|
||||||
|
|
||||||
fn merge_arg_tys(
|
|
||||||
srv: astsrv::srv,
|
|
||||||
fn_id: doc::ast_id,
|
|
||||||
args: [doc::argdoc]
|
|
||||||
) -> [doc::argdoc] {
|
|
||||||
let tys = get_arg_tys(srv, fn_id);
|
|
||||||
vec::map2(args, tys) {|arg, ty|
|
|
||||||
// Sanity check that we're talking about the same args
|
|
||||||
assert arg.name == tuple::first(ty);
|
|
||||||
{
|
|
||||||
ty: some(tuple::second(ty))
|
|
||||||
with arg
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_arg_tys(srv: astsrv::srv, fn_id: doc::ast_id) -> [(str, str)] {
|
fn get_arg_tys(srv: astsrv::srv, fn_id: doc::ast_id) -> [(str, str)] {
|
||||||
astsrv::exec(srv) {|ctxt|
|
astsrv::exec(srv) {|ctxt|
|
||||||
alt check ctxt.ast_map.get(fn_id) {
|
alt check ctxt.ast_map.get(fn_id) {
|
||||||
|
@ -174,20 +157,6 @@ fn decl_arg_tys(decl: ast::fn_decl) -> [(str, str)] {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn should_add_arg_types() {
|
|
||||||
let doc = test::mk_doc("fn a(b: int, c: bool) { }");
|
|
||||||
let fn_ = doc.cratemod().fns()[0];
|
|
||||||
assert fn_.args[0].ty == some("int");
|
|
||||||
assert fn_.args[1].ty == some("bool");
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn should_add_native_fn_arg_types() {
|
|
||||||
let doc = test::mk_doc("native mod a { fn a(b: int); }");
|
|
||||||
assert doc.cratemod().nmods()[0].fns[0].args[0].ty == some("int");
|
|
||||||
}
|
|
||||||
|
|
||||||
fn fold_const(
|
fn fold_const(
|
||||||
fold: fold::fold<astsrv::srv>,
|
fold: fold::fold<astsrv::srv>,
|
||||||
doc: doc::constdoc
|
doc: doc::constdoc
|
||||||
|
@ -260,7 +229,6 @@ fn fold_res(
|
||||||
let srv = fold.ctxt;
|
let srv = fold.ctxt;
|
||||||
|
|
||||||
{
|
{
|
||||||
args: merge_arg_tys(srv, doc.id(), doc.args),
|
|
||||||
sig: some(astsrv::exec(srv) {|ctxt|
|
sig: some(astsrv::exec(srv) {|ctxt|
|
||||||
alt check ctxt.ast_map.get(doc.id()) {
|
alt check ctxt.ast_map.get(doc.id()) {
|
||||||
ast_map::node_item(@{
|
ast_map::node_item(@{
|
||||||
|
@ -280,12 +248,6 @@ fn should_add_resource_sigs() {
|
||||||
assert doc.cratemod().resources()[0].sig == some("resource r(b: bool)");
|
assert doc.cratemod().resources()[0].sig == some("resource r(b: bool)");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn should_add_resource_arg_tys() {
|
|
||||||
let doc = test::mk_doc("resource r(a: bool) { }");
|
|
||||||
assert doc.cratemod().resources()[0].args[0].ty == some("bool");
|
|
||||||
}
|
|
||||||
|
|
||||||
fn fold_iface(
|
fn fold_iface(
|
||||||
fold: fold::fold<astsrv::srv>,
|
fold: fold::fold<astsrv::srv>,
|
||||||
doc: doc::ifacedoc
|
doc: doc::ifacedoc
|
||||||
|
@ -303,11 +265,6 @@ fn merge_methods(
|
||||||
) -> [doc::methoddoc] {
|
) -> [doc::methoddoc] {
|
||||||
par::anymap(docs) {|doc|
|
par::anymap(docs) {|doc|
|
||||||
{
|
{
|
||||||
args: merge_method_arg_tys(
|
|
||||||
srv,
|
|
||||||
item_id,
|
|
||||||
doc.args,
|
|
||||||
doc.name),
|
|
||||||
return: merge_method_ret_ty(
|
return: merge_method_ret_ty(
|
||||||
srv,
|
srv,
|
||||||
item_id,
|
item_id,
|
||||||
|
@ -403,58 +360,6 @@ fn get_method_sig(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn merge_method_arg_tys(
|
|
||||||
srv: astsrv::srv,
|
|
||||||
item_id: doc::ast_id,
|
|
||||||
args: [doc::argdoc],
|
|
||||||
method_name: str
|
|
||||||
) -> [doc::argdoc] {
|
|
||||||
let tys = get_method_arg_tys(srv, item_id, method_name);
|
|
||||||
vec::map2(args, tys) {|arg, ty|
|
|
||||||
assert arg.name == tuple::first(ty);
|
|
||||||
{
|
|
||||||
ty: some(tuple::second(ty))
|
|
||||||
with arg
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_method_arg_tys(
|
|
||||||
srv: astsrv::srv,
|
|
||||||
item_id: doc::ast_id,
|
|
||||||
method_name: str
|
|
||||||
) -> [(str, str)] {
|
|
||||||
astsrv::exec(srv) {|ctxt|
|
|
||||||
alt ctxt.ast_map.get(item_id) {
|
|
||||||
ast_map::node_item(@{
|
|
||||||
node: ast::item_iface(_, methods), _
|
|
||||||
}, _) {
|
|
||||||
alt vec::find(methods) {|method|
|
|
||||||
method.ident == method_name
|
|
||||||
} {
|
|
||||||
some(method) {
|
|
||||||
decl_arg_tys(method.decl)
|
|
||||||
}
|
|
||||||
_ { fail "get_method_arg_tys: expected method"; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ast_map::node_item(@{
|
|
||||||
node: ast::item_impl(_, _, _, methods), _
|
|
||||||
}, _) {
|
|
||||||
alt vec::find(methods) {|method|
|
|
||||||
method.ident == method_name
|
|
||||||
} {
|
|
||||||
some(method) {
|
|
||||||
decl_arg_tys(method.decl)
|
|
||||||
}
|
|
||||||
_ { fail "get_method_arg_tys: expected method"; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_ { fail }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn should_add_iface_method_sigs() {
|
fn should_add_iface_method_sigs() {
|
||||||
let doc = test::mk_doc("iface i { fn a() -> int; }");
|
let doc = test::mk_doc("iface i { fn a() -> int; }");
|
||||||
|
@ -473,14 +378,6 @@ fn should_not_add_iface_method_nil_ret_type() {
|
||||||
assert doc.cratemod().ifaces()[0].methods[0].return.ty == none;
|
assert doc.cratemod().ifaces()[0].methods[0].return.ty == none;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn should_add_iface_method_arg_types() {
|
|
||||||
let doc = test::mk_doc("iface i { fn a(b: int, c: bool); }");
|
|
||||||
let fn_ = doc.cratemod().ifaces()[0].methods[0];
|
|
||||||
assert fn_.args[0].ty == some("int");
|
|
||||||
assert fn_.args[1].ty == some("bool");
|
|
||||||
}
|
|
||||||
|
|
||||||
fn fold_impl(
|
fn fold_impl(
|
||||||
fold: fold::fold<astsrv::srv>,
|
fold: fold::fold<astsrv::srv>,
|
||||||
doc: doc::impldoc
|
doc: doc::impldoc
|
||||||
|
@ -546,14 +443,6 @@ fn should_not_add_impl_method_nil_ret_type() {
|
||||||
assert doc.cratemod().impls()[0].methods[0].return.ty == none;
|
assert doc.cratemod().impls()[0].methods[0].return.ty == none;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn should_add_impl_method_arg_types() {
|
|
||||||
let doc = test::mk_doc("impl i for int { fn a(b: int, c: bool) { } }");
|
|
||||||
let fn_ = doc.cratemod().impls()[0].methods[0];
|
|
||||||
assert fn_.args[0].ty == some("int");
|
|
||||||
assert fn_.args[1].ty == some("bool");
|
|
||||||
}
|
|
||||||
|
|
||||||
fn fold_type(
|
fn fold_type(
|
||||||
fold: fold::fold<astsrv::srv>,
|
fold: fold::fold<astsrv::srv>,
|
||||||
doc: doc::tydoc
|
doc: doc::tydoc
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue