]> git.lizzy.rs Git - rust.git/commitdiff
rustbuild: Add crate documentation generation
authorAlex Crichton <alex@alexcrichton.com>
Tue, 8 Mar 2016 06:36:21 +0000 (22:36 -0800)
committerAlex Crichton <alex@alexcrichton.com>
Tue, 8 Mar 2016 19:51:47 +0000 (11:51 -0800)
Run `cargo doc` to generate all documentation for the standard library, and also
add a target which generates documentation for the compiler as well (but don't
enable it by default).

src/bootstrap/build/doc.rs
src/bootstrap/build/mod.rs
src/bootstrap/build/step.rs
src/bootstrap/build/util.rs

index 937a234bec86dda5f21c380876d5a6ae51910c31..02eda0e7b58fb2419a68967299f181ed23e462f1 100644 (file)
@@ -13,7 +13,7 @@
 use std::io::prelude::*;
 
 use build::{Build, Compiler};
-use build::util::up_to_date;
+use build::util::{up_to_date, cp_r};
 
 pub fn rustbook(build: &Build, stage: u32, host: &str, name: &str, out: &Path) {
     t!(fs::create_dir_all(out));
@@ -102,3 +102,40 @@ pub fn standalone(build: &Build, stage: u32, host: &str, out: &Path) {
         build.run(&mut cmd);
     }
 }
+
+pub fn std(build: &Build, stage: u32, host: &str, out: &Path) {
+    println!("Documenting stage{} std ({})", stage, host);
+    let compiler = Compiler::new(stage, host);
+    let out_dir = build.stage_out(stage, host, true)
+                       .join(host).join("doc");
+    let rustdoc = build.tool(&compiler, "rustdoc");
+    if !up_to_date(&rustdoc, &out_dir.join("std/index.html")) {
+        t!(fs::remove_dir_all(&out_dir));
+    }
+
+    let mut cargo = build.cargo(stage, &compiler, true, host,
+                                "doc");
+    cargo.arg("--manifest-path")
+         .arg(build.src.join("src/rustc/std_shim/Cargo.toml"))
+         .arg("--features").arg(build.std_features());
+    build.run(&mut cargo);
+    cp_r(&out_dir, out)
+}
+
+pub fn rustc(build: &Build, stage: u32, host: &str, out: &Path) {
+    println!("Documenting stage{} compiler ({})", stage, host);
+    let compiler = Compiler::new(stage, host);
+    let out_dir = build.stage_out(stage, host, false)
+                       .join(host).join("doc");
+    let rustdoc = build.tool(&compiler, "rustdoc");
+    if !up_to_date(&rustdoc, &out_dir.join("rustc/index.html")) {
+        t!(fs::remove_dir_all(&out_dir));
+    }
+    let mut cargo = build.cargo(stage, &compiler, false, host,
+                                "doc");
+    cargo.arg("--manifest-path")
+         .arg(build.src.join("src/rustc/Cargo.toml"))
+         .arg("--features").arg(build.rustc_features(stage));
+    build.run(&mut cargo);
+    cp_r(&out_dir, out)
+}
index 98d821b8b90235c71d4ed718e3e1b8544024a29a..05920a480a9ae77d65ef8eae887735198788d28d 100644 (file)
@@ -179,7 +179,15 @@ pub fn build(&mut self) {
                 DocStandalone { stage } => {
                     doc::standalone(self, stage, target.target, &doc_out);
                 }
-                Doc { .. } => {} // pseudo-step
+                DocStd { stage } => {
+                    doc::std(self, stage, target.target, &doc_out);
+                }
+                DocRustc { stage } => {
+                    doc::rustc(self, stage, target.target, &doc_out);
+                }
+
+                Doc { .. } | // pseudo-steps
+                Check { .. } => {}
             }
         }
     }
index fbdcddf3aa06491495e782e83e6723e50ef13db0..fc8d366faac2a1ee9b30e868a5faa733b1265991 100644 (file)
@@ -62,6 +62,8 @@ macro_rules! targets {
             (doc_nomicon, DocNomicon { stage: u32 }),
             (doc_style, DocStyle { stage: u32 }),
             (doc_standalone, DocStandalone { stage: u32 }),
+            (doc_std, DocStd { stage: u32 }),
+            (doc_rustc, DocRustc { stage: u32 }),
 
             // Steps for running tests. The 'check' target is just a pseudo
             // target to depend on a bunch of others.
@@ -182,6 +184,8 @@ fn add_steps<'a>(build: &'a Build,
             "doc-standalone" => targets.push(host.doc_standalone(stage)),
             "doc-nomicon" => targets.push(host.doc_nomicon(stage)),
             "doc-book" => targets.push(host.doc_book(stage)),
+            "doc-std" => targets.push(host.doc_std(stage)),
+            "doc-rustc" => targets.push(host.doc_rustc(stage)),
             "doc" => targets.push(host.doc(stage)),
             "check" => targets.push(host.check(stage, compiler)),
             _ => panic!("unknown build target: `{}`", step),
@@ -239,15 +243,22 @@ pub fn deps(&self, build: &'a Build) -> Vec<Step<'a>> {
                 vec![self.llvm(()).target(&build.config.build)]
             }
             Source::Llvm { _dummy } => Vec::new(),
+            Source::DocStd { stage } => {
+                vec![self.libstd(stage, self.compiler(stage))]
+            }
             Source::DocBook { stage } |
             Source::DocNomicon { stage } |
             Source::DocStyle { stage } |
             Source::DocStandalone { stage } => {
                 vec![self.rustc(stage)]
             }
+            Source::DocRustc { stage } => {
+                vec![self.doc_std(stage)]
+            }
             Source::Doc { stage } => {
                 vec![self.doc_book(stage), self.doc_nomicon(stage),
-                     self.doc_style(stage), self.doc_standalone(stage)]
+                     self.doc_style(stage), self.doc_standalone(stage),
+                     self.doc_std(stage)]
             }
             Source::Check { stage, compiler: _ } => {
                 vec![]
index 6c700671f11115d396897e1e537a5ca66f6364f0..35d22ee5d2658ecedd01abc92cc22b11b4f8a7f1 100644 (file)
@@ -30,7 +30,6 @@ pub fn mtime(path: &Path) -> FileTime {
     }).unwrap_or(FileTime::zero())
 }
 
-#[allow(dead_code)] // this will be used soon
 pub fn cp_r(src: &Path, dst: &Path) {
     for f in t!(fs::read_dir(src)) {
         let f = t!(f);