toolkit for mdBook [mirror of my GitHub repo] docs.tonywu.dev/mdbookkit/
permalinks rust-analyzer mdbook
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: ignore `optional` when deserializing preprocessor options (#24)

Tony Wu 52e54ec2 bb2e148a

+19 -51
-20
crates/mdbook-permalinks/src/main.rs
··· 592 592 #[serde(default)] 593 593 #[arg(long, value_enum, value_name("MODE"), default_value_t = Default::default())] 594 594 fail_on_warnings: OnWarning, 595 - 596 - #[allow(unused)] 597 - #[serde(default)] 598 - #[doc(hidden)] 599 - after: Option<Vec<String>>, 600 - 601 - #[allow(unused)] 602 - #[serde(default)] 603 - #[doc(hidden)] 604 - before: Option<Vec<String>>, 605 - 606 - #[allow(unused)] 607 - #[serde(default)] 608 - #[doc(hidden)] 609 - renderers: Option<Vec<String>>, 610 - 611 - #[allow(unused)] 612 - #[serde(default)] 613 - #[doc(hidden)] 614 - command: Option<String>, 615 595 } 616 596 617 597 #[derive(Clone)]
-24
crates/mdbook-rustdoc-links/src/env.rs
··· 89 89 #[serde(default)] 90 90 #[arg(long, value_name("SECONDS"), default_value("60"))] 91 91 pub rust_analyzer_timeout: Option<u64>, 92 - 93 - #[allow(unused)] 94 - #[serde(default)] 95 - #[doc(hidden)] 96 - #[arg(skip)] 97 - pub after: Option<Vec<String>>, 98 - 99 - #[allow(unused)] 100 - #[serde(default)] 101 - #[doc(hidden)] 102 - #[arg(skip)] 103 - pub before: Option<Vec<String>>, 104 - 105 - #[allow(unused)] 106 - #[serde(default)] 107 - #[doc(hidden)] 108 - #[arg(skip)] 109 - pub renderers: Option<Vec<String>>, 110 - 111 - #[allow(unused)] 112 - #[serde(default)] 113 - #[doc(hidden)] 114 - #[arg(skip)] 115 - pub command: Option<String>, 116 92 } 117 93 118 94 impl Config {
+19 -7
crates/mdbookkit/src/book.rs
··· 59 59 60 60 for (idx, name) in names.iter().enumerate() { 61 61 let name = format_name(name); 62 - if let Some(value) = self.get::<T>(&name)? { 63 - if idx != 0 { 64 - let recommended = format_name(names[0]); 65 - warn! { "The book.toml section [{name}] is deprecated. \ 66 - Use [{recommended}] instead." }; 67 - } 68 - return Ok(value); 62 + let Some(mut table) = self.get::<toml::Table>(&name)? else { 63 + continue; 64 + }; 65 + // remove mdbook's builtin preprocessor options from table before deserializing 66 + // so that they don't interfere with `deny_unknown_fields` 67 + // keep in-sync with: 68 + // - https://rust-lang.github.io/mdBook/format/configuration/preprocessors.html 69 + // - https://github.com/rust-lang/mdBook/blob/v0.5.2/crates/mdbook-driver/src/mdbook.rs#L434-L443 70 + table.remove("command"); 71 + table.remove("before"); 72 + table.remove("after"); 73 + table.remove("optional"); 74 + table.remove("renderers"); 75 + let value = T::deserialize(table)?; 76 + if idx != 0 { 77 + let recommended = format_name(names[0]); 78 + warn! { "The book.toml section [{name}] is deprecated. \ 79 + Use [{recommended}] instead." }; 69 80 } 81 + return Ok(value); 70 82 } 71 83 72 84 Ok(Default::default())