Skip to content

Commit

Permalink
Update rustbook to support new test linking in reference
Browse files Browse the repository at this point in the history
  • Loading branch information
ehuss committed Oct 23, 2024
1 parent 87fb4ea commit df8551b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/bootstrap/src/core/build_steps/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,14 @@ impl<P: Step> Step for RustbookSrc<P> {
builder.add_rustc_lib_path(compiler, &mut rustbook_cmd);
}

rustbook_cmd.arg("build").arg(&src).arg("-d").arg(&out).run(builder);
rustbook_cmd
.arg("build")
.arg(&src)
.arg("-d")
.arg(&out)
.arg("--rust-root")
.arg(&builder.src)
.run(builder);

for lang in &self.languages {
let out = out.join(lang);
Expand Down
9 changes: 8 additions & 1 deletion src/tools/rustbook/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ fn main() {
.required(false)
.value_parser(clap::value_parser!(String));

let root_arg = arg!(--"rust-root" <ROOT_DIR>
"Path to the root of the rust source tree")
.required(false)
.value_parser(clap::value_parser!(PathBuf));

let dir_arg = arg!([dir] "Root directory for the book\n\
(Defaults to the current directory when omitted)")
.value_parser(clap::value_parser!(PathBuf));
Expand All @@ -37,6 +42,7 @@ fn main() {
.about("Build the book from the markdown files")
.arg(d_arg)
.arg(l_arg)
.arg(root_arg)
.arg(&dir_arg),
)
.subcommand(
Expand Down Expand Up @@ -96,7 +102,8 @@ pub fn build(args: &ArgMatches) -> Result3<()> {
}

if book.config.get_preprocessor("spec").is_some() {
book.with_preprocessor(Spec::new());
let rust_root = args.get_one::<PathBuf>("rust-root").cloned();
book.with_preprocessor(Spec::new(rust_root)?);
}

book.build()?;
Expand Down

0 comments on commit df8551b

Please sign in to comment.