diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2016-03-07 23:15:55 -0800 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2016-03-08 13:44:14 -0800 |
| commit | defd1b3392df2434ae67e0885cba16cdb9a2d5b4 (patch) | |
| tree | acb72878bdac6b7778fa25dfcff2b2adbab81b25 /src/bootstrap | |
| parent | f7b7535fd7cc4df3c137c5ce05bcd9817e8e006c (diff) | |
| download | rust-defd1b3392df2434ae67e0885cba16cdb9a2d5b4.tar.gz rust-defd1b3392df2434ae67e0885cba16cdb9a2d5b4.zip | |
rustbuild: Add a link checker for documentation
Add a script to get run which verifies that `href` links in documents are correct. We're always getting a steady stream of "fix a broken link" PRs and issue reports, and we should probably just nip them all in the bud.
Diffstat (limited to 'src/bootstrap')
| -rw-r--r-- | src/bootstrap/bootstrap.py | 3 | ||||
| -rw-r--r-- | src/bootstrap/build/check.rs | 21 | ||||
| -rw-r--r-- | src/bootstrap/build/mod.rs | 8 | ||||
| -rw-r--r-- | src/bootstrap/build/step.rs | 14 |
4 files changed, 44 insertions, 2 deletions
diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py index 6659894a171..5de7e6957c6 100644 --- a/src/bootstrap/bootstrap.py +++ b/src/bootstrap/bootstrap.py @@ -73,7 +73,8 @@ class RustBuild: if self.rustc().startswith(self.bin_root()) and \ (not os.path.exists(self.rustc()) or self.rustc_out_of_date()): - shutil.rmtree(self.bin_root()) + if os.path.exists(self.bin_root()): + shutil.rmtree(self.bin_root()) filename = "rust-std-nightly-" + self.build + ".tar.gz" url = "https://static.rust-lang.org/dist/" + self.snap_rustc_date() tarball = os.path.join(rustc_cache, filename) diff --git a/src/bootstrap/build/check.rs b/src/bootstrap/build/check.rs new file mode 100644 index 00000000000..19293e80217 --- /dev/null +++ b/src/bootstrap/build/check.rs @@ -0,0 +1,21 @@ +// Copyright 2016 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. + +use std::process::Command; + +use build::{Build, Compiler}; + +pub fn linkcheck(build: &Build, stage: u32, host: &str) { + println!("Linkcheck stage{} ({})", stage, host); + let compiler = Compiler::new(stage, host); + let linkchecker = build.tool(&compiler, "linkchecker"); + build.run(Command::new(&linkchecker) + .arg(build.out.join(host).join("doc"))); +} diff --git a/src/bootstrap/build/mod.rs b/src/bootstrap/build/mod.rs index 825cca6563c..9f24fba5843 100644 --- a/src/bootstrap/build/mod.rs +++ b/src/bootstrap/build/mod.rs @@ -30,6 +30,7 @@ macro_rules! t { mod cc; mod channel; +mod check; mod clean; mod compile; mod config; @@ -171,6 +172,9 @@ impl Build { Rustc { stage } => { compile::assemble_rustc(self, stage, target.target); } + ToolLinkchecker { stage } => { + compile::tool(self, stage, target.target, "linkchecker"); + } ToolRustbook { stage } => { compile::tool(self, stage, target.target, "rustbook"); } @@ -195,6 +199,10 @@ impl Build { doc::rustc(self, stage, target.target, &doc_out); } + CheckLinkcheck { stage } => { + check::linkcheck(self, stage, target.target); + } + Doc { .. } | // pseudo-steps Check { .. } => {} } diff --git a/src/bootstrap/build/step.rs b/src/bootstrap/build/step.rs index 23c678df9ac..7921edcff55 100644 --- a/src/bootstrap/build/step.rs +++ b/src/bootstrap/build/step.rs @@ -46,6 +46,7 @@ macro_rules! targets { }), // Various tools that we can build as part of the build. + (tool_linkchecker, ToolLinkchecker { stage: u32 }), (tool_rustbook, ToolRustbook { stage: u32 }), // Steps for long-running native builds. Ideally these wouldn't @@ -71,6 +72,7 @@ macro_rules! targets { // Steps for running tests. The 'check' target is just a pseudo // target to depend on a bunch of others. (check, Check { stage: u32, compiler: Compiler<'a> }), + (check_linkcheck, CheckLinkcheck { stage: u32 }), } } } @@ -200,6 +202,8 @@ fn add_steps<'a>(build: &'a Build, } targets!(add_step); + + panic!("unknown step: {}", step); } } @@ -273,7 +277,15 @@ impl<'a> Step<'a> { self.doc_std(stage)] } Source::Check { stage, compiler: _ } => { - vec![] + vec![self.check_linkcheck(stage)] + } + Source::CheckLinkcheck { stage } => { + vec![self.tool_linkchecker(stage), self.doc(stage)] + } + + Source::ToolLinkchecker { stage } => { + vec![self.libstd(stage, self.compiler(stage))] + } Source::ToolRustbook { stage } => { vec![self.librustc(stage, self.compiler(stage))] } |
