about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2013-09-16 16:31:04 -0700
committerAlex Crichton <alex@alexcrichton.com>2013-09-16 18:10:46 -0700
commit876cb76f1be63da0756a106ba743a617a5dfb2c8 (patch)
treeeea7f596c72cb45da8b841a7d526b5cec11d15da /src
parentbc89ade401e637fcb7d4d1d0b7f356ca359b0e7d (diff)
Add the rustdoc_ng binary to the makefile rules
Now rustdoc_ng will be built as both a binary and a library (using the same
rules as all the other binaries that rust has). Furthermore, this will also
start building rustdoc_ng unit tests (and running them).
Diffstat (limited to 'src')
-rw-r--r--src/driver/driver.rs3
-rw-r--r--src/rustdoc_ng/clean.rs24
-rw-r--r--src/rustdoc_ng/lib.rs37
-rw-r--r--src/rustdoc_ng/rustdoc_ng.rs (renamed from src/rustdoc_ng/main.rs)37
4 files changed, 31 insertions, 70 deletions
diff --git a/src/driver/driver.rs b/src/driver/driver.rs
index e81a3230e13..991bb914fd0 100644
--- a/src/driver/driver.rs
+++ b/src/driver/driver.rs
@@ -23,4 +23,7 @@ extern mod this(name = "rust");
 #[cfg(rustc)]
 extern mod this(name = "rustc");
 
+#[cfg(rustdoc_ng)]
+extern mod this(name = "rustdoc_ng");
+
 fn main() { this::main() }
diff --git a/src/rustdoc_ng/clean.rs b/src/rustdoc_ng/clean.rs
index 1bfb8e28393..65aa070ce6e 100644
--- a/src/rustdoc_ng/clean.rs
+++ b/src/rustdoc_ng/clean.rs
@@ -1043,27 +1043,3 @@ fn resolve_type(t: &Type) -> Type {
         ResolvedPath {path: path.clone(), typarams: tpbs.clone(), id: def_id.node}
     }
 }
-
-#[cfg(test)]
-mod tests {
-    use super::NameValue;
-
-    #[test]
-    fn test_doc_collapsing() {
-        assert_eq!(collapse_docs(~"// Foo\n//Bar\n // Baz\n"), ~"Foo\nBar\nBaz");
-        assert_eq!(collapse_docs(~"* Foo\n *  Bar\n *Baz\n"), ~"Foo\n Bar\nBaz");
-        assert_eq!(collapse_docs(~"* Short desc\n *\n * Bar\n *Baz\n"), ~"Short desc\n\nBar\nBaz");
-        assert_eq!(collapse_docs(~" * Foo"), ~"Foo");
-        assert_eq!(collapse_docs(~"\n *\n *\n * Foo"), ~"Foo");
-    }
-
-    fn collapse_docs(input: ~str) -> ~str {
-        let attrs = ~[NameValue(~"doc", input)];
-        let attrs_clean = super::collapse_docs(attrs);
-
-        match attrs_clean[0] {
-            NameValue(~"doc", s) => s,
-            _ => (fail!("dude where's my doc?"))
-        }
-    }
-}
diff --git a/src/rustdoc_ng/lib.rs b/src/rustdoc_ng/lib.rs
deleted file mode 100644
index 75453aa129c..00000000000
--- a/src/rustdoc_ng/lib.rs
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-#[link(name = "rustdoc_ng",
-       vers = "0.1.0",
-       uuid = "8c6e4598-1596-4aa5-a24c-b811914bbbc6")];
-#[desc = "rustdoc, the Rust documentation extractor"];
-#[license = "MIT/ASL2"];
-#[crate_type = "lib"];
-
-#[deny(warnings)];
-
-extern mod syntax;
-extern mod rustc;
-
-extern mod extra;
-
-use extra::serialize::Encodable;
-
-pub mod core;
-pub mod doctree;
-pub mod clean;
-pub mod visit_ast;
-pub mod fold;
-pub mod plugins;
-pub mod passes;
-
-pub static SCHEMA_VERSION: &'static str = "0.8.0";
-
-pub static ctxtkey: std::local_data::Key<@core::DocContext> = &std::local_data::Key;
diff --git a/src/rustdoc_ng/main.rs b/src/rustdoc_ng/rustdoc_ng.rs
index aad64041a63..ec6ad6974e9 100644
--- a/src/rustdoc_ng/main.rs
+++ b/src/rustdoc_ng/rustdoc_ng.rs
@@ -9,25 +9,41 @@
 // except according to those terms.
 
 #[link(name = "rustdoc_ng",
-       vers = "0.1.0",
-       uuid = "8c6e4598-1596-4aa5-a24c-b811914bbbc6")];
+       vers = "0.8-pre",
+       uuid = "8c6e4598-1596-4aa5-a24c-b811914bbbc6",
+       url = "https://github.com/mozilla/rust/tree/master/src/rustdoc_ng")];
+
 #[desc = "rustdoc, the Rust documentation extractor"];
 #[license = "MIT/ASL2"];
-#[crate_type = "bin"];
+#[crate_type = "lib"];
 
+extern mod syntax;
+extern mod rustc;
 extern mod extra;
-extern mod rustdoc_ng;
 
-use rustdoc_ng::*;
+use extra::serialize::Encodable;
 use std::cell::Cell;
 
-use extra::serialize::Encodable;
+pub mod core;
+pub mod doctree;
+pub mod clean;
+pub mod visit_ast;
+pub mod fold;
+pub mod plugins;
+pub mod passes;
+
+pub static SCHEMA_VERSION: &'static str = "0.8.0";
+
+local_data_key!(pub ctxtkey: @core::DocContext)
+
+pub fn main() {
+    main_args(std::os::args());
+}
 
-fn main() {
+pub fn main_args(args: &[~str]) {
     use extra::getopts::*;
     use extra::getopts::groups::*;
 
-    let args = std::os::args();
     let opts = ~[
         optmulti("L", "library-path", "directory to add to crate search path", "DIR"),
         optmulti("p", "plugin", "plugin to load and run", "NAME"),
@@ -62,7 +78,10 @@ fn main() {
 
     let cr = Cell::new(Path(matches.free[0]));
 
-    let crate = std::task::try(|| {let cr = cr.take(); core::run_core(libs.take(), &cr)}).unwrap();
+    let crate = do std::task::try {
+        let cr = cr.take();
+        core::run_core(libs.take(), &cr)
+    }.unwrap();
 
     // { "schema": version, "crate": { parsed crate ... }, "plugins": { output of plugins ... }}
     let mut json = ~extra::treemap::TreeMap::new();