about summary refs log tree commit diff
path: root/src/rustdoc
diff options
context:
space:
mode:
Diffstat (limited to 'src/rustdoc')
-rw-r--r--src/rustdoc/astsrv.rs2
-rw-r--r--src/rustdoc/config.rs27
-rw-r--r--src/rustdoc/markdown_index_pass.rs4
-rw-r--r--src/rustdoc/markdown_pass.rs2
-rw-r--r--src/rustdoc/markdown_writer.rs32
-rw-r--r--src/rustdoc/parse.rs6
-rwxr-xr-xsrc/rustdoc/rustdoc.rs4
7 files changed, 39 insertions, 38 deletions
diff --git a/src/rustdoc/astsrv.rs b/src/rustdoc/astsrv.rs
index 3dd029f2307..91f910f5280 100644
--- a/src/rustdoc/astsrv.rs
+++ b/src/rustdoc/astsrv.rs
@@ -51,7 +51,7 @@ fn from_str<T>(source: ~str, owner: srv_owner<T>) -> T {
 }
 
 fn from_file<T>(file: ~str, owner: srv_owner<T>) -> T {
-    run(owner, file, parse::from_file_sess)
+    run(owner, file, |sess, f| parse::from_file_sess(sess, &Path(f)))
 }
 
 fn run<T>(owner: srv_owner<T>, source: ~str, +parse: parser) -> T {
diff --git a/src/rustdoc/config.rs b/src/rustdoc/config.rs
index 96f418247af..9bb3d4730d4 100644
--- a/src/rustdoc/config.rs
+++ b/src/rustdoc/config.rs
@@ -28,8 +28,8 @@ enum output_style {
 
 /// The configuration for a rustdoc session
 type config = {
-    input_crate: ~str,
-    output_dir: ~str,
+    input_crate: Path,
+    output_dir: Path,
     output_format: output_format,
     output_style: output_style,
     pandoc_cmd: option<~str>
@@ -67,10 +67,10 @@ fn usage() {
     println(~"");
 }
 
-fn default_config(input_crate: ~str) -> config {
+fn default_config(input_crate: &Path) -> config {
     {
-        input_crate: input_crate,
-        output_dir: ~".",
+        input_crate: *input_crate,
+        output_dir: Path("."),
         output_format: pandoc_html,
         output_style: doc_per_mod,
         pandoc_cmd: none
@@ -103,8 +103,8 @@ fn parse_config_(
     match getopts::getopts(args, opts) {
         result::ok(matches) => {
             if vec::len(matches.free) == 1u {
-                let input_crate = vec::head(matches.free);
-                config_from_opts(input_crate, matches, program_output)
+                let input_crate = Path(vec::head(matches.free));
+                config_from_opts(&input_crate, matches, program_output)
             } else if vec::is_empty(matches.free) {
                 result::err(~"no crates specified")
             } else {
@@ -118,7 +118,7 @@ fn parse_config_(
 }
 
 fn config_from_opts(
-    input_crate: ~str,
+    input_crate: &Path,
     matches: getopts::matches,
     program_output: program_output
 ) -> result<config, ~str> {
@@ -127,6 +127,7 @@ fn config_from_opts(
     let result = result::ok(config);
     let result = do result::chain(result) |config| {
         let output_dir = getopts::opt_maybe_str(matches, opt_output_dir());
+        let output_dir = option::map(output_dir, |s| Path(s));
         result::ok({
             output_dir: option::get_default(output_dir, config.output_dir)
             with config
@@ -205,7 +206,7 @@ fn maybe_find_pandoc(
       none => {
         ~[~"pandoc"] + match os::homedir() {
           some(dir) => {
-            ~[path::connect(dir, ~".cabal/bin/pandoc")]
+            ~[dir.push_rel(&Path(".cabal/bin/pandoc")).to_str()]
           }
           none => ~[]
         }
@@ -229,7 +230,7 @@ fn maybe_find_pandoc(
 fn should_find_pandoc() {
     let config = {
         output_format: pandoc_html
-        with default_config(~"test")
+        with default_config(&Path("test"))
     };
     let mock_program_output = fn~(_prog: &str, _args: &[~str]) -> {
         status: int, out: ~str, err: ~str
@@ -246,7 +247,7 @@ fn should_find_pandoc() {
 fn should_error_with_no_pandoc() {
     let config = {
         output_format: pandoc_html
-        with default_config(~"test")
+        with default_config(&Path("test"))
     };
     let mock_program_output = fn~(_prog: &str, _args: &[~str]) -> {
         status: int, out: ~str, err: ~str
@@ -282,7 +283,7 @@ fn should_error_with_multiple_crates() {
 #[test]
 fn should_set_output_dir_to_cwd_if_not_provided() {
     let config = test::parse_config(~[~"rustdoc", ~"crate.rc"]);
-    assert result::get(config).output_dir == ~".";
+    assert result::get(config).output_dir == Path(".");
 }
 
 #[test]
@@ -290,7 +291,7 @@ fn should_set_output_dir_if_provided() {
     let config = test::parse_config(~[
         ~"rustdoc", ~"crate.rc", ~"--output-dir", ~"snuggles"
     ]);
-    assert result::get(config).output_dir == ~"snuggles";
+    assert result::get(config).output_dir == Path("snuggles");
 }
 
 #[test]
diff --git a/src/rustdoc/markdown_index_pass.rs b/src/rustdoc/markdown_index_pass.rs
index 9a58d0c9179..47b1cee019c 100644
--- a/src/rustdoc/markdown_index_pass.rs
+++ b/src/rustdoc/markdown_index_pass.rs
@@ -81,7 +81,7 @@ fn item_to_entry(
     let link = match doc {
       doc::modtag(_) | doc::nmodtag(_)
       if config.output_style == config::doc_per_mod => {
-        markdown_writer::make_filename(config, doc::itempage(doc))
+        markdown_writer::make_filename(config, doc::itempage(doc)).to_str()
       }
       _ => {
         ~"#" + pandoc_header_id(markdown_pass::header_text(doc))
@@ -230,7 +230,7 @@ mod test {
         do astsrv::from_str(source) |srv| {
             let config = {
                 output_style: output_style
-                with config::default_config(~"whatever")
+                with config::default_config(&Path("whatever"))
             };
             let doc = extract::from_srv(srv, ~"");
             let doc = attr_pass::mk_pass().f(srv, doc);
diff --git a/src/rustdoc/markdown_pass.rs b/src/rustdoc/markdown_pass.rs
index 6ed6dc4abab..da05b935cef 100644
--- a/src/rustdoc/markdown_pass.rs
+++ b/src/rustdoc/markdown_pass.rs
@@ -785,7 +785,7 @@ mod test {
 
             let config = {
                 output_style: config::doc_per_crate
-                with config::default_config(~"whatever")
+                with config::default_config(&Path("whatever"))
             };
 
             let doc = extract::from_srv(srv, ~"");
diff --git a/src/rustdoc/markdown_writer.rs b/src/rustdoc/markdown_writer.rs
index 74932ca579d..a62f275acc8 100644
--- a/src/rustdoc/markdown_writer.rs
+++ b/src/rustdoc/markdown_writer.rs
@@ -66,7 +66,7 @@ fn markdown_writer(
 ) -> writer {
     let filename = make_local_filename(config, page);
     do generic_writer |markdown| {
-        write_file(filename, markdown);
+        write_file(&filename, markdown);
     }
 }
 
@@ -84,7 +84,7 @@ fn pandoc_writer(
         ~"--from=markdown",
         ~"--to=html",
         ~"--css=rust.css",
-        ~"--output=" + filename
+        ~"--output=" + filename.to_str()
     ];
 
     do generic_writer |markdown| {
@@ -166,15 +166,15 @@ fn generic_writer(+process: fn~(markdown: ~str)) -> writer {
 fn make_local_filename(
     config: config::config,
     page: doc::page
-) -> ~str {
+) -> Path {
     let filename = make_filename(config, page);
-    path::connect(config.output_dir, filename)
+    config.output_dir.push_rel(&filename)
 }
 
 fn make_filename(
     config: config::config,
     page: doc::page
-) -> ~str {
+) -> Path {
     let filename = {
         match page {
           doc::cratepage(doc) => {
@@ -196,50 +196,50 @@ fn make_filename(
       config::pandoc_html => ~"html"
     };
 
-    filename + ~"." + ext
+    Path(filename).with_filetype(ext)
 }
 
 #[test]
 fn should_use_markdown_file_name_based_off_crate() {
     let config = {
-        output_dir: ~"output/dir",
+        output_dir: Path("output/dir"),
         output_format: config::markdown,
         output_style: config::doc_per_crate
-        with config::default_config(~"input/test.rc")
+        with config::default_config(&Path("input/test.rc"))
     };
     let doc = test::mk_doc(~"test", ~"");
     let page = doc::cratepage(doc.cratedoc());
     let filename = make_local_filename(config, page);
-    assert filename == ~"output/dir/test.md";
+    assert filename.to_str() == ~"output/dir/test.md";
 }
 
 #[test]
 fn should_name_html_crate_file_name_index_html_when_doc_per_mod() {
     let config = {
-        output_dir: ~"output/dir",
+        output_dir: Path("output/dir"),
         output_format: config::pandoc_html,
         output_style: config::doc_per_mod
-        with config::default_config(~"input/test.rc")
+        with config::default_config(&Path("input/test.rc"))
     };
     let doc = test::mk_doc(~"", ~"");
     let page = doc::cratepage(doc.cratedoc());
     let filename = make_local_filename(config, page);
-    assert filename == ~"output/dir/index.html";
+    assert filename.to_str() == ~"output/dir/index.html";
 }
 
 #[test]
 fn should_name_mod_file_names_by_path() {
     let config = {
-        output_dir: ~"output/dir",
+        output_dir: Path("output/dir"),
         output_format: config::pandoc_html,
         output_style: config::doc_per_mod
-        with config::default_config(~"input/test.rc")
+        with config::default_config(&Path("input/test.rc"))
     };
     let doc = test::mk_doc(~"", ~"mod a { mod b { } }");
     let modb = doc.cratemod().mods()[0].mods()[0];
     let page = doc::itempage(doc::modtag(modb));
     let filename = make_local_filename(config, page);
-    assert  filename == ~"output/dir/a_b.html";
+    assert  filename == Path("output/dir/a_b.html");
 }
 
 #[cfg(test)]
@@ -253,7 +253,7 @@ mod test {
     }
 }
 
-fn write_file(path: ~str, s: ~str) {
+fn write_file(path: &Path, s: ~str) {
     import io::WriterUtil;
 
     match io::file_writer(path, ~[io::Create, io::Truncate]) {
diff --git a/src/rustdoc/parse.rs b/src/rustdoc/parse.rs
index ca30e8aa8a8..e74700b7b67 100644
--- a/src/rustdoc/parse.rs
+++ b/src/rustdoc/parse.rs
@@ -10,7 +10,7 @@ import syntax::parse;
 
 export from_file, from_str, from_file_sess, from_str_sess;
 
-fn from_file(file: ~str) -> @ast::crate {
+fn from_file(file: &Path) -> @ast::crate {
     parse::parse_crate_from_file(
         file, ~[], parse::new_parse_sess(none))
 }
@@ -20,9 +20,9 @@ fn from_str(source: ~str) -> @ast::crate {
         ~"-", @source, ~[], parse::new_parse_sess(none))
 }
 
-fn from_file_sess(sess: session::session, file: ~str) -> @ast::crate {
+fn from_file_sess(sess: session::session, file: &Path) -> @ast::crate {
     parse::parse_crate_from_file(
-        file, cfg(sess, file_input(file)), sess.parse_sess)
+        file, cfg(sess, file_input(*file)), sess.parse_sess)
 }
 
 fn from_str_sess(sess: session::session, source: ~str) -> @ast::crate {
diff --git a/src/rustdoc/rustdoc.rs b/src/rustdoc/rustdoc.rs
index 751e94e8649..ec7556afa0a 100755
--- a/src/rustdoc/rustdoc.rs
+++ b/src/rustdoc/rustdoc.rs
@@ -130,13 +130,13 @@ fn time<T>(what: ~str, f: fn() -> T) -> T {
 fn run(config: config::config) {
 
     let source_file = config.input_crate;
-    do astsrv::from_file(source_file) |srv| {
+    do astsrv::from_file(source_file.to_str()) |srv| {
         do time(~"wait_ast") {
             do astsrv::exec(srv) |_ctxt| { }
         };
         let doc = time(~"extract", || {
             let default_name = source_file;
-            extract::from_srv(srv, default_name)
+            extract::from_srv(srv, default_name.to_str())
         });
         run_passes(srv, doc, ~[
             tystr_pass::mk_pass(),