Skip to content

Commit

Permalink
Auto merge of #40693 - frewsxcv:rollup, r=frewsxcv
Browse files Browse the repository at this point in the history
Rollup of 10 pull requests

- Successful merges: #40229, #40312, #40332, #40502, #40556, #40576, #40667, #40671, #40681, #40685
- Failed merges:
  • Loading branch information
bors committed Mar 21, 2017
2 parents 53eb08b + b6240e5 commit 58c701f
Show file tree
Hide file tree
Showing 125 changed files with 874 additions and 17,908 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Expand Up @@ -27,3 +27,6 @@
[submodule "reference"]
path = src/doc/reference
url = https://github.com/rust-lang-nursery/reference.git
[submodule "book"]
path = src/doc/book
url = https://github.com/rust-lang/book
10 changes: 10 additions & 0 deletions src/bootstrap/check.rs
Expand Up @@ -285,6 +285,16 @@ pub fn docs(build: &Build, compiler: &Compiler) {
continue
}

// The nostarch directory in the book is for no starch, and so isn't guaranteed to build.
// we don't care if it doesn't build, so skip it.
use std::ffi::OsStr;
let path: &OsStr = p.as_ref();
if let Some(path) = path.to_str() {
if path.contains("nostarch") {
continue;
}
}

println!("doc tests for: {}", p.display());
markdown_test(build, compiler, &p);
}
Expand Down
4 changes: 2 additions & 2 deletions src/bootstrap/config.toml.example
Expand Up @@ -88,11 +88,11 @@
# for each target triple.
#target = ["x86_64-unknown-linux-gnu"] # defaults to just the build triple

# Instead of downloading the src/nightlies.txt version of Cargo specified, use
# Instead of downloading the src/stage0.txt version of Cargo specified, use
# this Cargo binary instead to build all Rust code
#cargo = "/path/to/bin/cargo"

# Instead of downloading the src/nightlies.txt version of the compiler
# Instead of downloading the src/stage0.txt version of the compiler
# specified, use this rustc binary instead as the stage0 snapshot compiler.
#rustc = "/path/to/bin/rustc"

Expand Down
76 changes: 76 additions & 0 deletions src/bootstrap/doc.rs
Expand Up @@ -53,6 +53,82 @@ 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);
println!("Documenting book index ({})", target);
invoke_rustdoc(build, target, &index);

// build the redirect pages
println!("Documenting book redirect pages ({})", target);
for file in t!(fs::read_dir(build.src.join("src/doc/book/redirects"))) {
let file = t!(file);
let path = file.path();
let path = path.to_str().unwrap();

invoke_rustdoc(build, target, path);
}
}

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");

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 = Command::new(&rustdoc);

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

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("--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`
/// for the `target` into `out`.
///
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/step.rs
Expand Up @@ -581,7 +581,7 @@ pub fn build_rules<'a>(build: &'a Build) -> Rules {
.stage(0)
})
.default(build.config.docs)
.run(move |s| doc::rustbook(build, s.target, "book"));
.run(move |s| doc::book(build, s.target, "book"));
rules.doc("doc-nomicon", "src/doc/nomicon")
.dep(move |s| {
s.name("tool-rustbook")
Expand Down
1 change: 1 addition & 0 deletions src/doc/book
Submodule book added at e6d6ca
39 changes: 0 additions & 39 deletions src/doc/book/src/README.md

This file was deleted.

60 changes: 0 additions & 60 deletions src/doc/book/src/SUMMARY.md

This file was deleted.

0 comments on commit 58c701f

Please sign in to comment.