Skip to content

Commit 7c0ddff

Browse files
committed
allow to serialize the "build" section
1 parent eaa6914 commit 7c0ddff

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/config.rs

+5
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,11 @@ impl Serialize for Config {
352352
let book_config = Value::try_from(&self.book).expect("should always be serializable");
353353
table.insert("book", book_config);
354354

355+
if self.build != BuildConfig::default() {
356+
let build_config = Value::try_from(&self.build).expect("should always be serializable");
357+
table.insert("build", build_config);
358+
}
359+
355360
if self.rust != RustConfig::default() {
356361
let rust_config = Value::try_from(&self.rust).expect("should always be serializable");
357362
table.insert("rust", rust_config);

tests/init.rs

+6
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,12 @@ fn run_mdbook_init_with_custom_book_and_src_locations() {
9191
file
9292
);
9393
}
94+
95+
let contents = fs::read_to_string(temp.path().join("book.toml")).unwrap();
96+
assert_eq!(
97+
contents,
98+
"[book]\nauthors = []\nlanguage = \"en\"\nmultilingual = false\nsrc = \"in\"\n\n[build]\nbuild-dir = \"out\"\ncreate-missing = true\nuse-default-preprocessors = true\n"
99+
);
94100
}
95101

96102
#[test]

0 commit comments

Comments
 (0)