Skip to content

Commit ae3a043

Browse files
committed
Auto merge of #42612 - est31:master, r=<try>
Autogenerate stubs and SUMMARY.md in the unstable book Removes a speed bump in compiler development by autogenerating stubs for features in the unstable book. See #42454 for discussion. The PR contains three commits, separated in order to make review easy: * The first commit converts the tidy tool from a binary crate to a crate that contains both a library and a binary. In the second commit, we'll use the tidy library * The second and main commit introduces autogeneration of SUMMARY.md and feature stub files * The third commit turns off the tidy lint that checks for features without a stub, and removes the stub files. A separate commit due to the large number of files touched Members of the doc team who wish to document some features can either do this (where `$rustsrc` is the root of the rust repo git checkout): 1. cd to `$rustsrc/src/tools/unstable-book-gen` and then do `cargo run $rustsrc/src $rustsrc/src/doc/unstable-book` to put the stubs into the unstable book 2. cd to `$rustsrc` and run `git ls-files --others --exclude-standard` to list the newly added stubs 3. choose a file to edit, then `git add` it and `git commit` 4. afterwards, remove all changes by the tool by doing `git --reset hard` and `git clean -f` Or they can do this: 1. remove the comment marker in `src/tools/tidy/src/unstable_book.rs` line 122 2. run `./x.py test src/tools/tidy` to list the unstable features which only have stubs 3. revert the change in 1 3. document one of the chosen unstable features The changes done by this PR also allow for further development: * tidy obtains information about tracking issues. We can now forbid differing tracking issues between differing `#![unstable]` annotations. I haven't done this but plan to in a future PR * we now have a general framework for generating stuff for the unstable book at build time. Further changes can autogenerate a list of the API a given library feature exposes. r? @nagisa Fixes #42454
2 parents e40ef96 + 1173ec8 commit ae3a043

File tree

146 files changed

+422
-1195
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

146 files changed

+422
-1195
lines changed

src/Cargo.lock

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ members = [
99
"tools/error_index_generator",
1010
"tools/linkchecker",
1111
"tools/rustbook",
12+
"tools/unstable-book-gen",
1213
"tools/tidy",
1314
"tools/build-manifest",
1415
"tools/remote-test-client",

src/bootstrap/doc.rs

+24-3
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,26 @@ use {Build, Compiler, Mode};
2727
use util::{cp_r, symlink_dir};
2828
use build_helper::up_to_date;
2929

30-
/// Invoke `rustbook` as compiled in `stage` for `target` for the doc book
31-
/// `name` into the `out` path.
30+
/// Invoke `rustbook` for `target` for the doc book `name`.
3231
///
3332
/// This will not actually generate any documentation if the documentation has
3433
/// already been generated.
3534
pub fn rustbook(build: &Build, target: &str, name: &str) {
35+
let src = build.src.join("src/doc");
36+
rustbook_src(build, target, name, &src);
37+
}
38+
39+
/// Invoke `rustbook` for `target` for the doc book `name` from the `src` path.
40+
///
41+
/// This will not actually generate any documentation if the documentation has
42+
/// already been generated.
43+
pub fn rustbook_src(build: &Build, target: &str, name: &str, src: &Path) {
3644
let out = build.doc_out(target);
3745
t!(fs::create_dir_all(&out));
3846

3947
let out = out.join(name);
4048
let compiler = Compiler::new(0, &build.config.build);
41-
let src = build.src.join("src/doc").join(name);
49+
let src = src.join(name);
4250
let index = out.join("index.html");
4351
let rustbook = build.tool(&compiler, "rustbook");
4452
if up_to_date(&src, &index) && up_to_date(&rustbook, &index) {
@@ -354,6 +362,19 @@ pub fn error_index(build: &Build, target: &str) {
354362
build.run(&mut index);
355363
}
356364

365+
pub fn unstable_book_gen(build: &Build, target: &str) {
366+
println!("Generating unstable book md files ({})", target);
367+
let out = build.md_doc_out(target).join("unstable-book");
368+
t!(fs::create_dir_all(&out));
369+
t!(fs::remove_dir_all(&out));
370+
let compiler = Compiler::new(0, &build.config.build);
371+
let mut cmd = build.tool_cmd(&compiler, "unstable-book-gen");
372+
cmd.arg(build.src.join("src"));
373+
cmd.arg(out);
374+
375+
build.run(&mut cmd);
376+
}
377+
357378
fn symlink_dir_force(src: &Path, dst: &Path) -> io::Result<()> {
358379
if let Ok(m) = fs::symlink_metadata(dst) {
359380
if m.file_type().is_dir() {

src/bootstrap/lib.rs

+5
Original file line numberDiff line numberDiff line change
@@ -677,6 +677,11 @@ impl Build {
677677
self.out.join(target).join("doc")
678678
}
679679

680+
/// Output directory for some generated md crate documentation for a target (temporary)
681+
fn md_doc_out(&self, target: &str) -> PathBuf {
682+
self.out.join(target).join("md-doc")
683+
}
684+
680685
/// Output directory for all crate documentation for a target (temporary)
681686
///
682687
/// The artifacts here are then copied into `doc_out` above.

src/bootstrap/step.rs

+20-1
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,10 @@ pub fn build_rules<'a>(build: &'a Build) -> Rules {
548548
.dep(|s| s.name("maybe-clean-tools"))
549549
.dep(|s| s.name("librustc-tool"))
550550
.run(move |s| compile::tool(build, s.stage, s.target, "error_index_generator"));
551+
rules.build("tool-unstable-book-gen", "src/tools/unstable-book-gen")
552+
.dep(|s| s.name("maybe-clean-tools"))
553+
.dep(|s| s.name("libstd-tool"))
554+
.run(move |s| compile::tool(build, s.stage, s.target, "unstable-book-gen"));
551555
rules.build("tool-tidy", "src/tools/tidy")
552556
.dep(|s| s.name("maybe-clean-tools"))
553557
.dep(|s| s.name("libstd-tool"))
@@ -662,8 +666,17 @@ pub fn build_rules<'a>(build: &'a Build) -> Rules {
662666
.target(&build.config.build)
663667
.stage(0)
664668
})
669+
.dep(move |s| {
670+
s.name("doc-unstable-book-gen")
671+
.host(&build.config.build)
672+
.target(&build.config.build)
673+
.stage(0)
674+
})
665675
.default(build.config.docs)
666-
.run(move |s| doc::rustbook(build, s.target, "unstable-book"));
676+
.run(move |s| doc::rustbook_src(build,
677+
s.target,
678+
"unstable-book",
679+
&build.md_doc_out(s.target)));
667680
rules.doc("doc-standalone", "src/doc")
668681
.dep(move |s| {
669682
s.name("rustc")
@@ -679,6 +692,12 @@ pub fn build_rules<'a>(build: &'a Build) -> Rules {
679692
.default(build.config.docs)
680693
.host(true)
681694
.run(move |s| doc::error_index(build, s.target));
695+
rules.doc("doc-unstable-book-gen", "src/tools/unstable-book-gen")
696+
.dep(move |s| s.name("tool-unstable-book-gen").target(&build.config.build).stage(0))
697+
.dep(move |s| s.name("librustc-link"))
698+
.default(build.config.docs)
699+
.host(true)
700+
.run(move |s| doc::unstable_book_gen(build, s.target));
682701
for (krate, path, default) in krates("std") {
683702
rules.doc(&krate.doc_step, path)
684703
.dep(|s| s.name("libstd-link"))

src/doc/unstable-book/src/language-features/abi-sysv64.md

-7
This file was deleted.

src/doc/unstable-book/src/language-features/abi-x86-interrupt.md

-7
This file was deleted.

src/doc/unstable-book/src/language-features/asm.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -190,4 +190,4 @@ constraints, etc.
190190
[llvm-docs]: http://llvm.org/docs/LangRef.html#inline-assembler-expressions
191191

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

src/doc/unstable-book/src/language-features/associated-type-defaults.md

-10
This file was deleted.

src/doc/unstable-book/src/language-features/cfg-target-feature.md

-10
This file was deleted.

src/doc/unstable-book/src/language-features/cfg-target-has-atomic.md

-10
This file was deleted.

src/doc/unstable-book/src/language-features/cfg-target-thread-local.md

-10
This file was deleted.

src/doc/unstable-book/src/language-features/cfg-target-vendor.md

-10
This file was deleted.

src/doc/unstable-book/src/language-features/custom-attribute.md

-10
This file was deleted.

src/doc/unstable-book/src/language-features/custom-derive.md

-10
This file was deleted.

src/doc/unstable-book/src/language-features/decl-macro.md

-10
This file was deleted.

src/doc/unstable-book/src/language-features/default-type-parameter-fallback.md

-10
This file was deleted.

src/doc/unstable-book/src/language-features/drop-types-in-const.md

-10
This file was deleted.

src/doc/unstable-book/src/language-features/dropck-eyepatch.md

-10
This file was deleted.

src/doc/unstable-book/src/language-features/dropck-parametricity.md

-10
This file was deleted.

src/doc/unstable-book/src/language-features/exclusive-range-pattern.md

-10
This file was deleted.

src/doc/unstable-book/src/language-features/fundamental.md

-10
This file was deleted.

src/doc/unstable-book/src/language-features/generic-param-attrs.md

-10
This file was deleted.

src/doc/unstable-book/src/language-features/link-cfg.md

-10
This file was deleted.

src/doc/unstable-book/src/language-features/link-llvm-intrinsics.md

-10
This file was deleted.

src/doc/unstable-book/src/language-features/linkage.md

-10
This file was deleted.

src/doc/unstable-book/src/language-features/log-syntax.md

-10
This file was deleted.

src/doc/unstable-book/src/language-features/macro-reexport.md

-10
This file was deleted.

src/doc/unstable-book/src/language-features/main.md

-10
This file was deleted.

src/doc/unstable-book/src/language-features/naked-functions.md

-10
This file was deleted.

0 commit comments

Comments
 (0)