From c153451c026fd363e11f8d3694a281c82f035445 Mon Sep 17 00:00:00 2001 From: Gabor Szabo Date: Thu, 3 Apr 2025 22:06:17 +0300 Subject: [PATCH 1/2] Warn on invalid fields in the `[book]` section of `book.toml` A step for #1595. We might need to revise this if de decide to remove the `multilingual` field as described in #2636 --- src/config.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/config.rs b/src/config.rs index 2ede0c2f92..9e446c3344 100644 --- a/src/config.rs +++ b/src/config.rs @@ -313,6 +313,7 @@ impl<'de> serde::Deserialize<'de> for Config { } warn_on_invalid_fields(&raw); + warn_on_invalid_fields_in_book_section(&raw); use serde::de::Error; let mut table = match raw { @@ -389,6 +390,29 @@ fn warn_on_invalid_fields(table: &Value) { } } +fn warn_on_invalid_fields_in_book_section(table: &Value) { + let valid_items = [ + "title", + "authors", + "description", + "src", + "language", + "text-direction", + "multilingual", + ]; + if let Some(book) = table.get("book") { + let table = book.as_table().expect("root.book must be a table"); + for item in table.keys() { + if !valid_items.contains(&item.as_str()) { + warn!( + "Invalid field {:?} in the [book] section of book.toml", + &item + ); + } + } + } +} + fn is_legacy_format(table: &Value) -> bool { let legacy_items = [ "title", From 1e581c3043b7bc8f5845da815a64fe10ccb5787b Mon Sep 17 00:00:00 2001 From: Gabor Szabo Date: Wed, 9 Apr 2025 10:30:19 +0300 Subject: [PATCH 2/2] remove multilingual field as we have removed it elsewhere --- src/config.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/config.rs b/src/config.rs index 9e446c3344..f628e96d80 100644 --- a/src/config.rs +++ b/src/config.rs @@ -398,7 +398,6 @@ fn warn_on_invalid_fields_in_book_section(table: &Value) { "src", "language", "text-direction", - "multilingual", ]; if let Some(book) = table.get("book") { let table = book.as_table().expect("root.book must be a table");