}
book!(
- Nomicon, "src/doc/book", "nomicon";
+ Nomicon, "src/doc/nomicon", "nomicon";
Reference, "src/doc/reference", "reference";
Rustdoc, "src/doc/rustdoc", "rustdoc";
);
}
}
+#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
+pub struct CargoBook {
+ target: Interned<String>,
+ name: 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/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"),
+ });
+ }
+
+ fn run(self, builder: &Builder) {
+ let build = builder.build;
+
+ let target = self.target;
+ let name = self.name;
+ let src = build.src.join("src/tools/cargo/src/doc/book");
+
+ 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>,
///
/// * Book (first edition)
/// * Book (second edition)
+ /// * Version info and CSS
/// * Index page
/// * Redirect pages
fn run(self, builder: &Builder) {
let build = builder.build;
+ let compiler = self.compiler;
let target = self.target;
let name = self.name;
// build book first edition
name: INTERNER.intern_string(format!("{}/second-edition", name)),
});
+ // build the version info page and CSS
+ builder.ensure(Standalone {
+ compiler,
+ target,
+ });
+
// build the index page
let index = format!("{}/index.md", name);
println!("Documenting book index ({})", target);
- invoke_rustdoc(builder, self.compiler, target, &index);
+ invoke_rustdoc(builder, compiler, target, &index);
// build the redirect pages
println!("Documenting book redirect pages ({})", target);
let path = file.path();
let path = path.to_str().unwrap();
- invoke_rustdoc(builder, self.compiler, target, path);
+ invoke_rustdoc(builder, compiler, target, path);
}
}
}
-#[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);
let favicon = build.src.join("src/doc/favicon.inc");
let footer = build.src.join("src/doc/footer.inc");
-
- let version_input = build.src.join("src/doc/version_info.html.template");
let version_info = out.join("version_info.html");
- if !up_to_date(&version_input, &version_info) {
- let mut info = String::new();
- t!(t!(File::open(&version_input)).read_to_string(&mut info));
- let info = info.replace("VERSION", &build.rust_release())
- .replace("SHORT_HASH", build.rust_info.sha_short().unwrap_or(""))
- .replace("STAMP", build.rust_info.sha().unwrap_or(""));
- t!(t!(File::create(&version_info)).write_all(info.as_bytes()));
- }
-
let mut cmd = builder.rustdoc_cmd(compiler.host);
let out = out.join("book");
- t!(fs::copy(build.src.join("src/doc/rust.css"), out.join("rust.css")));
-
cmd.arg("--html-after-content").arg(&footer)
.arg("--html-before-content").arg(&version_info)
.arg("--html-in-header").arg(&favicon)
.arg("-o").arg(&out)
.arg(&path)
.arg("--markdown-css")
- .arg("rust.css");
+ .arg("../rust.css");
build.run(&mut cmd);
}
// for which docs must be built.
if !build.config.compiler_docs {
cargo.arg("--no-deps");
- for krate in &["alloc", "collections", "core", "std", "std_unicode"] {
+ for krate in &["alloc", "core", "std", "std_unicode"] {
cargo.arg("-p").arg(krate);
// Create all crate output directories first to make sure rustdoc uses
// relative links.
compile::rustc_cargo(build, &compiler, target, &mut cargo);
if build.config.compiler_docs {
- // src/rustc/Cargo.toml contains bin crates called rustc and rustdoc
- // which would otherwise overwrite the docs for the real rustc and
- // rustdoc lib crates.
- cargo.arg("-p").arg("rustc_driver")
- .arg("-p").arg("rustdoc");
+ // src/rustc/Cargo.toml contains a bin crate called rustc which
+ // would otherwise overwrite the docs for the real rustc lib crate.
+ cargo.arg("-p").arg("rustc_driver");
} else {
// Like with libstd above if compiler docs aren't enabled then we're not
// documenting internal dependencies, so we have a whitelist.