Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -389,6 +390,28 @@ 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",
];
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",
Expand Down