Skip to content

Commit

Permalink
allow to serialize the "build" section
Browse files Browse the repository at this point in the history
  • Loading branch information
daynin committed Nov 12, 2020
1 parent eaa6914 commit 7c0ddff
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,11 @@ impl Serialize for Config {
let book_config = Value::try_from(&self.book).expect("should always be serializable");
table.insert("book", book_config);

if self.build != BuildConfig::default() {
let build_config = Value::try_from(&self.build).expect("should always be serializable");
table.insert("build", build_config);
}

if self.rust != RustConfig::default() {
let rust_config = Value::try_from(&self.rust).expect("should always be serializable");
table.insert("rust", rust_config);
Expand Down
6 changes: 6 additions & 0 deletions tests/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ fn run_mdbook_init_with_custom_book_and_src_locations() {
file
);
}

let contents = fs::read_to_string(temp.path().join("book.toml")).unwrap();
assert_eq!(
contents,
"[book]\nauthors = []\nlanguage = \"en\"\nmultilingual = false\nsrc = \"in\"\n\n[build]\nbuild-dir = \"out\"\ncreate-missing = true\nuse-default-preprocessors = true\n"
);
}

#[test]
Expand Down

0 comments on commit 7c0ddff

Please sign in to comment.