Skip to content

Commit 936ac6a

Browse files
committed
Migrate changes for ExternArgs from root to crates mdbook-core and mdbook-driver.
1 parent 19859b0 commit 936ac6a

File tree

9 files changed

+82
-1468
lines changed

9 files changed

+82
-1468
lines changed

Cargo.lock

Lines changed: 66 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ rust-version = "1.88.0" # Keep in sync with installation.md and .github/workflow
2727
[workspace.dependencies]
2828
anyhow = "1.0.100"
2929
axum = "0.8.6"
30+
cargo-manifest = "0.19.1"
3031
clap = { version = "4.5.51", features = ["cargo", "wrap_help"] }
3132
clap_complete = "4.5.60"
3233
ego-tree = "0.10.0"

crates/mdbook-core/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ rust-version.workspace = true
99

1010
[dependencies]
1111
anyhow.workspace = true
12+
cargo-manifest.workspace = true
1213
regex.workspace = true
1314
serde.workspace = true
1415
serde_json.workspace = true

crates/mdbook-core/src/utils/extern_args.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
//! Get "compiler" args from cargo
22
33
use crate::errors::*;
4-
use anyhow::anyhow;
4+
use anyhow::{Context, anyhow, bail};
55
use cargo_manifest::{Edition, Manifest, MaybeInherited::Local};
6-
use log::{debug, info};
6+
use tracing::{debug, info};
77
use std::fs;
88
use std::fs::File;
99
use std::io::prelude::*;

crates/mdbook-core/src/utils/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use anyhow::Error;
44
use std::fmt::Write;
55
use tracing::error;
66

7+
pub mod extern_args;
78
pub mod fs;
89
mod html;
910
mod toml_ext;

crates/mdbook-driver/src/mdbook.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use anyhow::{Context, Error, Result, bail};
88
use indexmap::IndexMap;
99
use mdbook_core::book::{Book, BookItem, BookItems};
1010
use mdbook_core::config::{Config, RustEdition};
11-
use mdbook_core::utils::fs;
11+
use mdbook_core::utils::{extern_args, fs};
1212
use mdbook_html::HtmlHandlebars;
1313
use mdbook_preprocessor::{Preprocessor, PreprocessorContext};
1414
use mdbook_renderer::{RenderContext, Renderer};
@@ -271,6 +271,13 @@ impl MDBook {
271271
let (book, _) = self.preprocess_book(&TestRenderer)?;
272272

273273
let color_output = std::io::stderr().is_terminal();
274+
// get extra args we'll need for rustdoc, if config points to a cargo project
275+
276+
let mut extern_args = extern_args::ExternArgs::new();
277+
if let Some(manifest) = &self.config.rust.manifest {
278+
extern_args.load(&self.root.join(manifest))?;
279+
}
280+
274281
let mut failed = false;
275282
for item in book.iter() {
276283
if let BookItem::Chapter(ref ch) = *item {
@@ -298,7 +305,8 @@ impl MDBook {
298305
cmd.current_dir(temp_dir.path())
299306
.arg(chapter_path)
300307
.arg("--test")
301-
.args(&library_args);
308+
.args(&library_args)
309+
.args(extern_args.get_args());
302310

303311
if let Some(edition) = self.config.rust.edition {
304312
match edition {

0 commit comments

Comments
 (0)