cleanup warnings from librustdoc

This commit is contained in:
Erick Tryzelaar 2013-05-23 09:39:38 -07:00
parent 50f6198ee2
commit d7e43aa779
6 changed files with 81 additions and 87 deletions

View File

@ -278,26 +278,26 @@ fn should_error_with_no_pandoc() {
#[test]
fn should_error_with_no_crates() {
let config = parse_config(~[~"rustdoc"]);
let config = parse_config([~"rustdoc"]);
assert!(config.get_err() == ~"no crates specified");
}
#[test]
fn should_error_with_multiple_crates() {
let config =
parse_config(~[~"rustdoc", ~"crate1.rc", ~"crate2.rc"]);
parse_config([~"rustdoc", ~"crate1.rc", ~"crate2.rc"]);
assert!(config.get_err() == ~"multiple crates specified");
}
#[test]
fn should_set_output_dir_to_cwd_if_not_provided() {
let config = parse_config(~[~"rustdoc", ~"crate.rc"]);
let config = parse_config([~"rustdoc", ~"crate.rc"]);
assert!(config.get().output_dir == Path("."));
}
#[test]
fn should_set_output_dir_if_provided() {
let config = parse_config(~[
let config = parse_config([
~"rustdoc", ~"crate.rc", ~"--output-dir", ~"snuggles"
]);
assert!(config.get().output_dir == Path("snuggles"));
@ -305,13 +305,13 @@ fn should_set_output_dir_if_provided() {
#[test]
fn should_set_output_format_to_pandoc_html_if_not_provided() {
let config = parse_config(~[~"rustdoc", ~"crate.rc"]);
let config = parse_config([~"rustdoc", ~"crate.rc"]);
assert!(config.get().output_format == PandocHtml);
}
#[test]
fn should_set_output_format_to_markdown_if_requested() {
let config = parse_config(~[
let config = parse_config([
~"rustdoc", ~"crate.rc", ~"--output-format", ~"markdown"
]);
assert!(config.get().output_format == Markdown);
@ -319,7 +319,7 @@ fn should_set_output_format_to_markdown_if_requested() {
#[test]
fn should_set_output_format_to_pandoc_html_if_requested() {
let config = parse_config(~[
let config = parse_config([
~"rustdoc", ~"crate.rc", ~"--output-format", ~"html"
]);
assert!(config.get().output_format == PandocHtml);
@ -327,7 +327,7 @@ fn should_set_output_format_to_pandoc_html_if_requested() {
#[test]
fn should_error_on_bogus_format() {
let config = parse_config(~[
let config = parse_config([
~"rustdoc", ~"crate.rc", ~"--output-format", ~"bogus"
]);
assert!(config.get_err() == ~"unknown output format 'bogus'");
@ -335,13 +335,13 @@ fn should_error_on_bogus_format() {
#[test]
fn should_set_output_style_to_doc_per_mod_by_default() {
let config = parse_config(~[~"rustdoc", ~"crate.rc"]);
let config = parse_config([~"rustdoc", ~"crate.rc"]);
assert!(config.get().output_style == DocPerMod);
}
#[test]
fn should_set_output_style_to_one_doc_if_requested() {
let config = parse_config(~[
let config = parse_config([
~"rustdoc", ~"crate.rc", ~"--output-style", ~"doc-per-crate"
]);
assert!(config.get().output_style == DocPerCrate);
@ -349,7 +349,7 @@ fn should_set_output_style_to_one_doc_if_requested() {
#[test]
fn should_set_output_style_to_doc_per_mod_if_requested() {
let config = parse_config(~[
let config = parse_config([
~"rustdoc", ~"crate.rc", ~"--output-style", ~"doc-per-mod"
]);
assert!(config.get().output_style == DocPerMod);
@ -357,7 +357,7 @@ fn should_set_output_style_to_doc_per_mod_if_requested() {
#[test]
fn should_error_on_bogus_output_style() {
let config = parse_config(~[
let config = parse_config([
~"rustdoc", ~"crate.rc", ~"--output-style", ~"bogus"
]);
assert!(config.get_err() == ~"unknown output style 'bogus'");
@ -365,7 +365,7 @@ fn should_error_on_bogus_output_style() {
#[test]
fn should_set_pandoc_command_if_requested() {
let config = parse_config(~[
let config = parse_config([
~"rustdoc", ~"crate.rc", ~"--pandoc-cmd", ~"panda-bear-doc"
]);
assert!(config.get().pandoc_cmd == Some(~"panda-bear-doc"));
@ -373,7 +373,7 @@ fn should_set_pandoc_command_if_requested() {
#[test]
fn should_set_pandoc_command_when_using_pandoc() {
let config = parse_config(~[~"rustdoc", ~"crate.rc"]);
let config = parse_config([~"rustdoc", ~"crate.rc"]);
assert!(config.get().pandoc_cmd == Some(~"pandoc"));
}
}

View File

@ -220,13 +220,13 @@ fn should_promote_impl_method_desc() {
#[test]
fn test_paragraphs_1() {
let paras = paragraphs(~"1\n\n2");
let paras = paragraphs("1\n\n2");
assert_eq!(paras, ~[~"1", ~"2"]);
}
#[test]
fn test_paragraphs_2() {
let paras = paragraphs(~"\n\n1\n1\n\n2\n\n");
let paras = paragraphs("\n\n1\n1\n\n2\n\n");
assert_eq!(paras, ~[~"1\n1", ~"2"]);
}

View File

@ -16,9 +16,7 @@
use doc::ItemUtils;
use doc;
use core::local_data::local_data_get;
use syntax::ast;
use syntax;
use syntax::parse::token::{ident_interner};
use syntax::parse::token;

View File

@ -193,21 +193,21 @@ fn mk_doc(output_style: config::OutputStyle, source: ~str)
#[test]
fn should_remove_punctuation_from_headers() {
assert!(pandoc_header_id(~"impl foo of bar<A>") ==
assert!(pandoc_header_id("impl foo of bar<A>") ==
~"impl-foo-of-bara");
assert!(pandoc_header_id(~"impl of num::num for int")
assert!(pandoc_header_id("impl of num::num for int")
== ~"impl-of-numnum-for-int");
assert!(pandoc_header_id(~"impl of num::num for int/&")
assert!(pandoc_header_id("impl of num::num for int/&")
== ~"impl-of-numnum-for-int");
assert!(pandoc_header_id(~"impl of num::num for ^int")
assert!(pandoc_header_id("impl of num::num for ^int")
== ~"impl-of-numnum-for-int");
assert!(pandoc_header_id(~"impl for & condvar")
assert!(pandoc_header_id("impl for & condvar")
== ~"impl-for-condvar");
assert!(pandoc_header_id(~"impl of Select<T, U> for (Left, Right)")
assert!(pandoc_header_id("impl of Select<T, U> for (Left, Right)")
== ~"impl-of-selectt-u-for-left-right");
assert!(pandoc_header_id(~"impl of Condition<'self, T, U>")
assert!(pandoc_header_id("impl of Condition<'self, T, U>")
== ~"impl-of-conditionself-t-u");
assert!(pandoc_header_id(~"impl of Condition<T: Copy + Clone>")
assert!(pandoc_header_id("impl of Condition<T: Copy + Clone>")
== ~"impl-of-conditiont-copy-clone");
}

View File

@ -587,13 +587,13 @@ fn write_markdown_str_srv(
#[test]
fn write_markdown_should_write_mod_headers() {
let markdown = render(~"mod moo { }");
assert!(str::contains(markdown, ~"# Module `moo`"));
assert!(str::contains(markdown, "# Module `moo`"));
}
#[test]
fn should_leave_blank_line_after_header() {
let markdown = render(~"mod morp { }");
assert!(str::contains(markdown, ~"Module `morp`\n\n"));
assert!(str::contains(markdown, "Module `morp`\n\n"));
}
#[test]
@ -613,10 +613,10 @@ mod c {
fn d() { }"
);
let idx_a = str::find_str(markdown, ~"# Module `a`").get();
let idx_b = str::find_str(markdown, ~"## Function `b`").get();
let idx_c = str::find_str(markdown, ~"# Module `c`").get();
let idx_d = str::find_str(markdown, ~"## Function `d`").get();
let idx_a = str::find_str(markdown, "# Module `a`").get();
let idx_b = str::find_str(markdown, "## Function `b`").get();
let idx_c = str::find_str(markdown, "# Module `c`").get();
let idx_d = str::find_str(markdown, "## Function `d`").get();
assert!(idx_b < idx_d);
assert!(idx_d < idx_a);
@ -649,7 +649,7 @@ fn should_write_title_for_each_page() {
let (page, markdown) = po.recv();
match page {
doc::CratePage(_) => {
assert!(str::contains(markdown, ~"% Crate core"));
assert!(str::contains(markdown, "% Crate core"));
}
doc::ItemPage(_) => {
assert!(str::contains(markdown, ~"% Module a"));
@ -661,7 +661,7 @@ fn should_write_title_for_each_page() {
#[test]
fn should_write_full_path_to_mod() {
let markdown = render(~"mod a { mod b { mod c { } } }");
assert!(str::contains(markdown, ~"# Module `a::b::c`"));
assert!(str::contains(markdown, "# Module `a::b::c`"));
}
#[test]
@ -672,13 +672,13 @@ fn should_write_sections() {
Body\"]\
mod a {
}");
assert!(str::contains(markdown, ~"#### Header\n\nBody\n\n"));
assert!(str::contains(markdown, "#### Header\n\nBody\n\n"));
}
#[test]
fn should_write_crate_description() {
let markdown = render(~"#[doc = \"this is the crate\"];");
assert!(str::contains(markdown, ~"this is the crate"));
assert!(str::contains(markdown, "this is the crate"));
}
@ -687,21 +687,21 @@ fn should_write_index() {
let markdown = render(~"mod a { } mod b { }");
assert!(str::contains(
markdown,
~"\n\n* [Module `a`](#module-a)\n\
* [Module `b`](#module-b)\n\n"
"\n\n* [Module `a`](#module-a)\n\
* [Module `b`](#module-b)\n\n"
));
}
#[test]
fn should_write_index_brief() {
let markdown = render(~"#[doc = \"test\"] mod a { }");
assert!(str::contains(markdown, ~"(#module-a) - test\n"));
assert!(str::contains(markdown, "(#module-a) - test\n"));
}
#[test]
fn should_not_write_index_if_no_entries() {
let markdown = render(~"");
assert!(!str::contains(markdown, ~"\n\n\n"));
assert!(!str::contains(markdown, "\n\n\n"));
}
#[test]
@ -709,7 +709,7 @@ fn should_write_index_for_foreign_mods() {
let markdown = render(~"extern { fn a(); }");
assert!(str::contains(
markdown,
~"\n\n* [Function `a`](#function-a)\n\n"
"\n\n* [Function `a`](#function-a)\n\n"
));
}
@ -717,32 +717,32 @@ fn should_write_index_for_foreign_mods() {
fn should_write_foreign_fns() {
let markdown = render(
~"extern { #[doc = \"test\"] fn a(); }");
assert!(str::contains(markdown, ~"test"));
assert!(str::contains(markdown, "test"));
}
#[test]
fn should_write_foreign_fn_headers() {
let markdown = render(
~"extern { #[doc = \"test\"] fn a(); }");
assert!(str::contains(markdown, ~"## Function `a`"));
assert!(str::contains(markdown, "## Function `a`"));
}
#[test]
fn write_markdown_should_write_function_header() {
let markdown = render(~"fn func() { }");
assert!(str::contains(markdown, ~"## Function `func`"));
assert!(str::contains(markdown, "## Function `func`"));
}
#[test]
fn should_write_the_function_signature() {
let markdown = render(~"#[doc = \"f\"] fn a() { }");
assert!(str::contains(markdown, ~"\n fn a()\n"));
assert!(str::contains(markdown, "\n fn a()\n"));
}
#[test]
fn should_insert_blank_line_after_fn_signature() {
let markdown = render(~"#[doc = \"f\"] fn a() { }");
assert!(str::contains(markdown, ~"fn a()\n\n"));
assert!(str::contains(markdown, "fn a()\n\n"));
}
#[test]
@ -763,19 +763,19 @@ fn should_correctly_indent_fn_signature() {
]
};
let markdown = write_markdown_str(doc);
assert!(str::contains(markdown, ~" line 1\n line 2"));
assert!(str::contains(markdown, " line 1\n line 2"));
}
#[test]
fn should_leave_blank_line_between_fn_header_and_sig() {
let markdown = render(~"fn a() { }");
assert!(str::contains(markdown, ~"Function `a`\n\n fn a()"));
assert!(str::contains(markdown, "Function `a`\n\n fn a()"));
}
#[test]
fn should_write_const_header() {
let markdown = render(~"static a: bool = true;");
assert!(str::contains(markdown, ~"## Const `a`\n\n"));
assert!(str::contains(markdown, "## Const `a`\n\n"));
}
#[test]
@ -783,20 +783,19 @@ fn should_write_const_description() {
let markdown = render(
~"#[doc = \"b\"]\
static a: bool = true;");
assert!(str::contains(markdown, ~"\n\nb\n\n"));
assert!(str::contains(markdown, "\n\nb\n\n"));
}
#[test]
fn should_write_enum_header() {
let markdown = render(~"enum a { b }");
assert!(str::contains(markdown, ~"## Enum `a`\n\n"));
assert!(str::contains(markdown, "## Enum `a`\n\n"));
}
#[test]
fn should_write_enum_description() {
let markdown = render(
~"#[doc = \"b\"] enum a { b }");
assert!(str::contains(markdown, ~"\n\nb\n\n"));
let markdown = render(~"#[doc = \"b\"] enum a { b }");
assert!(str::contains(markdown, "\n\nb\n\n"));
}
#[test]
@ -807,9 +806,9 @@ fn should_write_variant_list() {
#[doc = \"test\"] c }");
assert!(str::contains(
markdown,
~"\n\n#### Variants\n\
\n* `b` - test\
\n* `c` - test\n\n"));
"\n\n#### Variants\n\
\n* `b` - test\
\n* `c` - test\n\n"));
}
#[test]
@ -817,9 +816,9 @@ fn should_write_variant_list_without_descs() {
let markdown = render(~"enum a { b, c }");
assert!(str::contains(
markdown,
~"\n\n#### Variants\n\
\n* `b`\
\n* `c`\n\n"));
"\n\n#### Variants\n\
\n* `b`\
\n* `c`\n\n"));
}
#[test]
@ -827,100 +826,97 @@ fn should_write_variant_list_with_signatures() {
let markdown = render(~"enum a { b(int), #[doc = \"a\"] c(int) }");
assert!(str::contains(
markdown,
~"\n\n#### Variants\n\
\n* `b(int)`\
\n* `c(int)` - a\n\n"));
"\n\n#### Variants\n\
\n* `b(int)`\
\n* `c(int)` - a\n\n"));
}
#[test]
fn should_write_trait_header() {
let markdown = render(~"trait i { fn a(); }");
assert!(str::contains(markdown, ~"## Trait `i`"));
assert!(str::contains(markdown, "## Trait `i`"));
}
#[test]
fn should_write_trait_desc() {
let markdown = render(
~"#[doc = \"desc\"] trait i { fn a(); }");
assert!(str::contains(markdown, ~"desc"));
let markdown = render(~"#[doc = \"desc\"] trait i { fn a(); }");
assert!(str::contains(markdown, "desc"));
}
#[test]
fn should_write_trait_method_header() {
let markdown = render(
~"trait i { fn a(); }");
assert!(str::contains(markdown, ~"### Method `a`"));
let markdown = render(~"trait i { fn a(); }");
assert!(str::contains(markdown, "### Method `a`"));
}
#[test]
fn should_write_trait_method_signature() {
let markdown = render(
~"trait i { fn a(&self); }");
assert!(str::contains(markdown, ~"\n fn a(&self)"));
let markdown = render(~"trait i { fn a(&self); }");
assert!(str::contains(markdown, "\n fn a(&self)"));
}
#[test]
fn should_write_impl_header() {
let markdown = render(~"impl int { fn a() { } }");
assert!(str::contains(markdown, ~"## Implementation for `int`"));
assert!(str::contains(markdown, "## Implementation for `int`"));
}
#[test]
fn should_write_impl_header_with_bounds() {
let markdown = render(~"impl <T> int<T> { }");
assert!(str::contains(markdown, ~"## Implementation for `int<T>` where `<T>`"));
assert!(str::contains(markdown, "## Implementation for `int<T>` where `<T>`"));
}
#[test]
fn should_write_impl_header_with_trait() {
let markdown = render(~"impl j for int { fn a() { } }");
assert!(str::contains(markdown,
~"## Implementation of `j` for `int`"));
"## Implementation of `j` for `int`"));
}
#[test]
fn should_write_impl_desc() {
let markdown = render(
~"#[doc = \"desc\"] impl int { fn a() { } }");
assert!(str::contains(markdown, ~"desc"));
assert!(str::contains(markdown, "desc"));
}
#[test]
fn should_write_impl_method_header() {
let markdown = render(
~"impl int { fn a() { } }");
assert!(str::contains(markdown, ~"### Method `a`"));
assert!(str::contains(markdown, "### Method `a`"));
}
#[test]
fn should_write_impl_method_signature() {
let markdown = render(
~"impl int { fn a(&mut self) { } }");
assert!(str::contains(markdown, ~"\n fn a(&mut self)"));
assert!(str::contains(markdown, "\n fn a(&mut self)"));
}
#[test]
fn should_write_type_header() {
let markdown = render(~"type t = int;");
assert!(str::contains(markdown, ~"## Type `t`"));
assert!(str::contains(markdown, "## Type `t`"));
}
#[test]
fn should_write_type_desc() {
let markdown = render(
~"#[doc = \"desc\"] type t = int;");
assert!(str::contains(markdown, ~"\n\ndesc\n\n"));
assert!(str::contains(markdown, "\n\ndesc\n\n"));
}
#[test]
fn should_write_type_signature() {
let markdown = render(~"type t = int;");
assert!(str::contains(markdown, ~"\n\n type t = int\n\n"));
assert!(str::contains(markdown, "\n\n type t = int\n\n"));
}
#[test]
fn should_put_struct_header() {
let markdown = render(~"struct S { field: () }");
assert!(str::contains(markdown, ~"## Struct `S`\n\n"));
assert!(str::contains(markdown, "## Struct `S`\n\n"));
}
}

View File

@ -188,7 +188,7 @@ mod a {
}");
assert!(str::contains(
doc.cratemod().mods()[0].item.sections[0].header,
~"Header"));
"Header"));
}
#[test]
@ -201,7 +201,7 @@ mod a {
}");
assert!(str::contains(
doc.cratemod().mods()[0].item.sections[0].body,
~"Body"));
"Body"));
}
#[test]
@ -226,10 +226,10 @@ mod a {
}");
assert!(!str::contains(
doc.cratemod().mods()[0].desc().get(),
~"Header"));
"Header"));
assert!(!str::contains(
doc.cratemod().mods()[0].desc().get(),
~"Body"));
"Body"));
}
#[test]