From 7c0ddff96affec4d04879ba793e109cffe6781fa Mon Sep 17 00:00:00 2001 From: Sergey Golovin Date: Tue, 10 Nov 2020 22:45:36 +0300 Subject: [PATCH] allow to serialize the "build" section --- src/config.rs | 5 +++++ tests/init.rs | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/src/config.rs b/src/config.rs index 91d40300..14a13ce3 100644 --- a/src/config.rs +++ b/src/config.rs @@ -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); diff --git a/tests/init.rs b/tests/init.rs index ae80b059..92dc91c7 100644 --- a/tests/init.rs +++ b/tests/init.rs @@ -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]