From c9ddb4dd98b96e280d155f9f0763aff6788a5916 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Mon, 5 May 2025 14:01:49 -0700 Subject: [PATCH 1/2] Revert: Remove the book.multilingual field This reverts https://github.com/rust-lang/mdBook/pull/2646/ because I overlooked that this is a public field in a public struct, which would be a breaking API change. --- examples/nop-preprocessor.rs | 1 + src/config.rs | 5 +++++ tests/testsuite/init.rs | 4 ++++ tests/testsuite/renderer.rs | 1 + 4 files changed, 11 insertions(+) diff --git a/examples/nop-preprocessor.rs b/examples/nop-preprocessor.rs index f194991a8e..a384dfdafb 100644 --- a/examples/nop-preprocessor.rs +++ b/examples/nop-preprocessor.rs @@ -117,6 +117,7 @@ mod nop_lib { "book": { "authors": ["AUTHOR"], "language": "en", + "multilingual": false, "src": "src", "title": "TITLE" }, diff --git a/src/config.rs b/src/config.rs index 2ede0c2f92..db159a45ad 100644 --- a/src/config.rs +++ b/src/config.rs @@ -420,6 +420,8 @@ pub struct BookConfig { pub description: Option, /// Location of the book source relative to the book's root directory. pub src: PathBuf, + /// Does this book support more than one language? + pub multilingual: bool, /// The main language of the book. pub language: Option, /// The direction of text in the book: Left-to-right (LTR) or Right-to-left (RTL). @@ -434,6 +436,7 @@ impl Default for BookConfig { authors: Vec::new(), description: None, src: PathBuf::from("src"), + multilingual: false, language: Some(String::from("en")), text_direction: None, } @@ -817,6 +820,7 @@ mod tests { title = "Some Book" authors = ["Michael-F-Bryan "] description = "A completely useless book" + multilingual = true src = "source" language = "ja" @@ -855,6 +859,7 @@ mod tests { title: Some(String::from("Some Book")), authors: vec![String::from("Michael-F-Bryan ")], description: Some(String::from("A completely useless book")), + multilingual: true, src: PathBuf::from("source"), language: Some(String::from("ja")), text_direction: None, diff --git a/tests/testsuite/init.rs b/tests/testsuite/init.rs index e5989eb62c..a5e1e28b3e 100644 --- a/tests/testsuite/init.rs +++ b/tests/testsuite/init.rs @@ -28,6 +28,7 @@ All done, no errors... [book] authors = [] language = "en" +multilingual = false src = "src" "#]], @@ -94,6 +95,7 @@ All done, no errors... [book] authors = [] language = "en" +multilingual = false src = "src" "#]], @@ -127,6 +129,7 @@ All done, no errors... [book] authors = [] language = "en" +multilingual = false src = "src" title = "Example title" @@ -179,6 +182,7 @@ fn init_with_custom_book_and_src_locations() { [book] authors = [] language = "en" +multilingual = false src = "in" [build] diff --git a/tests/testsuite/renderer.rs b/tests/testsuite/renderer.rs index 1e1624474f..e893dd2f5e 100644 --- a/tests/testsuite/renderer.rs +++ b/tests/testsuite/renderer.rs @@ -188,6 +188,7 @@ fn backends_receive_render_context_via_stdin() { "book": { "authors": [], "language": "en", + "multilingual": false, "src": "src" }, "output": { From 3c10b00096f811a720e6076ee0b4624c2a9f551c Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Mon, 5 May 2025 14:05:00 -0700 Subject: [PATCH 2/2] Skip serializing of the multilingual field This skips serializing of the multilingual field since it is unused, and we plan to remove it in the future. This helps avoid it showing up in `mdbook init`. --- src/config.rs | 3 +++ tests/testsuite/init.rs | 4 ---- tests/testsuite/renderer.rs | 1 - 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/config.rs b/src/config.rs index db159a45ad..7ef8bcef12 100644 --- a/src/config.rs +++ b/src/config.rs @@ -421,6 +421,9 @@ pub struct BookConfig { /// Location of the book source relative to the book's root directory. pub src: PathBuf, /// Does this book support more than one language? + // TODO: Remove this field in 0.5, it is unused: + // https://github.com/rust-lang/mdBook/issues/2636 + #[serde(skip_serializing)] pub multilingual: bool, /// The main language of the book. pub language: Option, diff --git a/tests/testsuite/init.rs b/tests/testsuite/init.rs index a5e1e28b3e..e5989eb62c 100644 --- a/tests/testsuite/init.rs +++ b/tests/testsuite/init.rs @@ -28,7 +28,6 @@ All done, no errors... [book] authors = [] language = "en" -multilingual = false src = "src" "#]], @@ -95,7 +94,6 @@ All done, no errors... [book] authors = [] language = "en" -multilingual = false src = "src" "#]], @@ -129,7 +127,6 @@ All done, no errors... [book] authors = [] language = "en" -multilingual = false src = "src" title = "Example title" @@ -182,7 +179,6 @@ fn init_with_custom_book_and_src_locations() { [book] authors = [] language = "en" -multilingual = false src = "in" [build] diff --git a/tests/testsuite/renderer.rs b/tests/testsuite/renderer.rs index e893dd2f5e..1e1624474f 100644 --- a/tests/testsuite/renderer.rs +++ b/tests/testsuite/renderer.rs @@ -188,7 +188,6 @@ fn backends_receive_render_context_via_stdin() { "book": { "authors": [], "language": "en", - "multilingual": false, "src": "src" }, "output": {