Skip to content

Commit

Permalink
build book index
Browse files Browse the repository at this point in the history
  • Loading branch information
steveklabnik committed Mar 20, 2017
1 parent 8573a13 commit 5f2f3d0
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions src/bootstrap/doc.rs
Expand Up @@ -53,9 +53,58 @@ pub fn rustbook(build: &Build, target: &str, name: &str) {
.arg(out));
}

/// Build the book and associated stuff.
///
/// We need to build:
///
/// * Book (first edition)
/// * Book (second edition)
/// * Index page
/// * Redirect pages
pub fn book(build: &Build, target: &str, name: &str) {
// build book first edition
rustbook(build, target, &format!("{}/first-edition", name));

// build book second edition
rustbook(build, target, &format!("{}/second-edition", name));

// build the index page
let index = format!("{}/index.md", name);
invoke_rustdoc(build, target, &index);
}

fn invoke_rustdoc(build: &Build, target: &str, markdown: &str) {
let out = build.doc_out(target);

let compiler = Compiler::new(0, &build.config.build);

let path = build.src.join("src/doc").join(markdown);

let rustdoc = build.rustdoc(&compiler);

let favicon = build.src.join("src/doc/favicon.inc");
let footer = build.src.join("src/doc/footer.inc");
t!(fs::copy(build.src.join("src/doc/rust.css"), out.join("rust.css")));

let version_info = out.join("version_info.html");

let mut cmd = Command::new(&rustdoc);

build.add_rustc_lib_path(&compiler, &mut cmd);

let out = out.join("book");

cmd.arg("--html-after-content").arg(&footer)
.arg("--html-before-content").arg(&version_info)
.arg("--html-in-header").arg(&favicon)
.arg("--markdown-playground-url")
.arg("https://play.rust-lang.org/")
.arg("-o").arg(&out)
.arg(&path)
.arg("--markdown-css")
.arg("rust.css");

build.run(&mut cmd);
}

/// Generates all standalone documentation as compiled by the rustdoc in `stage`
Expand Down

0 comments on commit 5f2f3d0

Please sign in to comment.