about summary refs log tree commit diff
diff options
context:
space:
mode:
authorsteveklabnik <steve@steveklabnik.com>2017-11-01 15:21:55 -0400
committersteveklabnik <steve@steveklabnik.com>2017-11-14 06:51:59 -0500
commit623886f44c9c741a318b34b06f12e0a50997532b (patch)
treee2b3c639a2d826636f915b19d8587aeb8bf67790
parent24840dab0bef0047beb428e1c15e9a851f732dcc (diff)
downloadrust-623886f44c9c741a318b34b06f12e0a50997532b.tar.gz
rust-623886f44c9c741a318b34b06f12e0a50997532b.zip
Start shipping the Cargo book
Fixes #44910
Fixes #39588

See both of those bugs for more details.
-rw-r--r--src/bootstrap/doc.rs88
1 files changed, 43 insertions, 45 deletions
diff --git a/src/bootstrap/doc.rs b/src/bootstrap/doc.rs
index 16e8ee182bd..cb9698f168b 100644
--- a/src/bootstrap/doc.rs
+++ b/src/bootstrap/doc.rs
@@ -133,6 +133,49 @@ impl Step for UnstableBook {
 }
 
 #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
+pub struct CargoBook {
+    target: Interned<String>,
+    name: Interned<String>,
+    src: Interned<PathBuf>,
+}
+
+impl Step for CargoBook {
+    type Output = ();
+    const DEFAULT: bool = true;
+
+    fn should_run(run: ShouldRun) -> ShouldRun {
+        let builder = run.builder;
+        run.path("src/tools/cargo/src/doc/book").default_condition(builder.build.config.docs)
+    }
+
+    fn make_run(run: RunConfig) {
+        run.builder.ensure(CargoBook {
+            target: run.target,
+            name: INTERNER.intern_str("cargo"),
+            src: INTERNER.intern_path(PathBuf::from("src/tools/cargo/src/doc/book")),
+        });
+    }
+
+    fn run(self, builder: &Builder) {
+        let build = builder.build;
+        let target = self.target;
+        let name = self.name;
+        let src = self.src;
+        let out = build.doc_out(target);
+        t!(fs::create_dir_all(&out));
+
+        let out = out.join(name);
+        println!("Cargo Book ({}) - {}", target, name);
+        let _ = fs::remove_dir_all(&out);
+        build.run(builder.tool_cmd(Tool::Rustbook)
+                       .arg("build")
+                       .arg(&src)
+                       .arg("-d")
+                       .arg(out));
+    }
+}
+
+#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
 struct RustbookSrc {
     target: Interned<String>,
     name: Interned<String>,
@@ -240,51 +283,6 @@ impl Step for TheBook {
     }
 }
 
-#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
-pub struct CargoBook {
-    target: Interned<String>,
-}
-
-impl Step for CargoBook {
-    type Output = ();
-    const DEFAULT: bool = true;
-
-    fn should_run(run: ShouldRun) -> ShouldRun {
-        let builder = run.builder;
-        run.path("src/doc/cargo").default_condition(builder.build.config.docs)
-    }
-
-    fn make_run(run: RunConfig) {
-        run.builder.ensure(CargoBook {
-            target: run.target,
-        });
-    }
-
-    /// Create a placeholder for the cargo documentation so that doc.rust-lang.org/cargo will
-    /// redirect to doc.crates.io. We want to publish doc.rust-lang.org/cargo in the paper
-    /// version of the book, but we don't want to rush the process of switching cargo's docs
-    /// over to mdbook and deploying them. When the cargo book is ready, this implementation
-    /// should build the mdbook instead of this redirect page.
-    fn run(self, builder: &Builder) {
-        let build = builder.build;
-        let out = build.doc_out(self.target);
-
-        let cargo_dir = out.join("cargo");
-        t!(fs::create_dir_all(&cargo_dir));
-
-        let index = cargo_dir.join("index.html");
-        let redirect_html = r#"
-            <html>
-                <head>
-                    <meta http-equiv="refresh" content="0; URL='http://doc.crates.io'" />
-                </head>
-            </html>"#;
-
-        println!("Creating cargo book redirect page");
-        t!(t!(File::create(&index)).write_all(redirect_html.as_bytes()));
-    }
-}
-
 fn invoke_rustdoc(builder: &Builder, compiler: Compiler, target: Interned<String>, markdown: &str) {
     let build = builder.build;
     let out = build.doc_out(target);