rustdoc: Update for new impl syntax
This commit is contained in:
parent
99a571585c
commit
ab71c183b9
8 changed files with 39 additions and 37 deletions
|
|
@ -271,14 +271,14 @@ fn fold_impl(
|
|||
#[test]
|
||||
fn should_extract_impl_docs() {
|
||||
let doc = test::mk_doc(
|
||||
~"#[doc = \"whatever\"] impl i for int { fn a() { } }");
|
||||
~"#[doc = \"whatever\"] impl int { fn a() { } }");
|
||||
assert doc.cratemod().impls()[0].desc() == some(~"whatever");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn should_extract_impl_method_docs() {
|
||||
let doc = test::mk_doc(
|
||||
~"impl i for int {\
|
||||
~"impl int {\
|
||||
#[doc = \"desc\"]\
|
||||
fn f(a: bool) -> bool { }\
|
||||
}");
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ fn should_promote_trait_method_desc() {
|
|||
#[test]
|
||||
fn should_promote_impl_method_desc() {
|
||||
let doc = test::mk_doc(
|
||||
~"impl i for int { #[doc = \"desc\"] fn a() { } }");
|
||||
~"impl int { #[doc = \"desc\"] fn a() { } }");
|
||||
assert doc.cratemod().impls()[0].methods[0].brief == some(~"desc");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -248,21 +248,9 @@ fn impldoc_from_impl(
|
|||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn should_extract_impls_with_names() {
|
||||
let doc = test::mk_doc(~"impl i for int { fn a() { } }");
|
||||
assert doc.cratemod().impls()[0].name() == ~"i";
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn should_extract_impls_without_names() {
|
||||
let doc = test::mk_doc(~"impl of i for int { fn a() { } }");
|
||||
assert doc.cratemod().impls()[0].name() == ~"i";
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn should_extract_impl_methods() {
|
||||
let doc = test::mk_doc(~"impl i for int { fn f() { } }");
|
||||
let doc = test::mk_doc(~"impl int { fn f() { } }");
|
||||
assert doc.cratemod().impls()[0].methods[0].name == ~"f";
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -241,7 +241,21 @@ fn header_name(doc: doc::itemtag) -> ~str {
|
|||
}
|
||||
|
||||
fn header_text(doc: doc::itemtag) -> ~str {
|
||||
header_text_(header_kind(doc), header_name(doc))
|
||||
match doc {
|
||||
doc::impltag(impldoc) => {
|
||||
let header_kind = header_kind(doc);
|
||||
let desc = if impldoc.trait_types.is_empty() {
|
||||
fmt!{"for `%s`", impldoc.self_ty.get()}
|
||||
} else {
|
||||
fmt!{"of `%s` for `%s`", impldoc.trait_types[0],
|
||||
impldoc.self_ty.get()}
|
||||
};
|
||||
fmt!{"%s %s", header_kind, desc}
|
||||
}
|
||||
_ => {
|
||||
header_text_(header_kind(doc), header_name(doc))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn header_text_(kind: ~str, name: ~str) -> ~str {
|
||||
|
|
@ -697,34 +711,34 @@ fn write_impl(ctxt: ctxt, doc: doc::impldoc) {
|
|||
|
||||
#[test]
|
||||
fn should_write_impl_header() {
|
||||
let markdown = test::render(~"impl i for int { fn a() { } }");
|
||||
assert str::contains(markdown, ~"## Implementation `i for int`");
|
||||
let markdown = test::render(~"impl int { fn a() { } }");
|
||||
assert str::contains(markdown, ~"## Implementation for `int`");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn should_write_impl_header_with_trait() {
|
||||
let markdown = test::render(~"impl i of j for int { fn a() { } }");
|
||||
assert str::contains(markdown, ~"## Implementation `i of j for int`");
|
||||
let markdown = test::render(~"impl int: j { fn a() { } }");
|
||||
assert str::contains(markdown, ~"## Implementation of `j` for `int`");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn should_write_impl_desc() {
|
||||
let markdown = test::render(
|
||||
~"#[doc = \"desc\"] impl i for int { fn a() { } }");
|
||||
~"#[doc = \"desc\"] impl int { fn a() { } }");
|
||||
assert str::contains(markdown, ~"desc");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn should_write_impl_method_header() {
|
||||
let markdown = test::render(
|
||||
~"impl i for int { fn a() { } }");
|
||||
~"impl int { fn a() { } }");
|
||||
assert str::contains(markdown, ~"### Method `a`");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn should_write_impl_method_signature() {
|
||||
let markdown = test::render(
|
||||
~"impl i for int { fn a() { } }");
|
||||
~"impl int { fn a() { } }");
|
||||
assert str::contains(markdown, ~"\n fn a()");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -217,7 +217,7 @@ fn should_sectionalize_trait_methods() {
|
|||
#[test]
|
||||
fn should_sectionalize_impl_methods() {
|
||||
let doc = test::mk_doc(
|
||||
~"impl i for bool {
|
||||
~"impl bool {
|
||||
#[doc = \"\
|
||||
# Header\n\
|
||||
Body\"]\
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ fn test() {
|
|||
fn ifn() { } \
|
||||
enum ienum { ivar } \
|
||||
trait itrait { fn a(); } \
|
||||
impl iimpl for int { fn a() { } } \
|
||||
impl int { fn a() { } } \
|
||||
type itype = int;";
|
||||
do astsrv::from_str(source) |srv| {
|
||||
let doc = extract::from_srv(srv, ~"");
|
||||
|
|
@ -43,7 +43,7 @@ fn test() {
|
|||
assert doc.cratemod().items[1].name() == ~"itype";
|
||||
assert doc.cratemod().items[2].name() == ~"ienum";
|
||||
assert doc.cratemod().items[3].name() == ~"itrait";
|
||||
assert doc.cratemod().items[4].name() == ~"iimpl";
|
||||
assert doc.cratemod().items[4].name() == ~"__extensions__";
|
||||
assert doc.cratemod().items[5].name() == ~"ifn";
|
||||
assert doc.cratemod().items[6].name() == ~"imod";
|
||||
assert doc.cratemod().items[7].name() == ~"inmod";
|
||||
|
|
|
|||
|
|
@ -145,28 +145,28 @@ fn should_execute_op_on_trait_method_desc() {
|
|||
#[test]
|
||||
fn should_execute_op_on_impl_brief() {
|
||||
let doc = test::mk_doc(
|
||||
~"#[doc = \" a \"] impl i for int { fn a() { } }");
|
||||
~"#[doc = \" a \"] impl int { fn a() { } }");
|
||||
assert doc.cratemod().impls()[0].brief() == some(~"a");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn should_execute_op_on_impl_desc() {
|
||||
let doc = test::mk_doc(
|
||||
~"#[doc = \" a \"] impl i for int { fn a() { } }");
|
||||
~"#[doc = \" a \"] impl int { fn a() { } }");
|
||||
assert doc.cratemod().impls()[0].desc() == some(~"a");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn should_execute_op_on_impl_method_brief() {
|
||||
let doc = test::mk_doc(
|
||||
~"impl i for int { #[doc = \" a \"] fn a() { } }");
|
||||
~"impl int { #[doc = \" a \"] fn a() { } }");
|
||||
assert doc.cratemod().impls()[0].methods[0].brief == some(~"a");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn should_execute_op_on_impl_method_desc() {
|
||||
let doc = test::mk_doc(
|
||||
~"impl i for int { #[doc = \" a \"] fn a() { } }");
|
||||
~"impl int { #[doc = \" a \"] fn a() { } }");
|
||||
assert doc.cratemod().impls()[0].methods[0].desc == some(~"a");
|
||||
}
|
||||
|
||||
|
|
@ -230,7 +230,7 @@ fn should_execute_on_trait_method_section_bodies() {
|
|||
#[test]
|
||||
fn should_execute_on_impl_method_section_headers() {
|
||||
let doc = test::mk_doc(
|
||||
~"impl i for bool {
|
||||
~"impl bool {
|
||||
#[doc = \"\
|
||||
# Header \n\
|
||||
Body\"]\
|
||||
|
|
@ -242,7 +242,7 @@ fn should_execute_on_impl_method_section_headers() {
|
|||
#[test]
|
||||
fn should_execute_on_impl_method_section_bodies() {
|
||||
let doc = test::mk_doc(
|
||||
~"impl i for bool {
|
||||
~"impl bool {
|
||||
#[doc = \"\
|
||||
# Header\n\
|
||||
Body \"]\
|
||||
|
|
|
|||
|
|
@ -254,25 +254,25 @@ fn fold_impl(
|
|||
|
||||
#[test]
|
||||
fn should_add_impl_trait_types() {
|
||||
let doc = test::mk_doc(~"impl i of j for int { fn a<T>() { } }");
|
||||
let doc = test::mk_doc(~"impl int: j { fn a<T>() { } }");
|
||||
assert doc.cratemod().impls()[0].trait_types[0] == ~"j";
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn should_not_add_impl_trait_types_if_none() {
|
||||
let doc = test::mk_doc(~"impl i for int { fn a() { } }");
|
||||
let doc = test::mk_doc(~"impl int { fn a() { } }");
|
||||
assert vec::len(doc.cratemod().impls()[0].trait_types) == 0;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn should_add_impl_self_ty() {
|
||||
let doc = test::mk_doc(~"impl i for int { fn a() { } }");
|
||||
let doc = test::mk_doc(~"impl int { fn a() { } }");
|
||||
assert doc.cratemod().impls()[0].self_ty == some(~"int");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn should_add_impl_method_sigs() {
|
||||
let doc = test::mk_doc(~"impl i for int { fn a<T>() -> int { fail } }");
|
||||
let doc = test::mk_doc(~"impl int { fn a<T>() -> int { fail } }");
|
||||
assert doc.cratemod().impls()[0].methods[0].sig
|
||||
== some(~"fn a<T>() -> int");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue