From 8a3928f0e7cd379b0c012716364efd1308bd5f3e Mon Sep 17 00:00:00 2001 From: AlianBenabdallah <92268577+AlianBenabdallah@users.noreply.github.com> Date: Fri, 16 Sep 2022 00:23:10 +0200 Subject: [PATCH] Make `replace_template` and content of `utils.rs` public (#6) --- src/bin/mdbook-template.rs | 2 +- src/lib.rs | 6 +++--- src/links.rs | 2 +- src/utils.rs | 14 +++++++------- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/bin/mdbook-template.rs b/src/bin/mdbook-template.rs index a9776f4..a6e3d25 100644 --- a/src/bin/mdbook-template.rs +++ b/src/bin/mdbook-template.rs @@ -61,4 +61,4 @@ fn handle_supports(pre: &Template, sub_args: &ArgMatches) -> ! { } else { process::exit(1); } -} \ No newline at end of file +} diff --git a/src/lib.rs b/src/lib.rs index 1284114..725b560 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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( +pub fn replace_template( chapter_content: &str, file_reader: &FR, base: P1, @@ -296,4 +296,4 @@ mod lib_tests { assert_eq!(actual_chapter_content, start_chapter_content); } -} \ No newline at end of file +} diff --git a/src/links.rs b/src/links.rs index 77ff059..b5d42cf 100644 --- a/src/links.rs +++ b/src/links.rs @@ -708,4 +708,4 @@ year=2022 end ); } -} \ No newline at end of file +} diff --git a/src/utils.rs b/src/utils.rs index 5b32eee..271b85e 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -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; } -#[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, +#[derive(PartialEq, Eq, Debug, Clone, Default)] +pub struct TestFileReader { + pub captured_contents: HashMap, } impl FileReader for SystemFileReader { @@ -47,4 +47,4 @@ impl FileReader for TestFileReader { ))), } } -} \ No newline at end of file +}