Skip to content

Commit 20be84a

Browse files
committed
Auto merge of rust-lang#125408 - chriskrycho:chriskrycho/book-updates, r=ehuss
Support mdBook preprocessors for TRPL in rustbook `rust-lang/book` recently added two mdBook preprocessors. Enable `rustbook` to use those preprocessors for books where they are requested by the `book.toml` by adding the preprocessors as path dependencies, and ignoring them where they are not requested, i.e. by all the books other than TRPL at present. Addresses rust-lang/book#3927
2 parents ada5e2c + 2c9fc62 commit 20be84a

File tree

4 files changed

+164
-3
lines changed

4 files changed

+164
-3
lines changed

Cargo.lock

+150-2
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,21 @@ dependencies = [
284284
"nom",
285285
]
286286

287+
[[package]]
288+
name = "assert_cmd"
289+
version = "2.0.14"
290+
source = "registry+https://github.com/rust-lang/crates.io-index"
291+
checksum = "ed72493ac66d5804837f480ab3766c72bdfab91a65e565fc54fa9e42db0073a8"
292+
dependencies = [
293+
"anstyle",
294+
"bstr",
295+
"doc-comment",
296+
"predicates",
297+
"predicates-core",
298+
"predicates-tree",
299+
"wait-timeout",
300+
]
301+
287302
[[package]]
288303
name = "autocfg"
289304
version = "1.3.0"
@@ -1095,6 +1110,12 @@ version = "0.1.13"
10951110
source = "registry+https://github.com/rust-lang/crates.io-index"
10961111
checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8"
10971112

1113+
[[package]]
1114+
name = "difflib"
1115+
version = "0.4.0"
1116+
source = "registry+https://github.com/rust-lang/crates.io-index"
1117+
checksum = "6184e33543162437515c2e2b48714794e37845ec9851711914eec9d308f6ebe8"
1118+
10981119
[[package]]
10991120
name = "digest"
11001121
version = "0.10.7"
@@ -1197,6 +1218,12 @@ dependencies = [
11971218
"windows-sys 0.52.0",
11981219
]
11991220

1221+
[[package]]
1222+
name = "doc-comment"
1223+
version = "0.3.3"
1224+
source = "registry+https://github.com/rust-lang/crates.io-index"
1225+
checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10"
1226+
12001227
[[package]]
12011228
name = "either"
12021229
version = "1.12.0"
@@ -2337,6 +2364,33 @@ dependencies = [
23372364
"topological-sort",
23382365
]
23392366

2367+
[[package]]
2368+
name = "mdbook-trpl-listing"
2369+
version = "0.1.0"
2370+
dependencies = [
2371+
"assert_cmd",
2372+
"clap",
2373+
"mdbook",
2374+
"pulldown-cmark 0.10.3",
2375+
"pulldown-cmark-to-cmark",
2376+
"serde_json",
2377+
"thiserror",
2378+
"toml 0.8.13",
2379+
"xmlparser",
2380+
]
2381+
2382+
[[package]]
2383+
name = "mdbook-trpl-note"
2384+
version = "1.0.0"
2385+
dependencies = [
2386+
"assert_cmd",
2387+
"clap",
2388+
"mdbook",
2389+
"pulldown-cmark 0.10.3",
2390+
"pulldown-cmark-to-cmark",
2391+
"serde_json",
2392+
]
2393+
23402394
[[package]]
23412395
name = "measureme"
23422396
version = "11.0.1"
@@ -2949,6 +3003,33 @@ version = "0.1.1"
29493003
source = "registry+https://github.com/rust-lang/crates.io-index"
29503004
checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c"
29513005

3006+
[[package]]
3007+
name = "predicates"
3008+
version = "3.1.0"
3009+
source = "registry+https://github.com/rust-lang/crates.io-index"
3010+
checksum = "68b87bfd4605926cdfefc1c3b5f8fe560e3feca9d5552cf68c466d3d8236c7e8"
3011+
dependencies = [
3012+
"anstyle",
3013+
"difflib",
3014+
"predicates-core",
3015+
]
3016+
3017+
[[package]]
3018+
name = "predicates-core"
3019+
version = "1.0.6"
3020+
source = "registry+https://github.com/rust-lang/crates.io-index"
3021+
checksum = "b794032607612e7abeb4db69adb4e33590fa6cf1149e95fd7cb00e634b92f174"
3022+
3023+
[[package]]
3024+
name = "predicates-tree"
3025+
version = "1.0.9"
3026+
source = "registry+https://github.com/rust-lang/crates.io-index"
3027+
checksum = "368ba315fb8c5052ab692e68a0eefec6ec57b23a36959c14496f0b0df2c0cecf"
3028+
dependencies = [
3029+
"predicates-core",
3030+
"termtree",
3031+
]
3032+
29523033
[[package]]
29533034
name = "prettydiff"
29543035
version = "0.6.4"
@@ -3018,6 +3099,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
30183099
checksum = "76979bea66e7875e7509c4ec5300112b316af87fa7a252ca91c448b32dfe3993"
30193100
dependencies = [
30203101
"bitflags 2.5.0",
3102+
"getopts",
30213103
"memchr",
30223104
"pulldown-cmark-escape",
30233105
"unicase",
@@ -3029,6 +3111,15 @@ version = "0.10.1"
30293111
source = "registry+https://github.com/rust-lang/crates.io-index"
30303112
checksum = "bd348ff538bc9caeda7ee8cad2d1d48236a1f443c1fa3913c6a02fe0043b1dd3"
30313113

3114+
[[package]]
3115+
name = "pulldown-cmark-to-cmark"
3116+
version = "13.0.0"
3117+
source = "registry+https://github.com/rust-lang/crates.io-index"
3118+
checksum = "f609795c8d835f79dcfcf768415b9fb57ef1b74891e99f86e73f43a7a257163b"
3119+
dependencies = [
3120+
"pulldown-cmark 0.10.3",
3121+
]
3122+
30323123
[[package]]
30333124
name = "punycode"
30343125
version = "0.4.1"
@@ -3276,6 +3367,8 @@ dependencies = [
32763367
"clap",
32773368
"env_logger",
32783369
"mdbook",
3370+
"mdbook-trpl-listing",
3371+
"mdbook-trpl-note",
32793372
]
32803373

32813374
[[package]]
@@ -5386,6 +5479,12 @@ dependencies = [
53865479
"winapi",
53875480
]
53885481

5482+
[[package]]
5483+
name = "termtree"
5484+
version = "0.4.1"
5485+
source = "registry+https://github.com/rust-lang/crates.io-index"
5486+
checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76"
5487+
53895488
[[package]]
53905489
name = "test"
53915490
version = "0.0.0"
@@ -5558,7 +5657,19 @@ dependencies = [
55585657
"serde",
55595658
"serde_spanned",
55605659
"toml_datetime",
5561-
"toml_edit",
5660+
"toml_edit 0.19.15",
5661+
]
5662+
5663+
[[package]]
5664+
name = "toml"
5665+
version = "0.8.13"
5666+
source = "registry+https://github.com/rust-lang/crates.io-index"
5667+
checksum = "a4e43f8cc456c9704c851ae29c67e17ef65d2c30017c17a9765b89c382dc8bba"
5668+
dependencies = [
5669+
"serde",
5670+
"serde_spanned",
5671+
"toml_datetime",
5672+
"toml_edit 0.22.13",
55625673
]
55635674

55645675
[[package]]
@@ -5580,7 +5691,20 @@ dependencies = [
55805691
"serde",
55815692
"serde_spanned",
55825693
"toml_datetime",
5583-
"winnow",
5694+
"winnow 0.5.40",
5695+
]
5696+
5697+
[[package]]
5698+
name = "toml_edit"
5699+
version = "0.22.13"
5700+
source = "registry+https://github.com/rust-lang/crates.io-index"
5701+
checksum = "c127785850e8c20836d49732ae6abfa47616e60bf9d9f57c43c250361a9db96c"
5702+
dependencies = [
5703+
"indexmap",
5704+
"serde",
5705+
"serde_spanned",
5706+
"toml_datetime",
5707+
"winnow 0.6.8",
55845708
]
55855709

55865710
[[package]]
@@ -5990,6 +6114,15 @@ version = "0.9.4"
59906114
source = "registry+https://github.com/rust-lang/crates.io-index"
59916115
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
59926116

6117+
[[package]]
6118+
name = "wait-timeout"
6119+
version = "0.2.0"
6120+
source = "registry+https://github.com/rust-lang/crates.io-index"
6121+
checksum = "9f200f5b12eb75f8c1ed65abd4b2db8a6e1b138a20de009dacee265a2498f3f6"
6122+
dependencies = [
6123+
"libc",
6124+
]
6125+
59936126
[[package]]
59946127
name = "walkdir"
59956128
version = "2.5.0"
@@ -6302,6 +6435,15 @@ dependencies = [
63026435
"memchr",
63036436
]
63046437

6438+
[[package]]
6439+
name = "winnow"
6440+
version = "0.6.8"
6441+
source = "registry+https://github.com/rust-lang/crates.io-index"
6442+
checksum = "c3c52e9c97a68071b23e836c9380edae937f17b9c4667bd021973efc689f618d"
6443+
dependencies = [
6444+
"memchr",
6445+
]
6446+
63056447
[[package]]
63066448
name = "writeable"
63076449
version = "0.5.4"
@@ -6319,6 +6461,12 @@ dependencies = [
63196461
"rustix",
63206462
]
63216463

6464+
[[package]]
6465+
name = "xmlparser"
6466+
version = "0.13.6"
6467+
source = "registry+https://github.com/rust-lang/crates.io-index"
6468+
checksum = "66fee0b777b0f5ac1c69bb06d361268faafa61cd4682ae064a171c16c433e9e4"
6469+
63226470
[[package]]
63236471
name = "xz2"
63246472
version = "0.1.7"

src/doc/book

Submodule book updated 112 files

src/tools/rustbook/Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ edition = "2021"
77
[dependencies]
88
clap = "4.0.32"
99
env_logger = "0.11"
10+
mdbook-trpl-listing = { path = "../../doc/book/packages/mdbook-trpl-listing" }
11+
mdbook-trpl-note = { path = "../../doc/book/packages/mdbook-trpl-note" }
1012

1113
[dependencies.mdbook]
1214
version = "0.4.37"

src/tools/rustbook/src/main.rs

+11
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ use clap::{arg, ArgMatches, Command};
88
use mdbook::errors::Result as Result3;
99
use mdbook::MDBook;
1010

11+
use mdbook_trpl_listing::TrplListing;
12+
use mdbook_trpl_note::TrplNote;
13+
1114
fn main() {
1215
let crate_version = concat!("v", crate_version!());
1316
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("warn")).init();
@@ -67,6 +70,14 @@ pub fn build(args: &ArgMatches) -> Result3<()> {
6770
book.config.build.build_dir = dest_dir.into();
6871
}
6972

73+
if book.config.get_preprocessor("trpl-note").is_some() {
74+
book.with_preprocessor(TrplNote);
75+
}
76+
77+
if book.config.get_preprocessor("trpl-listing").is_some() {
78+
book.with_preprocessor(TrplListing);
79+
}
80+
7081
book.build()?;
7182

7283
Ok(())

0 commit comments

Comments
 (0)