diff options
Diffstat (limited to 'src/new/figure.rs')
-rw-r--r-- | src/new/figure.rs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/new/figure.rs b/src/new/figure.rs new file mode 100644 index 0000000..3099f94 --- /dev/null +++ b/src/new/figure.rs @@ -0,0 +1,28 @@ +use std::path::Path; + +use crate::{ + config_file::Config, + file_tree::{FileTree, GeneratedFile}, +}; + +use super::{replacement::untemplatize_figure, MangledName}; + +pub fn generate_new_figure( + config: &Config, + name: String, + project_root: &Path, +) -> anyhow::Result<FileTree> { + let mut file_tree = FileTree::new(); + + let new_figure_text = untemplatize_figure(&config.templates.figure, &name); + + file_tree.add_file(GeneratedFile::new_clobber( + project_root + .join("figures") + .join(format!("{}.tex", MangledName::new(&name))), + new_figure_text, + false, + )); + + Ok(file_tree) +} |