Fixing tests and format
`cargo test` and `cargo fmt --check` pass.
This commit is contained in:
parent
e166a1f2a4
commit
ac295bbfcc
|
@ -202,7 +202,11 @@ impl MDBook {
|
|||
}
|
||||
|
||||
/// Run the entire build process for a particular [`Renderer`].
|
||||
pub fn execute_build_process(&self, renderer: &dyn Renderer, translation: Option<&str>) -> Result<()> {
|
||||
pub fn execute_build_process(
|
||||
&self,
|
||||
renderer: &dyn Renderer,
|
||||
translation: Option<&str>,
|
||||
) -> Result<()> {
|
||||
let mut preprocessed_book = self.book.clone();
|
||||
let mut config = self.config.clone();
|
||||
if let Some(translation) = translation {
|
||||
|
@ -228,21 +232,21 @@ impl MDBook {
|
|||
build_dir = build_dir.join(translation);
|
||||
}
|
||||
|
||||
let mut render_context = RenderContext::new(
|
||||
self.root.clone(),
|
||||
preprocessed_book,
|
||||
config,
|
||||
build_dir,
|
||||
);
|
||||
let mut render_context =
|
||||
RenderContext::new(self.root.clone(), preprocessed_book, config, build_dir);
|
||||
render_context
|
||||
.chapter_titles
|
||||
.extend(preprocess_ctx.chapter_titles.borrow_mut().drain());
|
||||
|
||||
info!("Running the {}{} backend", renderer.name(), if let Some(translation) = translation {
|
||||
format!("[{}]", translation)
|
||||
} else {
|
||||
"".to_string()
|
||||
});
|
||||
info!(
|
||||
"Running the {}{} backend",
|
||||
renderer.name(),
|
||||
if let Some(translation) = translation {
|
||||
format!("[{}]", translation)
|
||||
} else {
|
||||
"".to_string()
|
||||
}
|
||||
);
|
||||
renderer
|
||||
.render(&render_context)
|
||||
.with_context(|| "Rendering failed")
|
||||
|
|
|
@ -772,6 +772,7 @@ mod tests {
|
|||
multilingual: true,
|
||||
src: PathBuf::from("source"),
|
||||
language: Some(String::from("ja")),
|
||||
..Default::default()
|
||||
};
|
||||
let build_should_be = BuildConfig {
|
||||
build_dir: PathBuf::from("outputs"),
|
||||
|
|
|
@ -637,10 +637,7 @@ fn make_data(
|
|||
json!(config.book.language.clone().unwrap_or_default()),
|
||||
);
|
||||
if !config.book.translations.is_empty() {
|
||||
data.insert(
|
||||
"translations".to_owned(),
|
||||
json!(config.book.translations),
|
||||
);
|
||||
data.insert("translations".to_owned(), json!(config.book.translations));
|
||||
}
|
||||
data.insert(
|
||||
"book_title".to_owned(),
|
||||
|
|
|
@ -29,7 +29,7 @@ fn base_mdbook_init_should_create_default_content() {
|
|||
let contents = fs::read_to_string(temp.path().join("book.toml")).unwrap();
|
||||
assert_eq!(
|
||||
contents,
|
||||
"[book]\nauthors = []\nlanguage = \"en\"\nmultilingual = false\nsrc = \"src\"\n"
|
||||
"[book]\nauthors = []\nlanguage = \"en\"\nmultilingual = false\nsrc = \"src\"\ntranslations = []\n"
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -96,7 +96,7 @@ fn run_mdbook_init_with_custom_book_and_src_locations() {
|
|||
let contents = fs::read_to_string(temp.path().join("book.toml")).unwrap();
|
||||
assert_eq!(
|
||||
contents,
|
||||
"[book]\nauthors = []\nlanguage = \"en\"\nmultilingual = false\nsrc = \"in\"\n\n[build]\nbuild-dir = \"out\"\ncreate-missing = true\nextra-watch-dirs = []\nuse-default-preprocessors = true\n"
|
||||
"[book]\nauthors = []\nlanguage = \"en\"\nmultilingual = false\nsrc = \"in\"\ntranslations = []\n\n[build]\nbuild-dir = \"out\"\ncreate-missing = true\nextra-watch-dirs = []\nuse-default-preprocessors = true\n"
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue