rust/src/tools/rustbook
github-actions 715c3d4fcf cargo update
compiler & tools dependencies:
     Locking 13 packages to latest compatible versions
    Updating anstyle-wincon v3.0.6 -> v3.0.7
    Updating bitflags v2.7.0 -> v2.8.0
    Updating chrono-tz v0.10.0 -> v0.10.1
    Updating js-sys v0.3.76 -> v0.3.77
    Updating log v0.4.22 -> v0.4.25
    Updating miniz_oxide v0.8.2 -> v0.8.3
    Updating uuid v1.11.1 -> v1.12.0
    Updating valuable v0.1.0 -> v0.1.1
    Updating wasm-bindgen v0.2.99 -> v0.2.100
    Updating wasm-bindgen-backend v0.2.99 -> v0.2.100
    Updating wasm-bindgen-macro v0.2.99 -> v0.2.100
    Updating wasm-bindgen-macro-support v0.2.99 -> v0.2.100
    Updating wasm-bindgen-shared v0.2.99 -> v0.2.100
note: pass `--verbose` to see 41 unchanged dependencies behind latest

library dependencies:
     Locking 1 package to latest compatible version
    Updating miniz_oxide v0.8.2 -> v0.8.3
note: pass `--verbose` to see 4 unchanged dependencies behind latest

rustbook dependencies:
     Locking 12 packages to latest compatible versions
    Updating anstyle-wincon v3.0.6 -> v3.0.7
    Updating bitflags v2.7.0 -> v2.8.0
    Updating cc v1.2.8 -> v1.2.10
    Updating js-sys v0.3.76 -> v0.3.77
    Updating log v0.4.22 -> v0.4.25
    Updating miniz_oxide v0.8.2 -> v0.8.3
      Adding rustversion v1.0.19
    Updating wasm-bindgen v0.2.99 -> v0.2.100
    Updating wasm-bindgen-backend v0.2.99 -> v0.2.100
    Updating wasm-bindgen-macro v0.2.99 -> v0.2.100
    Updating wasm-bindgen-macro-support v0.2.99 -> v0.2.100
    Updating wasm-bindgen-shared v0.2.99 -> v0.2.100
2025-01-19 00:21:55 +00:00
..
src rustbook: update to use new mdbook-trpl package from The Book 2024-12-05 11:01:42 -07:00
.gitignore Update mdbook to 0.4.42 2024-11-08 15:38:32 -08:00
Cargo.lock cargo update 2025-01-19 00:21:55 +00:00
Cargo.toml rustbook: update to use new mdbook-trpl package from The Book 2024-12-05 11:01:42 -07:00
README.md Add a README to rustbook to explain its purpose 2024-07-27 08:54:04 -07:00

Rustbook

This is a wrapper around mdbook, which is used to generate the book-style documentation in the Rust project. This wrapper serves a few purposes:

  • Avoids some of mdbook's large, optional dependencies (like tokio, webserver, etc.).
  • Makes it a little easier to customize and override some of mdbook's behaviors (like swapping in custom preprocessors).
  • Supports vendoring of the source via Rust's normal release process.

This is invoked automatically when building mdbook-style documentation, for example via ./x doc.

Cargo workspace

This package defines a separate cargo workspace from the main Rust workspace for a few reasons (ref #127786:

  • Avoids requiring checking out submodules for developers who are not working on the documentation. Otherwise, some submodules such as those that have custom preprocessors would be required for cargo to find the dependencies.
  • Avoids problems with updating dependencies. Unfortunately this workspace has a rather large set of dependencies, which can make coordinating updates difficult (see #127890).

Custom preprocessors

Some books have custom mdbook preprocessors that need to be integrated with both the book's repository, and the build system here in the rust-lang/rust repository. To add a new preprocessor, there are few things to do:

  1. Implement the preprocessor as a cargo library in the book's repository.
  2. Add the [preprocessor] table to the book's book.toml file. I recommend setting the command so that the preprocessor gets built automatically. It may look something like:
[preprocessor.spec]
command = "cargo run --manifest-path my-cool-extension/Cargo.toml"

[build]
extra-watch-dirs = ["my-cool-extension/src"]
  1. Add the preprocessor as a dependency in rustbook's Cargo.toml.
  2. Call with_preprocessor in rustbook/src/main.rs.
  3. Be sure to test that it generates correctly, such as running ./x doc MY-BOOK-NAME --open and verify the content looks correct.
  4. Also test tidy and your book, such as running ./x test tidy and ./x test MY-BOOK-NAME.