Fix warnings

master
Araozu 2023-06-25 19:44:22 -05:00
parent 50085e8ce2
commit 284e547acd
5 changed files with 9 additions and 33 deletions

View File

@ -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() {

View File

@ -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);

View File

@ -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<Vec<Node<'a>>>,
}
@ -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,
&current_path,
file_tree_html,
);
compile_md_to_html(config, node, &current_path, file_tree_html);
}
}
}

View File

@ -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);
}

View File

@ -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<Node>) -> 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);