Skip to content

Commit 8372e11

Browse files
committed
build book index
1 parent 65cc839 commit 8372e11

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

src/bootstrap/doc.rs

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,58 @@ pub fn rustbook(build: &Build, target: &str, name: &str) {
5353
.arg(out));
5454
}
5555

56+
/// Build the book and associated stuff.
57+
///
58+
/// We need to build:
59+
///
60+
/// * Book (first edition)
61+
/// * Book (second edition)
62+
/// * Index page
63+
/// * Redirect pages
5664
pub fn book(build: &Build, target: &str, name: &str) {
65+
// build book first edition
5766
rustbook(build, target, &format!("{}/first-edition", name));
67+
68+
// build book second edition
5869
rustbook(build, target, &format!("{}/second-edition", name));
70+
71+
// build the index page
72+
let index = format!("{}/index.md", name);
73+
invoke_rustdoc(build, target, &index);
74+
}
75+
76+
fn invoke_rustdoc(build: &Build, target: &str, markdown: &str) {
77+
let out = build.doc_out(target);
78+
79+
let compiler = Compiler::new(0, &build.config.build);
80+
81+
let path = build.src.join("src/doc").join(markdown);
82+
83+
let rustdoc = build.rustdoc(&compiler);
84+
85+
let favicon = build.src.join("src/doc/favicon.inc");
86+
let footer = build.src.join("src/doc/footer.inc");
87+
t!(fs::copy(build.src.join("src/doc/rust.css"), out.join("rust.css")));
88+
89+
let version_info = out.join("version_info.html");
90+
91+
let mut cmd = Command::new(&rustdoc);
92+
93+
build.add_rustc_lib_path(&compiler, &mut cmd);
94+
95+
let out = out.join("book");
96+
97+
cmd.arg("--html-after-content").arg(&footer)
98+
.arg("--html-before-content").arg(&version_info)
99+
.arg("--html-in-header").arg(&favicon)
100+
.arg("--markdown-playground-url")
101+
.arg("https://play.rust-lang.org/")
102+
.arg("-o").arg(&out)
103+
.arg(&path)
104+
.arg("--markdown-css")
105+
.arg("rust.css");
106+
107+
build.run(&mut cmd);
59108
}
60109

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

0 commit comments

Comments
 (0)