Skip to content

Commit 50fb4a0

Browse files
committed
chore(deps): upgrade mdbook to v0.5.0
1 parent c252ebb commit 50fb4a0

23 files changed

+235
-249
lines changed

Cargo.lock

Lines changed: 146 additions & 159 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ env_logger = "0.11.0"
2222
html5ever = "0.31.0"
2323
indexmap = { version = "2.7.0", features = ["serde"] }
2424
log = "0.4.0"
25-
mdbook = { version = "0.4.35", default-features = false }
25+
mdbook = { package = "mdbook-renderer", git = "https://github.com/rust-lang/mdBook", default-features = false }
2626
normpath = "1.0.0"
2727
once_cell = "1.0.0"
2828
pulldown-cmark = { version = "0.13.0", default-features = false }
@@ -40,6 +40,7 @@ walkdir = "2.0.0"
4040
[dev-dependencies]
4141
indoc = "2.0.5"
4242
insta = { version = "1.36.0" }
43+
mdbook-driver = { git = "https://github.com/rust-lang/mdBook", default-features = false }
4344
similar = { version = "2.5.0", features = ["text"] }
4445
tracing = { version = "0.1.0", default-features = false, features = ["std"] }
4546
tracing-log = "0.2.0"

src/book.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pub struct Book<'book> {
1010
}
1111

1212
impl<'book> Book<'book> {
13-
pub fn new(ctx: &'book mdbook::renderer::RenderContext) -> anyhow::Result<Self> {
13+
pub fn new(ctx: &'book mdbook::RenderContext) -> anyhow::Result<Self> {
1414
let root = ctx.root.normalize()?.into_path_buf();
1515
let source_dir = ctx.source_dir().normalize()?.into_path_buf();
1616

src/lib.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ impl mdbook::Renderer for Renderer {
102102
Self::NAME
103103
}
104104

105-
fn render(&self, ctx: &mdbook::renderer::RenderContext) -> anyhow::Result<()> {
105+
fn render(&self, ctx: &mdbook::RenderContext) -> anyhow::Result<()> {
106106
// If we're compiled against mdbook version I.J.K, require ^I.J
107107
// This allows using a version of mdbook with an earlier patch version as a server
108108
static MDBOOK_VERSION_REQ: Lazy<semver::VersionReq> = Lazy::new(|| {
@@ -112,8 +112,10 @@ impl mdbook::Renderer for Renderer {
112112
op: semver::Op::Caret,
113113
major: compiled_mdbook_version.major,
114114
minor: Some(compiled_mdbook_version.minor),
115-
patch: None,
116-
pre: Default::default(),
115+
// Preleases are only compatible with identical patch versions
116+
patch: (!compiled_mdbook_version.pre.is_empty())
117+
.then_some(compiled_mdbook_version.patch),
118+
pre: compiled_mdbook_version.pre,
117119
}],
118120
}
119121
});
@@ -129,7 +131,7 @@ impl mdbook::Renderer for Renderer {
129131

130132
let cfg: Config = ctx
131133
.config
132-
.get_deserialized_opt(Self::CONFIG_KEY)
134+
.get(Self::CONFIG_KEY)
133135
.with_context(|| format!("Unable to deserialize {}", Self::CONFIG_KEY))?
134136
.ok_or(anyhow!("No {} table found", Self::CONFIG_KEY))?;
135137

@@ -140,10 +142,7 @@ impl mdbook::Renderer for Renderer {
140142

141143
pandoc::check_compatibility()?;
142144

143-
let html_cfg: Option<HtmlConfig> = ctx
144-
.config
145-
.get_deserialized_opt("output.html")
146-
.unwrap_or_default();
145+
let html_cfg: Option<HtmlConfig> = ctx.config.get("output.html").unwrap_or_default();
147146

148147
let book = Book::new(ctx)?;
149148

src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ fn main() {
1717
fn try_main() -> anyhow::Result<()> {
1818
init_logger();
1919

20-
let ctx = mdbook::renderer::RenderContext::from_json(io::stdin().lock())
20+
let ctx = mdbook::RenderContext::from_json(io::stdin().lock())
2121
.context("unable to parse mdBook context")?;
2222
mdbook_pandoc::Renderer::new().render(&ctx)
2323
}

src/pandoc/renderer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub struct Context<'book> {
2323
pub output: OutputFormat,
2424
pub destination: PathBuf,
2525
pub book: &'book Book<'book>,
26-
pub mdbook_cfg: &'book mdbook::Config,
26+
pub mdbook_cfg: &'book mdbook::config::Config,
2727
pub columns: usize,
2828
pub cur_list_depth: usize,
2929
pub max_list_depth: usize,

src/preprocess.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@ use anyhow::{anyhow, Context};
1717
use ego_tree::NodeId;
1818
use html5ever::{expanded_name, local_name, ns, tendril::format_tendril};
1919
use log::log;
20-
use mdbook::{
21-
book::{BookItems, Chapter},
22-
BookItem,
23-
};
20+
use mdbook::book::{BookItem, BookItems, Chapter};
2421
use normpath::PathExt;
2522
use once_cell::sync::Lazy;
2623
use pulldown_cmark::{CowStr, Event, HeadingLevel, LinkType, Tag, TagEnd};

src/tests/basic.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ fn basic() {
1111
.build();
1212
insta::assert_snapshot!(book, @r"
1313
├─ log output
14-
│ INFO mdbook::book: Running the pandoc backend
14+
│ INFO mdbook_driver::mdbook: Running the pandoc backend
1515
│ INFO mdbook_pandoc::pandoc::renderer: Running pandoc
1616
│ INFO mdbook_pandoc::pandoc::renderer: Wrote output to book/markdown/book.md
1717
├─ markdown/book.md
@@ -27,7 +27,7 @@ fn strikethrough() {
2727
.build();
2828
insta::assert_snapshot!(book, @r#"
2929
├─ log output
30-
│ INFO mdbook::book: Running the pandoc backend
30+
│ INFO mdbook_driver::mdbook: Running the pandoc backend
3131
│ INFO mdbook_pandoc::pandoc::renderer: Running pandoc
3232
│ INFO mdbook_pandoc::pandoc::renderer: Wrote output to book/latex/output.tex
3333
├─ latex/output.tex
@@ -49,7 +49,7 @@ fn task_lists() {
4949
.build();
5050
insta::assert_snapshot!(book, @r#"
5151
├─ log output
52-
│ INFO mdbook::book: Running the pandoc backend
52+
│ INFO mdbook_driver::mdbook: Running the pandoc backend
5353
│ INFO mdbook_pandoc::pandoc::renderer: Running pandoc
5454
│ INFO mdbook_pandoc::pandoc::renderer: Wrote output to book/latex/output.tex
5555
├─ latex/output.tex

src/tests/code.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ fn code_escaping() {
3131
.build();
3232
insta::assert_snapshot!(book, @r###"
3333
├─ log output
34-
│ INFO mdbook::book: Running the pandoc backend
34+
│ INFO mdbook_driver::mdbook: Running the pandoc backend
3535
│ INFO mdbook_pandoc::pandoc::renderer: Running pandoc
3636
│ INFO mdbook_pandoc::pandoc::renderer: Wrote output to book/markdown/pandoc-ir
3737
├─ markdown/pandoc-ir
@@ -89,7 +89,7 @@ fn code_block_with_hidden_lines() {
8989
.build();
9090
insta::assert_snapshot!(book, @r#"
9191
├─ log output
92-
│ INFO mdbook::book: Running the pandoc backend
92+
│ INFO mdbook_driver::mdbook: Running the pandoc backend
9393
│ INFO mdbook_pandoc::pandoc::renderer: Running pandoc
9494
│ INFO mdbook_pandoc::pandoc::renderer: Wrote output to book/markdown/book.md
9595
├─ markdown/book.md
@@ -113,7 +113,7 @@ fn code_block_with_hidden_lines() {
113113
.build();
114114
insta::assert_snapshot!(book, @r#"
115115
├─ log output
116-
│ INFO mdbook::book: Running the pandoc backend
116+
│ INFO mdbook_driver::mdbook: Running the pandoc backend
117117
│ INFO mdbook_pandoc::pandoc::renderer: Running pandoc
118118
│ INFO mdbook_pandoc::pandoc::renderer: Wrote output to book/markdown/book.md
119119
├─ markdown/book.md
@@ -156,7 +156,7 @@ fn non_rust_code_block_with_hidden_lines() {
156156
.build();
157157
insta::assert_snapshot!(book, @r"
158158
├─ log output
159-
│ INFO mdbook::book: Running the pandoc backend
159+
│ INFO mdbook_driver::mdbook: Running the pandoc backend
160160
│ INFO mdbook_pandoc::pandoc::renderer: Running pandoc
161161
│ INFO mdbook_pandoc::pandoc::renderer: Wrote output to book/markdown/book.md
162162
├─ markdown/book.md
@@ -177,7 +177,7 @@ fn non_rust_code_block_with_hidden_lines() {
177177
.build();
178178
insta::assert_snapshot!(book, @r"
179179
├─ log output
180-
│ INFO mdbook::book: Running the pandoc backend
180+
│ INFO mdbook_driver::mdbook: Running the pandoc backend
181181
│ INFO mdbook_pandoc::pandoc::renderer: Running pandoc
182182
│ INFO mdbook_pandoc::pandoc::renderer: Wrote output to book/markdown/book.md
183183
├─ markdown/book.md
@@ -208,7 +208,7 @@ fn code_block_hidelines_override() {
208208
.build();
209209
insta::assert_snapshot!(book, @r"
210210
├─ log output
211-
│ INFO mdbook::book: Running the pandoc backend
211+
│ INFO mdbook_driver::mdbook: Running the pandoc backend
212212
│ INFO mdbook_pandoc::pandoc::renderer: Running pandoc
213213
│ INFO mdbook_pandoc::pandoc::renderer: Wrote output to book/markdown/book.md
214214
├─ markdown/book.md
@@ -285,7 +285,7 @@ fn mdbook_rust_code_block_attributes() {
285285
.build();
286286
insta::assert_snapshot!(book, @r#"
287287
├─ log output
288-
│ INFO mdbook::book: Running the pandoc backend
288+
│ INFO mdbook_driver::mdbook: Running the pandoc backend
289289
│ INFO mdbook_pandoc::pandoc::renderer: Running pandoc
290290
│ INFO mdbook_pandoc::pandoc::renderer: Wrote output to book/latex/output.tex
291291
├─ latex/output.tex
@@ -319,7 +319,7 @@ fn mdbook_rust_code_block_attributes() {
319319
.build();
320320
insta::assert_snapshot!(book, @r##"
321321
├─ log output
322-
│ INFO mdbook::book: Running the pandoc backend
322+
│ INFO mdbook_driver::mdbook: Running the pandoc backend
323323
│ INFO mdbook_pandoc::pandoc::renderer: Running pandoc
324324
│ INFO mdbook_pandoc::pandoc::renderer: Wrote output to book/html/book.html
325325
├─ html/book.html
@@ -345,7 +345,7 @@ fn regression_inline_code_newline() {
345345
.build();
346346
insta::assert_snapshot!(book, @r#"
347347
├─ log output
348-
│ INFO mdbook::book: Running the pandoc backend
348+
│ INFO mdbook_driver::mdbook: Running the pandoc backend
349349
│ INFO mdbook_pandoc::pandoc::renderer: Running pandoc
350350
│ INFO mdbook_pandoc::pandoc::renderer: Wrote output to book/markdown/pandoc-ir
351351
├─ markdown/pandoc-ir

src/tests/config.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ fn disabled() {
1111
disabled = true
1212
"#};
1313
let output = MDBook::init()
14-
.mdbook_config(mdbook::Config::from_str(cfg).unwrap())
14+
.mdbook_config(mdbook::config::Config::from_str(cfg).unwrap())
1515
.build();
16-
insta::assert_snapshot!(output, @r###"
16+
insta::assert_snapshot!(output, @r"
1717
├─ log output
18-
│ INFO mdbook::book: Running the pandoc backend
19-
│ INFO mdbook_pandoc: Skipping rendering since `disabled` is set
20-
"###)
18+
│ INFO mdbook_driver::mdbook: Running the pandoc backend
19+
│ INFO mdbook_pandoc: Skipping rendering since `disabled` is set
20+
")
2121
}
2222

2323
#[test]
@@ -33,7 +33,7 @@ fn pandoc_working_dir_is_root() {
3333
.build();
3434
insta::assert_snapshot!(book, @r"
3535
├─ log output
36-
│ INFO mdbook::book: Running the pandoc backend
36+
│ INFO mdbook_driver::mdbook: Running the pandoc backend
3737
│ INFO mdbook_pandoc::pandoc::renderer: Running pandoc
3838
│ INFO mdbook_pandoc::pandoc::renderer: Wrote output to book/foo/foo.md
3939
├─ foo/foo.md
@@ -73,13 +73,13 @@ fn raw_opts() {
7373
let output = MDBook::options()
7474
.max_log_level(tracing::Level::TRACE)
7575
.init()
76-
.mdbook_config(mdbook::Config::from_str(cfg).unwrap())
76+
.mdbook_config(mdbook::config::Config::from_str(cfg).unwrap())
7777
.build();
7878
insta::assert_snapshot!(output, @r#"
7979
├─ log output
80-
│ DEBUG mdbook::book: Running the index preprocessor.
81-
│ DEBUG mdbook::book: Running the links preprocessor.
82-
│ INFO mdbook::book: Running the pandoc backend
80+
│ DEBUG mdbook_driver::mdbook: Running the index preprocessor.
81+
│ DEBUG mdbook_driver::mdbook: Running the links preprocessor.
82+
│ INFO mdbook_driver::mdbook: Running the pandoc backend
8383
│ TRACE mdbook_pandoc::pandoc::renderer: Running pandoc with profile: Profile {
8484
│ columns: 72,
8585
│ file_scope: true,

0 commit comments

Comments
 (0)