Make `replace_template` and content of `utils.rs` public (#6)

pull/7/head
AlianBenabdallah 2 years ago committed by GitHub
parent 5da7959545
commit 8a3928f0e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -61,4 +61,4 @@ fn handle_supports(pre: &Template, sub_args: &ArgMatches) -> ! {
} else { } else {
process::exit(1); process::exit(1);
} }
} }

@ -9,7 +9,7 @@ use mdbook::BookItem;
use crate::utils::{FileReader, SystemFileReader}; use crate::utils::{FileReader, SystemFileReader};
mod links; mod links;
mod utils; pub mod utils;
const MAX_LINK_NESTED_DEPTH: usize = 10; const MAX_LINK_NESTED_DEPTH: usize = 10;
@ -58,7 +58,7 @@ impl Preprocessor for Template {
} }
} }
fn replace_template<P1, P2, FR>( pub fn replace_template<P1, P2, FR>(
chapter_content: &str, chapter_content: &str,
file_reader: &FR, file_reader: &FR,
base: P1, base: P1,
@ -296,4 +296,4 @@ mod lib_tests {
assert_eq!(actual_chapter_content, start_chapter_content); assert_eq!(actual_chapter_content, start_chapter_content);
} }
} }

@ -708,4 +708,4 @@ year=2022
end end
); );
} }
} }

@ -4,16 +4,16 @@ use std::path::{Path, PathBuf};
use anyhow::{Context, Error, Result}; use anyhow::{Context, Error, Result};
pub(crate) trait FileReader { pub trait FileReader {
fn read_to_string(&self, file_name: &Path, template_text: &str) -> Result<String>; fn read_to_string(&self, file_name: &Path, template_text: &str) -> Result<String>;
} }
#[derive(PartialEq, Debug, Clone, Default)] #[derive(PartialEq, Eq, Debug, Clone, Default)]
pub(crate) struct SystemFileReader; pub struct SystemFileReader;
#[derive(PartialEq, Debug, Clone, Default)] #[derive(PartialEq, Eq, Debug, Clone, Default)]
pub(crate) struct TestFileReader { pub struct TestFileReader {
pub(crate) captured_contents: HashMap<PathBuf, String>, pub captured_contents: HashMap<PathBuf, String>,
} }
impl FileReader for SystemFileReader { impl FileReader for SystemFileReader {
@ -47,4 +47,4 @@ impl FileReader for TestFileReader {
))), ))),
} }
} }
} }

Loading…
Cancel
Save