Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autogenerate stubs and SUMMARY.md in the unstable book #42612

Merged
merged 5 commits into from
Jun 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ members = [
"tools/error_index_generator",
"tools/linkchecker",
"tools/rustbook",
"tools/unstable-book-gen",
"tools/tidy",
"tools/build-manifest",
"tools/remote-test-client",
Expand Down
27 changes: 24 additions & 3 deletions src/bootstrap/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,26 @@ use {Build, Compiler, Mode};
use util::{cp_r, symlink_dir};
use build_helper::up_to_date;

/// Invoke `rustbook` as compiled in `stage` for `target` for the doc book
/// `name` into the `out` path.
/// Invoke `rustbook` for `target` for the doc book `name`.
///
/// This will not actually generate any documentation if the documentation has
/// already been generated.
pub fn rustbook(build: &Build, target: &str, name: &str) {
let src = build.src.join("src/doc");
rustbook_src(build, target, name, &src);
}

/// Invoke `rustbook` for `target` for the doc book `name` from the `src` path.
///
/// This will not actually generate any documentation if the documentation has
/// already been generated.
pub fn rustbook_src(build: &Build, target: &str, name: &str, src: &Path) {
let out = build.doc_out(target);
t!(fs::create_dir_all(&out));

let out = out.join(name);
let compiler = Compiler::new(0, &build.config.build);
let src = build.src.join("src/doc").join(name);
let src = src.join(name);
let index = out.join("index.html");
let rustbook = build.tool(&compiler, "rustbook");
if up_to_date(&src, &index) && up_to_date(&rustbook, &index) {
Expand Down Expand Up @@ -354,6 +362,19 @@ pub fn error_index(build: &Build, target: &str) {
build.run(&mut index);
}

pub fn unstable_book_gen(build: &Build, target: &str) {
println!("Generating unstable book md files ({})", target);
let out = build.md_doc_out(target).join("unstable-book");
t!(fs::create_dir_all(&out));
t!(fs::remove_dir_all(&out));
let compiler = Compiler::new(0, &build.config.build);
let mut cmd = build.tool_cmd(&compiler, "unstable-book-gen");
cmd.arg(build.src.join("src"));
cmd.arg(out);

build.run(&mut cmd);
}

fn symlink_dir_force(src: &Path, dst: &Path) -> io::Result<()> {
if let Ok(m) = fs::symlink_metadata(dst) {
if m.file_type().is_dir() {
Expand Down
5 changes: 5 additions & 0 deletions src/bootstrap/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,11 @@ impl Build {
self.out.join(target).join("doc")
}

/// Output directory for some generated md crate documentation for a target (temporary)
fn md_doc_out(&self, target: &str) -> PathBuf {
self.out.join(target).join("md-doc")
}

/// Output directory for all crate documentation for a target (temporary)
///
/// The artifacts here are then copied into `doc_out` above.
Expand Down
21 changes: 20 additions & 1 deletion src/bootstrap/step.rs
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,10 @@ pub fn build_rules<'a>(build: &'a Build) -> Rules {
.dep(|s| s.name("maybe-clean-tools"))
.dep(|s| s.name("librustc-tool"))
.run(move |s| compile::tool(build, s.stage, s.target, "error_index_generator"));
rules.build("tool-unstable-book-gen", "src/tools/unstable-book-gen")
.dep(|s| s.name("maybe-clean-tools"))
.dep(|s| s.name("libstd-tool"))
.run(move |s| compile::tool(build, s.stage, s.target, "unstable-book-gen"));
rules.build("tool-tidy", "src/tools/tidy")
.dep(|s| s.name("maybe-clean-tools"))
.dep(|s| s.name("libstd-tool"))
Expand Down Expand Up @@ -662,8 +666,12 @@ pub fn build_rules<'a>(build: &'a Build) -> Rules {
.target(&build.config.build)
.stage(0)
})
.dep(move |s| s.name("doc-unstable-book-gen"))
.default(build.config.docs)
.run(move |s| doc::rustbook(build, s.target, "unstable-book"));
.run(move |s| doc::rustbook_src(build,
s.target,
"unstable-book",
&build.md_doc_out(s.target)));
rules.doc("doc-standalone", "src/doc")
.dep(move |s| {
s.name("rustc")
Expand All @@ -679,6 +687,17 @@ pub fn build_rules<'a>(build: &'a Build) -> Rules {
.default(build.config.docs)
.host(true)
.run(move |s| doc::error_index(build, s.target));
rules.doc("doc-unstable-book-gen", "src/tools/unstable-book-gen")
.dep(move |s| {
s.name("tool-unstable-book-gen")
.host(&build.config.build)
.target(&build.config.build)
.stage(0)
})
.dep(move |s| s.name("libstd-link"))
.default(build.config.docs)
.host(true)
.run(move |s| doc::unstable_book_gen(build, s.target));
for (krate, path, default) in krates("std") {
rules.doc(&krate.doc_step, path)
.dep(|s| s.name("libstd-link"))
Expand Down
7 changes: 0 additions & 7 deletions src/doc/unstable-book/src/language-features/abi-sysv64.md

This file was deleted.

6 changes: 0 additions & 6 deletions src/doc/unstable-book/src/language-features/abi-unadjusted.md

This file was deleted.

7 changes: 0 additions & 7 deletions src/doc/unstable-book/src/language-features/abi-vectorcall.md

This file was deleted.

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion src/doc/unstable-book/src/language-features/asm.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,4 +190,4 @@ constraints, etc.
[llvm-docs]: http://llvm.org/docs/LangRef.html#inline-assembler-expressions

If you need more power and don't mind losing some of the niceties of
`asm!`, check out [global_asm](language-features/global_asm.html).
`asm!`, check out [global_asm](language-features/global-asm.html).

This file was deleted.

10 changes: 0 additions & 10 deletions src/doc/unstable-book/src/language-features/cfg-target-feature.md

This file was deleted.

This file was deleted.

This file was deleted.

10 changes: 0 additions & 10 deletions src/doc/unstable-book/src/language-features/cfg-target-vendor.md

This file was deleted.

10 changes: 0 additions & 10 deletions src/doc/unstable-book/src/language-features/custom-attribute.md

This file was deleted.

10 changes: 0 additions & 10 deletions src/doc/unstable-book/src/language-features/custom-derive.md

This file was deleted.

10 changes: 0 additions & 10 deletions src/doc/unstable-book/src/language-features/decl-macro.md

This file was deleted.

This file was deleted.

10 changes: 0 additions & 10 deletions src/doc/unstable-book/src/language-features/drop-types-in-const.md

This file was deleted.

10 changes: 0 additions & 10 deletions src/doc/unstable-book/src/language-features/dropck-eyepatch.md

This file was deleted.

This file was deleted.

This file was deleted.

10 changes: 0 additions & 10 deletions src/doc/unstable-book/src/language-features/fundamental.md

This file was deleted.

10 changes: 0 additions & 10 deletions src/doc/unstable-book/src/language-features/generic-param-attrs.md

This file was deleted.

10 changes: 0 additions & 10 deletions src/doc/unstable-book/src/language-features/link-cfg.md

This file was deleted.

This file was deleted.

10 changes: 0 additions & 10 deletions src/doc/unstable-book/src/language-features/linkage.md

This file was deleted.

10 changes: 0 additions & 10 deletions src/doc/unstable-book/src/language-features/log-syntax.md

This file was deleted.

10 changes: 0 additions & 10 deletions src/doc/unstable-book/src/language-features/macro-reexport.md

This file was deleted.

Loading