diff --git a/src/main.rs b/src/main.rs index cc4eab2..94b1c56 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,8 +1,5 @@ use config::CONFIG_NAME; use std::{fs, path::Path}; -use yaml_rust::Yaml; - -use crate::config::{INPUT_KEY, OUTPUT_KEY}; mod config; mod generator; @@ -11,13 +8,6 @@ mod processor; mod sidebar; mod utils; -/// Creates a `YAML::String` from a `&str` -macro_rules! ystr { - ($str:literal) => { - &Yaml::String(String::from($str)) - }; -} - fn main() { let config_file = Path::new(CONFIG_NAME); if !config_file.is_dir() { diff --git a/src/pages/md_compiler.rs b/src/pages/md_compiler.rs index 80e99cf..8e8d165 100644 --- a/src/pages/md_compiler.rs +++ b/src/pages/md_compiler.rs @@ -4,14 +4,14 @@ use std::{ path::{Path, PathBuf}, }; -use crate::{generator::Printable, sidebar::SidebarGenerator, config::Config}; +use crate::{config::Config, generator::Printable, sidebar::SidebarGenerator}; /// ## Parameters /// /// - `config`: Config struct with the parsed values /// - `file`: Path to the MD file to compile /// - `file_tree_html`: HTML code of the file tree to be inserted into the generated HTML -pub fn compile(config: &Config,file: &PathBuf, file_tree_html: &String) { +pub fn compile(config: &Config, file: &PathBuf, file_tree_html: &String) { let input_folder = Path::new(&config.input); let output_folder = Path::new(&config.output); diff --git a/src/pages/mod.rs b/src/pages/mod.rs index dca7a9f..fb343ed 100644 --- a/src/pages/mod.rs +++ b/src/pages/mod.rs @@ -2,7 +2,7 @@ use std::path::Path; use yaml_rust::Yaml; -use crate::{utils, config::{self, Config}}; +use crate::{config::Config, utils}; mod md_compiler; @@ -24,7 +24,7 @@ pub struct Folder<'a> { /// Display name of the folder name: &'a String, /// If true, then there MUST be a `File {path: "index"}` in the `children` field - has_index: bool, + _has_index: bool, /// Sub files or folders children: Box>>, } @@ -72,7 +72,7 @@ pub fn parse_yaml(values: &Yaml) -> Node { Node::Folder(Folder { path, name, - has_index, + _has_index: has_index, children: Box::new(children_nodes), }) } @@ -160,12 +160,7 @@ pub fn compile_md_to_html( } Node::Folder(folder) => { for node in folder.children.iter() { - compile_md_to_html( - config, - node, - ¤t_path, - file_tree_html, - ); + compile_md_to_html(config, node, ¤t_path, file_tree_html); } } } diff --git a/src/processor.rs b/src/processor.rs index 91b73be..6d69082 100644 --- a/src/processor.rs +++ b/src/processor.rs @@ -67,7 +67,6 @@ pub fn search_config_file_impl(config: &Config, current_folder: &Path) { fn process_yaml(config: &Config, current_path: &Path) { let input_folder = Path::new(&config.input); - let output_folder = Path::new(&config.output); // // Read YAML file @@ -101,10 +100,5 @@ fn process_yaml(config: &Config, current_path: &Path) { // // Compile MD to HTML // - compile_md_to_html( - config, - &file_tree, - current_path, - &tree_html, - ); + compile_md_to_html(config, &file_tree, current_path, &tree_html); } diff --git a/src/utils.rs b/src/utils.rs index f31763c..190fd74 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -2,7 +2,7 @@ use std::{fs, path::Path}; use markdown::mdast::Node; -use crate::{generator::Printable, config::{self, Config}}; +use crate::{config::Config, generator::Printable}; pub fn to_html_fragment(text: &String) -> String { text.clone().replace(" ", "-") @@ -28,10 +28,7 @@ pub fn collect_children_text(vec: &Vec) -> String { result.join("-") } -pub fn ensure_folder_exists( - config: &Config, - folder: &Path, -) -> Result<(), String> { +pub fn ensure_folder_exists(config: &Config, folder: &Path) -> Result<(), String> { let input_folder = Path::new(&config.input); let output_folder = Path::new(&config.output);