diff options
Diffstat (limited to 'src/tools/rustbook')
| -rw-r--r-- | src/tools/rustbook/Cargo.lock | 21 | ||||
| -rw-r--r-- | src/tools/rustbook/Cargo.toml | 1 | ||||
| -rw-r--r-- | src/tools/rustbook/src/main.rs | 12 |
3 files changed, 34 insertions, 0 deletions
diff --git a/src/tools/rustbook/Cargo.lock b/src/tools/rustbook/Cargo.lock index 75b89a162e9..df051ed447e 100644 --- a/src/tools/rustbook/Cargo.lock +++ b/src/tools/rustbook/Cargo.lock @@ -662,6 +662,20 @@ dependencies = [ ] [[package]] +name = "mdbook-spec" +version = "0.1.2" +dependencies = [ + "anyhow", + "mdbook", + "once_cell", + "pathdiff", + "regex", + "semver", + "serde_json", + "tempfile", +] + +[[package]] name = "mdbook-trpl-listing" version = "0.1.0" dependencies = [ @@ -795,6 +809,12 @@ dependencies = [ ] [[package]] +name = "pathdiff" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd" + +[[package]] name = "percent-encoding" version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1079,6 +1099,7 @@ dependencies = [ "env_logger", "mdbook", "mdbook-i18n-helpers", + "mdbook-spec", "mdbook-trpl-listing", "mdbook-trpl-note", ] diff --git a/src/tools/rustbook/Cargo.toml b/src/tools/rustbook/Cargo.toml index 51ba58483c5..2c29a2848b7 100644 --- a/src/tools/rustbook/Cargo.toml +++ b/src/tools/rustbook/Cargo.toml @@ -12,6 +12,7 @@ env_logger = "0.11" mdbook-trpl-listing = { path = "../../doc/book/packages/mdbook-trpl-listing" } mdbook-trpl-note = { path = "../../doc/book/packages/mdbook-trpl-note" } mdbook-i18n-helpers = "0.3.3" +mdbook-spec = { path = "../../doc/reference/mdbook-spec"} [dependencies.mdbook] version = "0.4.37" diff --git a/src/tools/rustbook/src/main.rs b/src/tools/rustbook/src/main.rs index 31bba56adde..e94c2f5958e 100644 --- a/src/tools/rustbook/src/main.rs +++ b/src/tools/rustbook/src/main.rs @@ -9,6 +9,7 @@ use mdbook::errors::Result as Result3; use mdbook::MDBook; use mdbook_i18n_helpers::preprocessors::Gettext; +use mdbook_spec::Spec; use mdbook_trpl_listing::TrplListing; use mdbook_trpl_note::TrplNote; @@ -83,6 +84,13 @@ pub fn build(args: &ArgMatches) -> Result3<()> { book.config.build.build_dir = dest_dir.into(); } + // NOTE: Replacing preprocessors using this technique causes error + // messages to be displayed when the original preprocessor doesn't work + // (but it otherwise succeeds). + // + // This should probably be fixed in mdbook to remove the existing + // preprocessor, or this should modify the config and use + // MDBook::load_with_config. if book.config.get_preprocessor("trpl-note").is_some() { book.with_preprocessor(TrplNote); } @@ -91,6 +99,10 @@ pub fn build(args: &ArgMatches) -> Result3<()> { book.with_preprocessor(TrplListing); } + if book.config.get_preprocessor("spec").is_some() { + book.with_preprocessor(Spec::new()); + } + book.build()?; Ok(()) |
