diff options
Diffstat (limited to 'src/rustdoc/sectionalize_pass.rs')
| -rw-r--r-- | src/rustdoc/sectionalize_pass.rs | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/src/rustdoc/sectionalize_pass.rs b/src/rustdoc/sectionalize_pass.rs index 0974e5da850..a6bb3574687 100644 --- a/src/rustdoc/sectionalize_pass.rs +++ b/src/rustdoc/sectionalize_pass.rs @@ -4,7 +4,7 @@ export mk_pass; fn mk_pass() -> pass { { - name: "sectionalize", + name: ~"sectionalize", f: run } } @@ -64,7 +64,7 @@ fn fold_impl(fold: fold::fold<()>, doc: doc::impldoc) -> doc::impldoc { } } -fn sectionalize(desc: option<str>) -> (option<str>, ~[doc::section]) { +fn sectionalize(desc: option<~str>) -> (option<~str>, ~[doc::section]) { /*! * Take a description of the form @@ -88,7 +88,7 @@ fn sectionalize(desc: option<str>) -> (option<str>, ~[doc::section]) { let lines = str::lines(option::get(desc)); - let mut new_desc = none::<str>; + let mut new_desc = none::<~str>; let mut current_section = none; let mut sections = ~[]; @@ -100,21 +100,21 @@ fn sectionalize(desc: option<str>) -> (option<str>, ~[doc::section]) { } current_section = some({ header: header, - body: "" + body: ~"" }); } none { alt copy current_section { some(section) { current_section = some({ - body: section.body + "\n" + line + body: section.body + ~"\n" + line with section }); } none { new_desc = alt new_desc { some(desc) { - some(desc + "\n" + line) + some(desc + ~"\n" + line) } none { some(line) @@ -133,8 +133,8 @@ fn sectionalize(desc: option<str>) -> (option<str>, ~[doc::section]) { (new_desc, sections) } -fn parse_header(line: str) -> option<str> { - if str::starts_with(line, "# ") { +fn parse_header(line: ~str) -> option<~str> { + if str::starts_with(line, ~"# ") { some(str::slice(line, 2u, str::len(line))) } else { none @@ -144,31 +144,31 @@ fn parse_header(line: str) -> option<str> { #[test] fn should_create_section_headers() { let doc = test::mk_doc( - "#[doc = \"\ + ~"#[doc = \"\ # Header\n\ Body\"]\ mod a { }"); assert str::contains( doc.cratemod().mods()[0].item.sections[0].header, - "Header"); + ~"Header"); } #[test] fn should_create_section_bodies() { let doc = test::mk_doc( - "#[doc = \"\ + ~"#[doc = \"\ # Header\n\ Body\"]\ mod a { }"); assert str::contains( doc.cratemod().mods()[0].item.sections[0].body, - "Body"); + ~"Body"); } #[test] fn should_not_create_sections_from_indented_headers() { let doc = test::mk_doc( - "#[doc = \"\n\ + ~"#[doc = \"\n\ Text\n # Header\n\ Body\"]\ mod a { }"); @@ -178,23 +178,23 @@ fn should_not_create_sections_from_indented_headers() { #[test] fn should_remove_section_text_from_main_desc() { let doc = test::mk_doc( - "#[doc = \"\ + ~"#[doc = \"\ Description\n\n\ # Header\n\ Body\"]\ mod a { }"); assert !str::contains( option::get(doc.cratemod().mods()[0].desc()), - "Header"); + ~"Header"); assert !str::contains( option::get(doc.cratemod().mods()[0].desc()), - "Body"); + ~"Body"); } #[test] fn should_eliminate_desc_if_it_is_just_whitespace() { let doc = test::mk_doc( - "#[doc = \"\ + ~"#[doc = \"\ # Header\n\ Body\"]\ mod a { }"); @@ -204,7 +204,7 @@ fn should_eliminate_desc_if_it_is_just_whitespace() { #[test] fn should_sectionalize_trait_methods() { let doc = test::mk_doc( - "iface i { + ~"iface i { #[doc = \"\ # Header\n\ Body\"]\ @@ -215,7 +215,7 @@ fn should_sectionalize_trait_methods() { #[test] fn should_sectionalize_impl_methods() { let doc = test::mk_doc( - "impl i for bool { + ~"impl i for bool { #[doc = \"\ # Header\n\ Body\"]\ @@ -225,9 +225,9 @@ fn should_sectionalize_impl_methods() { #[cfg(test)] mod test { - fn mk_doc(source: str) -> doc::doc { + fn mk_doc(source: ~str) -> doc::doc { do astsrv::from_str(source) |srv| { - let doc = extract::from_srv(srv, ""); + let doc = extract::from_srv(srv, ~""); let doc = attr_pass::mk_pass().f(srv, doc); run(srv, doc) } |
