diff options
| author | Eric Huss <eric@huss.org> | 2024-07-25 17:38:22 -0700 |
|---|---|---|
| committer | Eric Huss <eric@huss.org> | 2024-07-25 17:38:22 -0700 |
| commit | 53ef052d455ba8bd9a4823c59696efb257aef2fa (patch) | |
| tree | 343d159393ab4ec0fd9ab4799682349777c79bf1 /src/tools | |
| parent | a20db06d5be876fbdaf1d4542d2974f2f76abba0 (diff) | |
| download | rust-53ef052d455ba8bd9a4823c59696efb257aef2fa.tar.gz rust-53ef052d455ba8bd9a4823c59696efb257aef2fa.zip | |
Integrate mdbook-spec for the reference.
This updates the reference which is now using a new mdbook plugin. This requires a little extra work than a normal book because the plugin uses `rustdoc` to generate links to the standard library. It also ensures that the submodule is available for *any* command that uses rustbook, since it is now part of the rustbook workspace.
Diffstat (limited to 'src/tools')
| -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 | ||||
| -rw-r--r-- | src/tools/tidy/src/deps.rs | 2 |
4 files changed, 35 insertions, 1 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(()) diff --git a/src/tools/tidy/src/deps.rs b/src/tools/tidy/src/deps.rs index 6d61e0dd3ef..d53e535a750 100644 --- a/src/tools/tidy/src/deps.rs +++ b/src/tools/tidy/src/deps.rs @@ -72,7 +72,7 @@ pub(crate) const WORKSPACES: &[(&str, ExceptionList, Option<(&[&str], &[&str])>, //("src/tools/miri/test-cargo-miri", &[], None), // FIXME uncomment once all deps are vendored //("src/tools/miri/test_dependencies", &[], None), // FIXME uncomment once all deps are vendored ("src/tools/rust-analyzer", EXCEPTIONS_RUST_ANALYZER, None, &[]), - ("src/tools/rustbook", EXCEPTIONS_RUSTBOOK, None, &["src/doc/book"]), + ("src/tools/rustbook", EXCEPTIONS_RUSTBOOK, None, &["src/doc/book", "src/doc/reference"]), ("src/tools/rustc-perf", EXCEPTIONS_RUSTC_PERF, None, &["src/tools/rustc-perf"]), ("src/tools/x", &[], None, &[]), // tidy-alphabetical-end |
