Merge pull request #2622 from szabgab/warn-on-invalid-configuration-field
warn on invalid fields in the root of book.toml
This commit is contained in:
commit
4f698f813c
1 changed files with 13 additions and 0 deletions
|
|
@ -312,6 +312,8 @@ impl<'de> serde::Deserialize<'de> for Config {
|
||||||
return Ok(Config::from_legacy(raw));
|
return Ok(Config::from_legacy(raw));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
warn_on_invalid_fields(&raw);
|
||||||
|
|
||||||
use serde::de::Error;
|
use serde::de::Error;
|
||||||
let mut table = match raw {
|
let mut table = match raw {
|
||||||
Value::Table(t) => t,
|
Value::Table(t) => t,
|
||||||
|
|
@ -376,6 +378,17 @@ fn parse_env(key: &str) -> Option<String> {
|
||||||
.map(|key| key.to_lowercase().replace("__", ".").replace('_', "-"))
|
.map(|key| key.to_lowercase().replace("__", ".").replace('_', "-"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn warn_on_invalid_fields(table: &Value) {
|
||||||
|
let valid_items = ["book", "build", "rust", "output", "preprocessor"];
|
||||||
|
|
||||||
|
let table = table.as_table().expect("root must be a table");
|
||||||
|
for item in table.keys() {
|
||||||
|
if !valid_items.contains(&item.as_str()) {
|
||||||
|
warn!("Invalid field {:?} in book.toml", &item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn is_legacy_format(table: &Value) -> bool {
|
fn is_legacy_format(table: &Value) -> bool {
|
||||||
let legacy_items = [
|
let legacy_items = [
|
||||||
"title",
|
"title",
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue