1 // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 //! Documentation generation for rustbuilder.
13 //! This module implements generation for all bits and pieces of documentation
14 //! for the Rust project. This notably includes suites like the rust book, the
15 //! nomicon, rust by example, standalone documentation, etc.
17 //! Everything here is basically just a shim around calling either `rustbook` or
20 use std::collections::HashSet;
21 use std::fs::{self, File};
22 use std::io::prelude::*;
24 use std::path::{PathBuf, Path};
27 use build_helper::up_to_date;
29 use util::symlink_dir;
30 use builder::{Builder, Compiler, RunConfig, ShouldRun, Step};
31 use tool::{self, prepare_tool_cargo, Tool, SourceType};
33 use cache::{INTERNER, Interned};
37 ($($name:ident, $path:expr, $book_name:expr;)+) => {
39 #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
41 target: Interned<String>,
46 const DEFAULT: bool = true;
48 fn should_run(run: ShouldRun) -> ShouldRun {
49 let builder = run.builder;
50 run.path($path).default_condition(builder.config.docs)
53 fn make_run(run: RunConfig) {
54 run.builder.ensure($name {
59 fn run(self, builder: &Builder) {
60 builder.ensure(Rustbook {
62 name: INTERNER.intern_str($book_name),
71 Nomicon, "src/doc/nomicon", "nomicon";
72 Reference, "src/doc/reference", "reference";
73 RustdocBook, "src/doc/rustdoc", "rustdoc";
74 RustcBook, "src/doc/rustc", "rustc";
75 RustByExample, "src/doc/rust-by-example", "rust-by-example";
78 #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
80 target: Interned<String>,
81 name: Interned<String>,
84 impl Step for Rustbook {
87 // rustbook is never directly called, and only serves as a shim for the nomicon and the
89 fn should_run(run: ShouldRun) -> ShouldRun {
93 /// Invoke `rustbook` for `target` for the doc book `name`.
95 /// This will not actually generate any documentation if the documentation has
96 /// already been generated.
97 fn run(self, builder: &Builder) {
98 let src = builder.src.join("src/doc");
99 builder.ensure(RustbookSrc {
102 src: INTERNER.intern_path(src),
107 #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
108 pub struct UnstableBook {
109 target: Interned<String>,
112 impl Step for UnstableBook {
114 const DEFAULT: bool = true;
116 fn should_run(run: ShouldRun) -> ShouldRun {
117 let builder = run.builder;
118 run.path("src/doc/unstable-book").default_condition(builder.config.docs)
121 fn make_run(run: RunConfig) {
122 run.builder.ensure(UnstableBook {
127 fn run(self, builder: &Builder) {
128 builder.ensure(UnstableBookGen {
131 builder.ensure(RustbookSrc {
133 name: INTERNER.intern_str("unstable-book"),
134 src: builder.md_doc_out(self.target),
139 #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
140 pub struct CargoBook {
141 target: Interned<String>,
142 name: Interned<String>,
145 impl Step for CargoBook {
147 const DEFAULT: bool = true;
149 fn should_run(run: ShouldRun) -> ShouldRun {
150 let builder = run.builder;
151 run.path("src/tools/cargo/src/doc/book").default_condition(builder.config.docs)
154 fn make_run(run: RunConfig) {
155 run.builder.ensure(CargoBook {
157 name: INTERNER.intern_str("cargo"),
161 fn run(self, builder: &Builder) {
162 let target = self.target;
163 let name = self.name;
164 let src = builder.src.join("src/tools/cargo/src/doc");
166 let out = builder.doc_out(target);
167 t!(fs::create_dir_all(&out));
169 let out = out.join(name);
171 builder.info(&format!("Cargo Book ({}) - {}", target, name));
173 let _ = fs::remove_dir_all(&out);
175 builder.run(builder.tool_cmd(Tool::Rustbook)
183 #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
185 target: Interned<String>,
186 name: Interned<String>,
187 src: Interned<PathBuf>,
190 impl Step for RustbookSrc {
193 fn should_run(run: ShouldRun) -> ShouldRun {
197 /// Invoke `rustbook` for `target` for the doc book `name` from the `src` path.
199 /// This will not actually generate any documentation if the documentation has
200 /// already been generated.
201 fn run(self, builder: &Builder) {
202 let target = self.target;
203 let name = self.name;
205 let out = builder.doc_out(target);
206 t!(fs::create_dir_all(&out));
208 let out = out.join(name);
209 let src = src.join(name);
210 let index = out.join("index.html");
211 let rustbook = builder.tool_exe(Tool::Rustbook);
212 let mut rustbook_cmd = builder.tool_cmd(Tool::Rustbook);
213 if up_to_date(&src, &index) && up_to_date(&rustbook, &index) {
216 builder.info(&format!("Rustbook ({}) - {}", target, name));
217 let _ = fs::remove_dir_all(&out);
218 builder.run(rustbook_cmd
226 #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
229 target: Interned<String>,
233 impl Step for TheBook {
235 const DEFAULT: bool = true;
237 fn should_run(run: ShouldRun) -> ShouldRun {
238 let builder = run.builder;
239 run.path("src/doc/book").default_condition(builder.config.docs)
242 fn make_run(run: RunConfig) {
243 run.builder.ensure(TheBook {
244 compiler: run.builder.compiler(run.builder.top_stage, run.builder.config.build),
250 /// Build the book and associated stuff.
252 /// We need to build:
254 /// * Book (first edition)
255 /// * Book (second edition)
256 /// * Version info and CSS
259 fn run(self, builder: &Builder) {
260 let compiler = self.compiler;
261 let target = self.target;
262 let name = self.name;
263 // build book first edition
264 builder.ensure(Rustbook {
266 name: INTERNER.intern_string(format!("{}/first-edition", name)),
269 // build book second edition
270 builder.ensure(Rustbook {
272 name: INTERNER.intern_string(format!("{}/second-edition", name)),
275 // build book 2018 edition
276 builder.ensure(Rustbook {
278 name: INTERNER.intern_string(format!("{}/2018-edition", name)),
281 // build the version info page and CSS
282 builder.ensure(Standalone {
287 // build the index page
288 let index = format!("{}/index.md", name);
289 builder.info(&format!("Documenting book index ({})", target));
290 invoke_rustdoc(builder, compiler, target, &index);
292 // build the redirect pages
293 builder.info(&format!("Documenting book redirect pages ({})", target));
294 for file in t!(fs::read_dir(builder.src.join("src/doc/book/redirects"))) {
296 let path = file.path();
297 let path = path.to_str().unwrap();
299 invoke_rustdoc(builder, compiler, target, path);
304 fn invoke_rustdoc(builder: &Builder, compiler: Compiler, target: Interned<String>, markdown: &str) {
305 let out = builder.doc_out(target);
307 let path = builder.src.join("src/doc").join(markdown);
309 let favicon = builder.src.join("src/doc/favicon.inc");
310 let footer = builder.src.join("src/doc/footer.inc");
311 let version_info = out.join("version_info.html");
313 let mut cmd = builder.rustdoc_cmd(compiler.host);
315 let out = out.join("book");
317 cmd.arg("--html-after-content").arg(&footer)
318 .arg("--html-before-content").arg(&version_info)
319 .arg("--html-in-header").arg(&favicon)
320 .arg("--markdown-no-toc")
321 .arg("--markdown-playground-url")
322 .arg("https://play.rust-lang.org/")
325 .arg("--markdown-css")
328 builder.run(&mut cmd);
331 #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
332 pub struct Standalone {
334 target: Interned<String>,
337 impl Step for Standalone {
339 const DEFAULT: bool = true;
341 fn should_run(run: ShouldRun) -> ShouldRun {
342 let builder = run.builder;
343 run.path("src/doc").default_condition(builder.config.docs)
346 fn make_run(run: RunConfig) {
347 run.builder.ensure(Standalone {
348 compiler: run.builder.compiler(run.builder.top_stage, run.builder.config.build),
353 /// Generates all standalone documentation as compiled by the rustdoc in `stage`
354 /// for the `target` into `out`.
356 /// This will list all of `src/doc` looking for markdown files and appropriately
357 /// perform transformations like substituting `VERSION`, `SHORT_HASH`, and
358 /// `STAMP` along with providing the various header/footer HTML we've customized.
360 /// In the end, this is just a glorified wrapper around rustdoc!
361 fn run(self, builder: &Builder) {
362 let target = self.target;
363 let compiler = self.compiler;
364 builder.info(&format!("Documenting standalone ({})", target));
365 let out = builder.doc_out(target);
366 t!(fs::create_dir_all(&out));
368 let favicon = builder.src.join("src/doc/favicon.inc");
369 let footer = builder.src.join("src/doc/footer.inc");
370 let full_toc = builder.src.join("src/doc/full-toc.inc");
371 t!(fs::copy(builder.src.join("src/doc/rust.css"), out.join("rust.css")));
373 let version_input = builder.src.join("src/doc/version_info.html.template");
374 let version_info = out.join("version_info.html");
376 if !builder.config.dry_run && !up_to_date(&version_input, &version_info) {
377 let mut info = String::new();
378 t!(t!(File::open(&version_input)).read_to_string(&mut info));
379 let info = info.replace("VERSION", &builder.rust_release())
380 .replace("SHORT_HASH", builder.rust_info.sha_short().unwrap_or(""))
381 .replace("STAMP", builder.rust_info.sha().unwrap_or(""));
382 t!(t!(File::create(&version_info)).write_all(info.as_bytes()));
385 for file in t!(fs::read_dir(builder.src.join("src/doc"))) {
387 let path = file.path();
388 let filename = path.file_name().unwrap().to_str().unwrap();
389 if !filename.ends_with(".md") || filename == "README.md" {
393 let html = out.join(filename).with_extension("html");
394 let rustdoc = builder.rustdoc(compiler.host);
395 if up_to_date(&path, &html) &&
396 up_to_date(&footer, &html) &&
397 up_to_date(&favicon, &html) &&
398 up_to_date(&full_toc, &html) &&
399 up_to_date(&version_info, &html) &&
400 (builder.config.dry_run || up_to_date(&rustdoc, &html)) {
404 let mut cmd = builder.rustdoc_cmd(compiler.host);
405 cmd.arg("--html-after-content").arg(&footer)
406 .arg("--html-before-content").arg(&version_info)
407 .arg("--html-in-header").arg(&favicon)
408 .arg("--markdown-playground-url")
409 .arg("https://play.rust-lang.org/")
413 if filename == "not_found.md" {
414 cmd.arg("--markdown-no-toc")
415 .arg("--markdown-css")
416 .arg("https://doc.rust-lang.org/rust.css");
418 cmd.arg("--markdown-css").arg("rust.css");
420 builder.run(&mut cmd);
425 #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
428 pub target: Interned<String>,
433 const DEFAULT: bool = true;
435 fn should_run(run: ShouldRun) -> ShouldRun {
436 let builder = run.builder;
437 run.all_krates("std").default_condition(builder.config.docs)
440 fn make_run(run: RunConfig) {
441 run.builder.ensure(Std {
442 stage: run.builder.top_stage,
447 /// Compile all standard library documentation.
449 /// This will generate all documentation for the standard library and its
450 /// dependencies. This is largely just a wrapper around `cargo doc`.
451 fn run(self, builder: &Builder) {
452 let stage = self.stage;
453 let target = self.target;
454 builder.info(&format!("Documenting stage{} std ({})", stage, target));
455 let out = builder.doc_out(target);
456 t!(fs::create_dir_all(&out));
457 let compiler = builder.compiler(stage, builder.config.build);
458 let compiler = if builder.force_use_stage1(compiler, target) {
459 builder.compiler(1, compiler.host)
464 builder.ensure(compile::Std { compiler, target });
465 let out_dir = builder.stage_out(compiler, Mode::Std)
466 .join(target).join("doc");
468 // Here what we're doing is creating a *symlink* (directory junction on
469 // Windows) to the final output location. This is not done as an
470 // optimization but rather for correctness. We've got three trees of
471 // documentation, one for std, one for test, and one for rustc. It's then
472 // our job to merge them all together.
474 // Unfortunately rustbuild doesn't know nearly as well how to merge doc
475 // trees as rustdoc does itself, so instead of actually having three
476 // separate trees we just have rustdoc output to the same location across
479 // This way rustdoc generates output directly into the output, and rustdoc
480 // will also directly handle merging.
481 let my_out = builder.crate_doc_out(target);
482 t!(symlink_dir_force(&builder.config, &my_out, &out_dir));
484 let mut cargo = builder.cargo(compiler, Mode::Std, target, "doc");
485 compile::std_cargo(builder, &compiler, target, &mut cargo);
487 // Keep a whitelist so we do not build internal stdlib crates, these will be
488 // build by the rustc step later if enabled.
489 cargo.arg("--no-deps");
490 for krate in &["alloc", "core", "std"] {
491 cargo.arg("-p").arg(krate);
492 // Create all crate output directories first to make sure rustdoc uses
494 // FIXME: Cargo should probably do this itself.
495 t!(fs::create_dir_all(out_dir.join(krate)));
498 builder.run(&mut cargo);
499 builder.cp_r(&my_out, &out);
503 #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
506 target: Interned<String>,
511 const DEFAULT: bool = true;
513 fn should_run(run: ShouldRun) -> ShouldRun {
514 let builder = run.builder;
515 run.krate("test").default_condition(builder.config.docs)
518 fn make_run(run: RunConfig) {
519 run.builder.ensure(Test {
520 stage: run.builder.top_stage,
525 /// Compile all libtest documentation.
527 /// This will generate all documentation for libtest and its dependencies. This
528 /// is largely just a wrapper around `cargo doc`.
529 fn run(self, builder: &Builder) {
530 let stage = self.stage;
531 let target = self.target;
532 builder.info(&format!("Documenting stage{} test ({})", stage, target));
533 let out = builder.doc_out(target);
534 t!(fs::create_dir_all(&out));
535 let compiler = builder.compiler(stage, builder.config.build);
536 let compiler = if builder.force_use_stage1(compiler, target) {
537 builder.compiler(1, compiler.host)
542 // Build libstd docs so that we generate relative links
543 builder.ensure(Std { stage, target });
545 builder.ensure(compile::Test { compiler, target });
546 let out_dir = builder.stage_out(compiler, Mode::Test)
547 .join(target).join("doc");
549 // See docs in std above for why we symlink
550 let my_out = builder.crate_doc_out(target);
551 t!(symlink_dir_force(&builder.config, &my_out, &out_dir));
553 let mut cargo = builder.cargo(compiler, Mode::Test, target, "doc");
554 compile::test_cargo(builder, &compiler, target, &mut cargo);
556 cargo.arg("--no-deps").arg("-p").arg("test");
558 builder.run(&mut cargo);
559 builder.cp_r(&my_out, &out);
563 #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
564 pub struct WhitelistedRustc {
566 target: Interned<String>,
569 impl Step for WhitelistedRustc {
571 const DEFAULT: bool = true;
572 const ONLY_HOSTS: bool = true;
574 fn should_run(run: ShouldRun) -> ShouldRun {
575 let builder = run.builder;
576 run.krate("rustc-main").default_condition(builder.config.docs)
579 fn make_run(run: RunConfig) {
580 run.builder.ensure(WhitelistedRustc {
581 stage: run.builder.top_stage,
586 /// Generate whitelisted compiler crate documentation.
588 /// This will generate all documentation for crates that are whitelisted
589 /// to be included in the standard documentation. This documentation is
590 /// included in the standard Rust documentation, so we should always
591 /// document it and symlink to merge with the rest of the std and test
592 /// documentation. We don't build other compiler documentation
593 /// here as we want to be able to keep it separate from the standard
594 /// documentation. This is largely just a wrapper around `cargo doc`.
595 fn run(self, builder: &Builder) {
596 let stage = self.stage;
597 let target = self.target;
598 builder.info(&format!("Documenting stage{} whitelisted compiler ({})", stage, target));
599 let out = builder.doc_out(target);
600 t!(fs::create_dir_all(&out));
601 let compiler = builder.compiler(stage, builder.config.build);
602 let compiler = if builder.force_use_stage1(compiler, target) {
603 builder.compiler(1, compiler.host)
608 // Build libstd docs so that we generate relative links
609 builder.ensure(Std { stage, target });
611 builder.ensure(compile::Rustc { compiler, target });
612 let out_dir = builder.stage_out(compiler, Mode::Rustc)
613 .join(target).join("doc");
615 // See docs in std above for why we symlink
616 let my_out = builder.crate_doc_out(target);
617 t!(symlink_dir_force(&builder.config, &my_out, &out_dir));
619 let mut cargo = builder.cargo(compiler, Mode::Rustc, target, "doc");
620 compile::rustc_cargo(builder, &mut cargo);
622 // We don't want to build docs for internal compiler dependencies in this
623 // step (there is another step for that). Therefore, we whitelist the crates
624 // for which docs must be built.
625 cargo.arg("--no-deps");
626 for krate in &["proc_macro"] {
627 cargo.arg("-p").arg(krate);
630 builder.run(&mut cargo);
631 builder.cp_r(&my_out, &out);
635 #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
638 target: Interned<String>,
641 impl Step for Rustc {
643 const DEFAULT: bool = true;
644 const ONLY_HOSTS: bool = true;
646 fn should_run(run: ShouldRun) -> ShouldRun {
647 let builder = run.builder;
648 run.krate("rustc-main").default_condition(builder.config.docs)
651 fn make_run(run: RunConfig) {
652 run.builder.ensure(Rustc {
653 stage: run.builder.top_stage,
658 /// Generate compiler documentation.
660 /// This will generate all documentation for compiler and dependencies.
661 /// Compiler documentation is distributed separately, so we make sure
662 /// we do not merge it with the other documentation from std, test and
663 /// proc_macros. This is largely just a wrapper around `cargo doc`.
664 fn run(self, builder: &Builder) {
665 let stage = self.stage;
666 let target = self.target;
667 builder.info(&format!("Documenting stage{} compiler ({})", stage, target));
669 // This is the intended out directory for compiler documentation.
670 let out = builder.compiler_doc_out(target);
671 t!(fs::create_dir_all(&out));
673 // Get the correct compiler for this stage.
674 let compiler = builder.compiler(stage, builder.config.build);
675 let compiler = if builder.force_use_stage1(compiler, target) {
676 builder.compiler(1, compiler.host)
681 if !builder.config.compiler_docs {
682 builder.info("\tskipping - compiler/librustdoc docs disabled");
686 // Build libstd docs so that we generate relative links.
687 builder.ensure(Std { stage, target });
690 builder.ensure(compile::Rustc { compiler, target });
692 // We do not symlink to the same shared folder that already contains std library
693 // documentation from previous steps as we do not want to include that.
694 let out_dir = builder.stage_out(compiler, Mode::Rustc).join(target).join("doc");
695 t!(symlink_dir_force(&builder.config, &out, &out_dir));
697 // Build cargo command.
698 let mut cargo = builder.cargo(compiler, Mode::Rustc, target, "doc");
699 cargo.env("RUSTDOCFLAGS", "--document-private-items");
700 compile::rustc_cargo(builder, &mut cargo);
702 // Only include compiler crates, no dependencies of those, such as `libc`.
703 cargo.arg("--no-deps");
705 // Find dependencies for top level crates.
706 let mut compiler_crates = HashSet::new();
707 for root_crate in &["rustc", "rustc_driver", "rustc_codegen_llvm"] {
708 let interned_root_crate = INTERNER.intern_str(root_crate);
709 find_compiler_crates(builder, &interned_root_crate, &mut compiler_crates);
712 for krate in &compiler_crates {
713 cargo.arg("-p").arg(krate);
716 builder.run(&mut cargo);
720 fn find_compiler_crates(
722 name: &Interned<String>,
723 crates: &mut HashSet<Interned<String>>
725 // Add current crate.
726 crates.insert(*name);
728 // Look for dependencies.
729 for dep in builder.crates.get(name).unwrap().deps.iter() {
730 if builder.crates.get(dep).unwrap().is_local(builder) {
731 find_compiler_crates(builder, dep, crates);
736 #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
739 target: Interned<String>,
742 impl Step for Rustdoc {
744 const DEFAULT: bool = true;
745 const ONLY_HOSTS: bool = true;
747 fn should_run(run: ShouldRun) -> ShouldRun {
748 run.krate("rustdoc-tool")
751 fn make_run(run: RunConfig) {
752 run.builder.ensure(Rustdoc {
753 stage: run.builder.top_stage,
758 /// Generate compiler documentation.
760 /// This will generate all documentation for compiler and dependencies.
761 /// Compiler documentation is distributed separately, so we make sure
762 /// we do not merge it with the other documentation from std, test and
763 /// proc_macros. This is largely just a wrapper around `cargo doc`.
764 fn run(self, builder: &Builder) {
765 let stage = self.stage;
766 let target = self.target;
767 builder.info(&format!("Documenting stage{} rustdoc ({})", stage, target));
769 // This is the intended out directory for compiler documentation.
770 let out = builder.compiler_doc_out(target);
771 t!(fs::create_dir_all(&out));
773 // Get the correct compiler for this stage.
774 let compiler = builder.compiler(stage, builder.config.build);
775 let compiler = if builder.force_use_stage1(compiler, target) {
776 builder.compiler(1, compiler.host)
781 if !builder.config.compiler_docs {
782 builder.info("\tskipping - compiler/librustdoc docs disabled");
786 // Build libstd docs so that we generate relative links.
787 builder.ensure(Std { stage, target });
790 builder.ensure(tool::Rustdoc { host: compiler.host });
792 // Symlink compiler docs to the output directory of rustdoc documentation.
793 let out_dir = builder.stage_out(compiler, Mode::ToolRustc)
796 t!(fs::create_dir_all(&out_dir));
797 t!(symlink_dir_force(&builder.config, &out, &out_dir));
799 // Build cargo command.
800 let mut cargo = prepare_tool_cargo(
811 cargo.env("RUSTDOCFLAGS", "--document-private-items");
812 builder.run(&mut cargo);
816 #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
817 pub struct ErrorIndex {
818 target: Interned<String>,
821 impl Step for ErrorIndex {
823 const DEFAULT: bool = true;
824 const ONLY_HOSTS: bool = true;
826 fn should_run(run: ShouldRun) -> ShouldRun {
827 let builder = run.builder;
828 run.path("src/tools/error_index_generator").default_condition(builder.config.docs)
831 fn make_run(run: RunConfig) {
832 run.builder.ensure(ErrorIndex {
837 /// Generates the HTML rendered error-index by running the
838 /// `error_index_generator` tool.
839 fn run(self, builder: &Builder) {
840 let target = self.target;
842 builder.info(&format!("Documenting error index ({})", target));
843 let out = builder.doc_out(target);
844 t!(fs::create_dir_all(&out));
845 let mut index = builder.tool_cmd(Tool::ErrorIndex);
847 index.arg(out.join("error-index.html"));
849 // FIXME: shouldn't have to pass this env var
850 index.env("CFG_BUILD", &builder.config.build)
851 .env("RUSTC_ERROR_METADATA_DST", builder.extended_error_dir());
853 builder.run(&mut index);
857 #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
858 pub struct UnstableBookGen {
859 target: Interned<String>,
862 impl Step for UnstableBookGen {
864 const DEFAULT: bool = true;
865 const ONLY_HOSTS: bool = true;
867 fn should_run(run: ShouldRun) -> ShouldRun {
868 let builder = run.builder;
869 run.path("src/tools/unstable-book-gen").default_condition(builder.config.docs)
872 fn make_run(run: RunConfig) {
873 run.builder.ensure(UnstableBookGen {
878 fn run(self, builder: &Builder) {
879 let target = self.target;
881 builder.ensure(compile::Std {
882 compiler: builder.compiler(builder.top_stage, builder.config.build),
886 builder.info(&format!("Generating unstable book md files ({})", target));
887 let out = builder.md_doc_out(target).join("unstable-book");
888 builder.create_dir(&out);
889 builder.remove_dir(&out);
890 let mut cmd = builder.tool_cmd(Tool::UnstableBookGen);
891 cmd.arg(builder.src.join("src"));
894 builder.run(&mut cmd);
898 fn symlink_dir_force(config: &Config, src: &Path, dst: &Path) -> io::Result<()> {
902 if let Ok(m) = fs::symlink_metadata(dst) {
903 if m.file_type().is_dir() {
904 try!(fs::remove_dir_all(dst));
906 // handle directory junctions on windows by falling back to
908 try!(fs::remove_file(dst).or_else(|_| {
914 symlink_dir(config, src, dst)