diff options
Diffstat (limited to 'src/bootstrap/doc.rs')
| -rw-r--r-- | src/bootstrap/doc.rs | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/bootstrap/doc.rs b/src/bootstrap/doc.rs index 5ade2c279e2..86f5346bea1 100644 --- a/src/bootstrap/doc.rs +++ b/src/bootstrap/doc.rs @@ -240,6 +240,51 @@ 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); |
