allow to serialize the "build" section

This commit is contained in:
Sergey Golovin 2020-11-10 22:45:36 +03:00
parent eaa6914205
commit 7c0ddff96a
2 changed files with 11 additions and 0 deletions

View File

@ -352,6 +352,11 @@ impl Serialize for Config {
let book_config = Value::try_from(&self.book).expect("should always be serializable"); let book_config = Value::try_from(&self.book).expect("should always be serializable");
table.insert("book", book_config); 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() { if self.rust != RustConfig::default() {
let rust_config = Value::try_from(&self.rust).expect("should always be serializable"); let rust_config = Value::try_from(&self.rust).expect("should always be serializable");
table.insert("rust", rust_config); table.insert("rust", rust_config);

View File

@ -91,6 +91,12 @@ fn run_mdbook_init_with_custom_book_and_src_locations() {
file 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] #[test]