Skip to content

Support mdBook preprocessors for TRPL in rustbook #125408

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
152 changes: 150 additions & 2 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,21 @@ dependencies = [
"nom",
]

[[package]]
name = "assert_cmd"
version = "2.0.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed72493ac66d5804837f480ab3766c72bdfab91a65e565fc54fa9e42db0073a8"
dependencies = [
"anstyle",
"bstr",
"doc-comment",
"predicates",
"predicates-core",
"predicates-tree",
"wait-timeout",
]

[[package]]
name = "autocfg"
version = "1.3.0"
Expand Down Expand Up @@ -1086,6 +1101,12 @@ version = "0.1.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8"

[[package]]
name = "difflib"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6184e33543162437515c2e2b48714794e37845ec9851711914eec9d308f6ebe8"

[[package]]
name = "digest"
version = "0.10.7"
Expand Down Expand Up @@ -1188,6 +1209,12 @@ dependencies = [
"windows-sys 0.52.0",
]

[[package]]
name = "doc-comment"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10"

[[package]]
name = "either"
version = "1.12.0"
Expand Down Expand Up @@ -2317,6 +2344,33 @@ dependencies = [
"topological-sort",
]

[[package]]
name = "mdbook-trpl-listing"
version = "0.1.0"
dependencies = [
"assert_cmd",
"clap",
"mdbook",
"pulldown-cmark 0.10.3",
"pulldown-cmark-to-cmark",
"serde_json",
"thiserror",
"toml 0.8.13",
"xmlparser",
]

[[package]]
name = "mdbook-trpl-note"
version = "1.0.0"
dependencies = [
"assert_cmd",
"clap",
"mdbook",
"pulldown-cmark 0.10.3",
"pulldown-cmark-to-cmark",
"serde_json",
]

[[package]]
name = "measureme"
version = "11.0.1"
Expand Down Expand Up @@ -2929,6 +2983,33 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c"

[[package]]
name = "predicates"
version = "3.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "68b87bfd4605926cdfefc1c3b5f8fe560e3feca9d5552cf68c466d3d8236c7e8"
dependencies = [
"anstyle",
"difflib",
"predicates-core",
]

[[package]]
name = "predicates-core"
version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b794032607612e7abeb4db69adb4e33590fa6cf1149e95fd7cb00e634b92f174"

[[package]]
name = "predicates-tree"
version = "1.0.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "368ba315fb8c5052ab692e68a0eefec6ec57b23a36959c14496f0b0df2c0cecf"
dependencies = [
"predicates-core",
"termtree",
]

[[package]]
name = "prettydiff"
version = "0.6.4"
Expand Down Expand Up @@ -2998,6 +3079,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "76979bea66e7875e7509c4ec5300112b316af87fa7a252ca91c448b32dfe3993"
dependencies = [
"bitflags 2.5.0",
"getopts",
"memchr",
"pulldown-cmark-escape",
"unicase",
Expand All @@ -3009,6 +3091,15 @@ version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bd348ff538bc9caeda7ee8cad2d1d48236a1f443c1fa3913c6a02fe0043b1dd3"

[[package]]
name = "pulldown-cmark-to-cmark"
version = "13.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f609795c8d835f79dcfcf768415b9fb57ef1b74891e99f86e73f43a7a257163b"
dependencies = [
"pulldown-cmark 0.10.3",
]

[[package]]
name = "punycode"
version = "0.4.1"
Expand Down Expand Up @@ -3256,6 +3347,8 @@ dependencies = [
"clap",
"env_logger",
"mdbook",
"mdbook-trpl-listing",
"mdbook-trpl-note",
]

[[package]]
Expand Down Expand Up @@ -5363,6 +5456,12 @@ dependencies = [
"winapi",
]

[[package]]
name = "termtree"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76"

[[package]]
name = "test"
version = "0.0.0"
Expand Down Expand Up @@ -5535,7 +5634,19 @@ dependencies = [
"serde",
"serde_spanned",
"toml_datetime",
"toml_edit",
"toml_edit 0.19.15",
]

[[package]]
name = "toml"
version = "0.8.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a4e43f8cc456c9704c851ae29c67e17ef65d2c30017c17a9765b89c382dc8bba"
dependencies = [
"serde",
"serde_spanned",
"toml_datetime",
"toml_edit 0.22.13",
]

[[package]]
Expand All @@ -5557,7 +5668,20 @@ dependencies = [
"serde",
"serde_spanned",
"toml_datetime",
"winnow",
"winnow 0.5.40",
]

[[package]]
name = "toml_edit"
version = "0.22.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c127785850e8c20836d49732ae6abfa47616e60bf9d9f57c43c250361a9db96c"
dependencies = [
"indexmap",
"serde",
"serde_spanned",
"toml_datetime",
"winnow 0.6.8",
]

[[package]]
Expand Down Expand Up @@ -5967,6 +6091,15 @@ version = "0.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"

[[package]]
name = "wait-timeout"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9f200f5b12eb75f8c1ed65abd4b2db8a6e1b138a20de009dacee265a2498f3f6"
dependencies = [
"libc",
]

[[package]]
name = "walkdir"
version = "2.5.0"
Expand Down Expand Up @@ -6279,6 +6412,15 @@ dependencies = [
"memchr",
]

[[package]]
name = "winnow"
version = "0.6.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3c52e9c97a68071b23e836c9380edae937f17b9c4667bd021973efc689f618d"
dependencies = [
"memchr",
]

[[package]]
name = "writeable"
version = "0.5.4"
Expand All @@ -6296,6 +6438,12 @@ dependencies = [
"rustix",
]

[[package]]
name = "xmlparser"
version = "0.13.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "66fee0b777b0f5ac1c69bb06d361268faafa61cd4682ae064a171c16c433e9e4"

[[package]]
name = "xz2"
version = "0.1.7"
Expand Down
2 changes: 1 addition & 1 deletion src/doc/book
Submodule book updated 112 files
2 changes: 2 additions & 0 deletions src/tools/rustbook/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ edition = "2021"
[dependencies]
clap = "4.0.32"
env_logger = "0.11"
mdbook-trpl-listing = { path = "../../doc/book/packages/mdbook-trpl-listing" }
mdbook-trpl-note = { path = "../../doc/book/packages/mdbook-trpl-note" }

[dependencies.mdbook]
version = "0.4.37"
Expand Down
11 changes: 11 additions & 0 deletions src/tools/rustbook/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ use clap::{arg, ArgMatches, Command};
use mdbook::errors::Result as Result3;
use mdbook::MDBook;

use mdbook_trpl_listing::TrplListing;
use mdbook_trpl_note::TrplNote;

fn main() {
let crate_version = concat!("v", crate_version!());
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("warn")).init();
Expand Down Expand Up @@ -67,6 +70,14 @@ pub fn build(args: &ArgMatches) -> Result3<()> {
book.config.build.build_dir = dest_dir.into();
}

if book.config.get_preprocessor("trpl-note").is_some() {
book.with_preprocessor(TrplNote);
}

if book.config.get_preprocessor("trpl-listing").is_some() {
book.with_preprocessor(TrplListing);
}

book.build()?;

Ok(())
Expand Down
Loading