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 {
process::exit(1);
}
}
}

@ -9,7 +9,7 @@ use mdbook::BookItem;
use crate::utils::{FileReader, SystemFileReader};
mod links;
mod utils;
pub mod utils;
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,
file_reader: &FR,
base: P1,
@ -296,4 +296,4 @@ mod lib_tests {
assert_eq!(actual_chapter_content, start_chapter_content);
}
}
}

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

@ -4,16 +4,16 @@ use std::path::{Path, PathBuf};
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>;
}
#[derive(PartialEq, Debug, Clone, Default)]
pub(crate) struct SystemFileReader;
#[derive(PartialEq, Eq, Debug, Clone, Default)]
pub struct SystemFileReader;
#[derive(PartialEq, Debug, Clone, Default)]
pub(crate) struct TestFileReader {
pub(crate) captured_contents: HashMap<PathBuf, String>,
#[derive(PartialEq, Eq, Debug, Clone, Default)]
pub struct TestFileReader {
pub captured_contents: HashMap<PathBuf, String>,
}
impl FileReader for SystemFileReader {
@ -47,4 +47,4 @@ impl FileReader for TestFileReader {
))),
}
}
}
}

Loading…
Cancel
Save