]> git.lizzy.rs Git - rust.git/commitdiff
auto merge of #9241 : alexcrichton/rust/build-rustdoc-ng, r=catamorphism
authorbors <bors@rust-lang.org>
Tue, 17 Sep 2013 13:00:45 +0000 (06:00 -0700)
committerbors <bors@rust-lang.org>
Tue, 17 Sep 2013 13:00:45 +0000 (06:00 -0700)
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).

Note that some `rustdoc_ng` tests were removed, but @cmr says they weren't supposed to be there in the first place. The rustdoc_ng code should also be included in `make install` and `make dist` now.

Makefile.in
mk/clean.mk
mk/dist.mk
mk/install.mk
mk/tests.mk
mk/tools.mk
src/driver/driver.rs
src/rustdoc_ng/clean.rs
src/rustdoc_ng/lib.rs [deleted file]
src/rustdoc_ng/main.rs [deleted file]
src/rustdoc_ng/rustdoc_ng.rs [new file with mode: 0644]

index 171ce8f19253d57014b80c7962dbc03c67143faa..a1c276cd3d20395715570a8f66fa3b16a1ae160b 100644 (file)
@@ -442,6 +442,7 @@ CSREQ$(1)_T_$(2)_H_$(3) = \
        $$(TSREQ$(1)_T_$(2)_H_$(3)) \
        $$(HBIN$(1)_H_$(3))/rustpkg$$(X_$(3)) \
        $$(HBIN$(1)_H_$(3))/rustdoc$$(X_$(3)) \
+       $$(HBIN$(1)_H_$(3))/rustdoc_ng$$(X_$(3)) \
        $$(HBIN$(1)_H_$(3))/rusti$$(X_$(3)) \
        $$(HBIN$(1)_H_$(3))/rust$$(X_$(3)) \
        $$(HLIB$(1)_H_$(3))/$(CFG_LIBRUSTPKG_$(3)) \
index 5e8d9835db20f2b80d98542e2d5563a36b122964..30ec6b15bfefe701b14e586a5b2607ff9311277b 100644 (file)
@@ -68,6 +68,7 @@ clean$(1)_H_$(2):
        $(Q)rm -f $$(HBIN$(1)_H_$(2))/rustpkg$(X_$(2))
        $(Q)rm -f $$(HBIN$(1)_H_$(2))/serializer$(X_$(2))
        $(Q)rm -f $$(HBIN$(1)_H_$(2))/rustdoc$(X_$(2))
+       $(Q)rm -f $$(HBIN$(1)_H_$(2))/rustdoc_ng$(X_$(2))
        $(Q)rm -f $$(HBIN$(1)_H_$(2))/rusti$(X_$(2))
        $(Q)rm -f $$(HBIN$(1)_H_$(2))/rust$(X_$(2))
        $(Q)rm -f $$(HLIB$(1)_H_$(2))/$(CFG_LIBRUSTPKG_$(2))
@@ -105,6 +106,7 @@ clean$(1)_T_$(2)_H_$(3):
        $(Q)rm -f $$(TBIN$(1)_T_$(2)_H_$(3))/rustpkg$(X_$(2))
        $(Q)rm -f $$(TBIN$(1)_T_$(2)_H_$(3))/serializer$(X_$(2))
        $(Q)rm -f $$(TBIN$(1)_T_$(2)_H_$(3))/rustdoc$(X_$(2))
+       $(Q)rm -f $$(TBIN$(1)_T_$(2)_H_$(3))/rustdoc_ng$(X_$(2))
        $(Q)rm -f $$(TBIN$(1)_T_$(2)_H_$(3))/rusti$(X_$(2))
        $(Q)rm -f $$(TBIN$(1)_T_$(2)_H_$(3))/rust$(X_$(2))
        $(Q)rm -f $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUSTPKG_$(2))
index 4a980edf7673141df16ae7895f9c14c37e9b5f7e..34230e6a5aaff3d143ad3b6fa50e7d3e0a130ab8 100644 (file)
@@ -39,6 +39,7 @@ PKG_FILES := \
       libsyntax                                \
       rt                                       \
       librustdoc                               \
+      rustdoc_ng                               \
       rustllvm                                 \
       snapshots.txt                            \
       test)                                    \
index bc4633b8225c4b6d8b46abbd98a082c457e288e2..3989e4f8119c8de74fa23db457bfba30e3edb3fb 100644 (file)
@@ -140,6 +140,7 @@ install-host: $(CSREQ$(ISTAGE)_T_$(CFG_BUILD_TRIPLE)_H_$(CFG_BUILD_TRIPLE))
        $(Q)$(call INSTALL,$(HB2),$(PHB),rustc$(X_$(CFG_BUILD_TRIPLE)))
        $(Q)$(call INSTALL,$(HB2),$(PHB),rustpkg$(X_$(CFG_BUILD_TRIPLE)))
        $(Q)$(call INSTALL,$(HB2),$(PHB),rustdoc$(X_$(CFG_BUILD_TRIPLE)))
+       $(Q)$(call INSTALL,$(HB2),$(PHB),rustdoc_ng$(X_$(CFG_BUILD_TRIPLE)))
        $(Q)$(call INSTALL,$(HB2),$(PHB),rusti$(X_$(CFG_BUILD_TRIPLE)))
        $(Q)$(call INSTALL,$(HB2),$(PHB),rust$(X_$(CFG_BUILD_TRIPLE)))
        $(Q)$(call INSTALL_LIB,$(STDLIB_GLOB_$(CFG_BUILD_TRIPLE)))
@@ -171,6 +172,7 @@ uninstall:
        $(Q)rm -f $(PHB)/rusti$(X_$(CFG_BUILD_TRIPLE))
        $(Q)rm -f $(PHB)/rust$(X_$(CFG_BUILD_TRIPLE))
        $(Q)rm -f $(PHB)/rustdoc$(X_$(CFG_BUILD_TRIPLE))
+       $(Q)rm -f $(PHB)/rustdoc_ng$(X_$(CFG_BUILD_TRIPLE))
        $(Q)rm -f $(PHL)/$(CFG_RUSTLLVM_$(CFG_BUILD_TRIPLE))
        $(Q)rm -f $(PHL)/$(CFG_RUNTIME_$(CFG_BUILD_TRIPLE))
        $(Q)for i in \
@@ -180,6 +182,7 @@ uninstall:
           $(call HOST_LIB_FROM_HL_GLOB,$(LIBSYNTAX_GLOB_$(CFG_BUILD_TRIPLE))) \
           $(call HOST_LIB_FROM_HL_GLOB,$(LIBRUSTPKG_GLOB_$(CFG_BUILD_TRIPLE))) \
           $(call HOST_LIB_FROM_HL_GLOB,$(LIBRUSTDOC_GLOB_$(CFG_BUILD_TRIPLE))) \
+          $(call HOST_LIB_FROM_HL_GLOB,$(LIBRUSTDOCNG_GLOB_$(CFG_BUILD_TRIPLE))) \
           $(call HOST_LIB_FROM_HL_GLOB,$(LIBRUSTI_GLOB_$(CFG_BUILD_TRIPLE))) \
           $(call HOST_LIB_FROM_HL_GLOB,$(LIBRUST_GLOB_$(CFG_BUILD_TRIPLE))) \
         ; \
index c6b4c9da37afa82a50c2603bfedc538d52d560b1..28bbddc787f450582b8388a46d6d1c4d981ae9a7 100644 (file)
@@ -15,7 +15,7 @@
 
 # The names of crates that must be tested
 TEST_TARGET_CRATES = std extra
-TEST_HOST_CRATES = rust rusti rustpkg rustc rustdoc syntax
+TEST_HOST_CRATES = rust rusti rustpkg rustc rustdoc rustdocng syntax
 TEST_CRATES = $(TEST_TARGET_CRATES) $(TEST_HOST_CRATES)
 
 # Markdown files under doc/ that should have their code extracted and run
@@ -393,6 +393,14 @@ $(3)/stage$(1)/test/rustdoctest-$(2)$$(X_$(2)):                                    \
        @$$(call E, compile_and_link: $$@)
        $$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --test
 
+$(3)/stage$(1)/test/rustdocngtest-$(2)$$(X_$(2)):                          \
+               $$(RUSTDOCNG_LIB) $$(RUSTDOCNG_INPUTS)          \
+               $$(SREQ$(1)_T_$(2)_H_$(3)) \
+               $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_LIBSYNTAX_$(2)) \
+               $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_LIBRUSTC_$(2))
+       @$$(call E, compile_and_link: $$@)
+       $$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --test
+
 endef
 
 $(foreach host,$(CFG_HOST_TRIPLES), \
index 848fa8447b693b6f3879f284a526aff64524ace2..212b7e570f7820ad1bf5a175bf099d959921c5a0 100644 (file)
@@ -25,7 +25,7 @@ RUSTDOC_INPUTS := $(wildcard $(S)src/librustdoc/*.rs)
 
 # rustdoc_ng, the next generation documentation tool
 
-RUSTDOCNG_LIB := $(S)src/rustdoc_ng/lib.rs
+RUSTDOCNG_LIB := $(S)src/rustdoc_ng/rustdoc_ng.rs
 RUSTDOCNG_INPUTS := $(wildcard $(S)src/rustdoc_ng/*.rs)
 
 # Rusti, the JIT REPL
@@ -208,6 +208,14 @@ $$(HLIB$(2)_H_$(4))/$(CFG_LIBRUSTDOCNG_$(4)):                                      \
                $$(wildcard $$(TLIB$(1)_T_$(4)_H_$(3))/$(LIBRUSTDOCNG_DSYM_GLOB_$(4))) \
                $$(HLIB$(2)_H_$(4))
 
+$$(HBIN$(2)_H_$(4))/rustdoc_ng$$(X_$(4)):                              \
+               $$(TBIN$(1)_T_$(4)_H_$(3))/rustdoc_ng$$(X_$(4)) \
+               $$(HLIB$(2)_H_$(4))/$(CFG_LIBRUSTDOCNG_$(4))    \
+               $$(HSREQ$(2)_H_$(4))                            \
+               | $$(HBIN$(2)_H_$(4))/
+       @$$(call E, cp: $$@)
+       $$(Q)cp $$< $$@
+
 $$(HLIB$(2)_H_$(4))/$(CFG_LIBRUSTI_$(4)):                                      \
                $$(TLIB$(1)_T_$(4)_H_$(3))/$(CFG_LIBRUSTI_$(4)) \
                $$(HLIB$(2)_H_$(4))/$(CFG_LIBRUSTC_$(4))                        \
index e81a3230e134384101441c8cc6a206a54e5af6e1..991bb914fd07f708d31b35a6ca3ef3ee4bc3a045 100644 (file)
@@ -23,4 +23,7 @@
 #[cfg(rustc)]
 extern mod this(name = "rustc");
 
+#[cfg(rustdoc_ng)]
+extern mod this(name = "rustdoc_ng");
+
 fn main() { this::main() }
index 1bfb8e28393973a90ed0c9e11bd07ab61fc08d74..65aa070ce6e9487fd6e6e6af67a5652c635ece4e 100644 (file)
@@ -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 (file)
index 75453aa..0000000
+++ /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/main.rs
deleted file mode 100644 (file)
index aad6404..0000000
+++ /dev/null
@@ -1,104 +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 = "bin"];
-
-extern mod extra;
-extern mod rustdoc_ng;
-
-use rustdoc_ng::*;
-use std::cell::Cell;
-
-use extra::serialize::Encodable;
-
-fn main() {
-    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"),
-        optmulti("", "plugin-path", "directory to load plugins from", "DIR"),
-        // auxillary pass (defaults to hidden_strip
-        optmulti("a", "pass", "auxillary pass to run", "NAME"),
-        optflag("n", "no-defult-passes", "do not run the default passes"),
-        optflag("h", "help", "show this help message"),
-    ];
-
-    let matches = getopts(args.tail(), opts).unwrap();
-
-    if opt_present(&matches, "h") || opt_present(&matches, "help") {
-        println(usage(args[0], opts));
-        return;
-    }
-
-    let libs = Cell::new(opt_strs(&matches, "L").map(|s| Path(*s)));
-
-    let mut passes = if opt_present(&matches, "n") {
-        ~[]
-    } else {
-        ~[~"collapse-docs", ~"clean-comments", ~"collapse-privacy" ]
-    };
-
-    opt_strs(&matches, "a").map(|x| passes.push(x.clone()));
-
-    if matches.free.len() != 1 {
-        println(usage(args[0], opts));
-        return;
-    }
-
-    let cr = Cell::new(Path(matches.free[0]));
-
-    let crate = 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();
-    json.insert(~"schema", extra::json::String(SCHEMA_VERSION.to_owned()));
-
-    let mut pm = plugins::PluginManager::new(Path("/tmp/rustdoc_ng/plugins"));
-
-    for pass in passes.iter() {
-        pm.add_plugin(match pass.as_slice() {
-            "strip-hidden" => passes::strip_hidden,
-            "clean-comments" => passes::clean_comments,
-            "collapse-docs" => passes::collapse_docs,
-            "collapse-privacy" => passes::collapse_privacy,
-            s => { error!("unknown pass %s, skipping", s); passes::noop },
-        })
-    }
-
-    for pname in opt_strs(&matches, "p").move_iter() {
-        pm.load_plugin(pname);
-    }
-
-    let (crate, res) = pm.run_plugins(crate);
-    let plugins_json = ~res.move_iter().filter_map(|opt| opt).collect();
-
-    // FIXME #8335: yuck, Rust -> str -> JSON round trip! No way to .encode
-    // straight to the Rust JSON representation.
-    let crate_json_str = do std::io::with_str_writer |w| {
-        crate.encode(&mut extra::json::Encoder(w));
-    };
-    let crate_json = match extra::json::from_str(crate_json_str) {
-        Ok(j) => j,
-        Err(_) => fail!("Rust generated JSON is invalid??")
-    };
-
-    json.insert(~"crate", crate_json);
-    json.insert(~"plugins", extra::json::Object(plugins_json));
-
-    println(extra::json::Object(json).to_str());
-}
diff --git a/src/rustdoc_ng/rustdoc_ng.rs b/src/rustdoc_ng/rustdoc_ng.rs
new file mode 100644 (file)
index 0000000..ec6ad69
--- /dev/null
@@ -0,0 +1,123 @@
+// 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.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 = "lib"];
+
+extern mod syntax;
+extern mod rustc;
+extern mod extra;
+
+use extra::serialize::Encodable;
+use std::cell::Cell;
+
+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());
+}
+
+pub fn main_args(args: &[~str]) {
+    use extra::getopts::*;
+    use extra::getopts::groups::*;
+
+    let opts = ~[
+        optmulti("L", "library-path", "directory to add to crate search path", "DIR"),
+        optmulti("p", "plugin", "plugin to load and run", "NAME"),
+        optmulti("", "plugin-path", "directory to load plugins from", "DIR"),
+        // auxillary pass (defaults to hidden_strip
+        optmulti("a", "pass", "auxillary pass to run", "NAME"),
+        optflag("n", "no-defult-passes", "do not run the default passes"),
+        optflag("h", "help", "show this help message"),
+    ];
+
+    let matches = getopts(args.tail(), opts).unwrap();
+
+    if opt_present(&matches, "h") || opt_present(&matches, "help") {
+        println(usage(args[0], opts));
+        return;
+    }
+
+    let libs = Cell::new(opt_strs(&matches, "L").map(|s| Path(*s)));
+
+    let mut passes = if opt_present(&matches, "n") {
+        ~[]
+    } else {
+        ~[~"collapse-docs", ~"clean-comments", ~"collapse-privacy" ]
+    };
+
+    opt_strs(&matches, "a").map(|x| passes.push(x.clone()));
+
+    if matches.free.len() != 1 {
+        println(usage(args[0], opts));
+        return;
+    }
+
+    let cr = Cell::new(Path(matches.free[0]));
+
+    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();
+    json.insert(~"schema", extra::json::String(SCHEMA_VERSION.to_owned()));
+
+    let mut pm = plugins::PluginManager::new(Path("/tmp/rustdoc_ng/plugins"));
+
+    for pass in passes.iter() {
+        pm.add_plugin(match pass.as_slice() {
+            "strip-hidden" => passes::strip_hidden,
+            "clean-comments" => passes::clean_comments,
+            "collapse-docs" => passes::collapse_docs,
+            "collapse-privacy" => passes::collapse_privacy,
+            s => { error!("unknown pass %s, skipping", s); passes::noop },
+        })
+    }
+
+    for pname in opt_strs(&matches, "p").move_iter() {
+        pm.load_plugin(pname);
+    }
+
+    let (crate, res) = pm.run_plugins(crate);
+    let plugins_json = ~res.move_iter().filter_map(|opt| opt).collect();
+
+    // FIXME #8335: yuck, Rust -> str -> JSON round trip! No way to .encode
+    // straight to the Rust JSON representation.
+    let crate_json_str = do std::io::with_str_writer |w| {
+        crate.encode(&mut extra::json::Encoder(w));
+    };
+    let crate_json = match extra::json::from_str(crate_json_str) {
+        Ok(j) => j,
+        Err(_) => fail!("Rust generated JSON is invalid??")
+    };
+
+    json.insert(~"crate", crate_json);
+    json.insert(~"plugins", extra::json::Object(plugins_json));
+
+    println(extra::json::Object(json).to_str());
+}