Fix warnings
This commit is contained in:
parent
50085e8ce2
commit
284e547acd
10
src/main.rs
10
src/main.rs
@ -1,8 +1,5 @@
|
|||||||
use config::CONFIG_NAME;
|
use config::CONFIG_NAME;
|
||||||
use std::{fs, path::Path};
|
use std::{fs, path::Path};
|
||||||
use yaml_rust::Yaml;
|
|
||||||
|
|
||||||
use crate::config::{INPUT_KEY, OUTPUT_KEY};
|
|
||||||
|
|
||||||
mod config;
|
mod config;
|
||||||
mod generator;
|
mod generator;
|
||||||
@ -11,13 +8,6 @@ mod processor;
|
|||||||
mod sidebar;
|
mod sidebar;
|
||||||
mod utils;
|
mod utils;
|
||||||
|
|
||||||
/// Creates a `YAML::String` from a `&str`
|
|
||||||
macro_rules! ystr {
|
|
||||||
($str:literal) => {
|
|
||||||
&Yaml::String(String::from($str))
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let config_file = Path::new(CONFIG_NAME);
|
let config_file = Path::new(CONFIG_NAME);
|
||||||
if !config_file.is_dir() {
|
if !config_file.is_dir() {
|
||||||
|
@ -4,14 +4,14 @@ use std::{
|
|||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{generator::Printable, sidebar::SidebarGenerator, config::Config};
|
use crate::{config::Config, generator::Printable, sidebar::SidebarGenerator};
|
||||||
|
|
||||||
/// ## Parameters
|
/// ## Parameters
|
||||||
///
|
///
|
||||||
/// - `config`: Config struct with the parsed values
|
/// - `config`: Config struct with the parsed values
|
||||||
/// - `file`: Path to the MD file to compile
|
/// - `file`: Path to the MD file to compile
|
||||||
/// - `file_tree_html`: HTML code of the file tree to be inserted into the generated HTML
|
/// - `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 input_folder = Path::new(&config.input);
|
||||||
let output_folder = Path::new(&config.output);
|
let output_folder = Path::new(&config.output);
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ use std::path::Path;
|
|||||||
|
|
||||||
use yaml_rust::Yaml;
|
use yaml_rust::Yaml;
|
||||||
|
|
||||||
use crate::{utils, config::{self, Config}};
|
use crate::{config::Config, utils};
|
||||||
|
|
||||||
mod md_compiler;
|
mod md_compiler;
|
||||||
|
|
||||||
@ -24,7 +24,7 @@ pub struct Folder<'a> {
|
|||||||
/// Display name of the folder
|
/// Display name of the folder
|
||||||
name: &'a String,
|
name: &'a String,
|
||||||
/// If true, then there MUST be a `File {path: "index"}` in the `children` field
|
/// If true, then there MUST be a `File {path: "index"}` in the `children` field
|
||||||
has_index: bool,
|
_has_index: bool,
|
||||||
/// Sub files or folders
|
/// Sub files or folders
|
||||||
children: Box<Vec<Node<'a>>>,
|
children: Box<Vec<Node<'a>>>,
|
||||||
}
|
}
|
||||||
@ -72,7 +72,7 @@ pub fn parse_yaml(values: &Yaml) -> Node {
|
|||||||
Node::Folder(Folder {
|
Node::Folder(Folder {
|
||||||
path,
|
path,
|
||||||
name,
|
name,
|
||||||
has_index,
|
_has_index: has_index,
|
||||||
children: Box::new(children_nodes),
|
children: Box::new(children_nodes),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -160,12 +160,7 @@ pub fn compile_md_to_html(
|
|||||||
}
|
}
|
||||||
Node::Folder(folder) => {
|
Node::Folder(folder) => {
|
||||||
for node in folder.children.iter() {
|
for node in folder.children.iter() {
|
||||||
compile_md_to_html(
|
compile_md_to_html(config, node, ¤t_path, file_tree_html);
|
||||||
config,
|
|
||||||
node,
|
|
||||||
¤t_path,
|
|
||||||
file_tree_html,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,6 @@ pub fn search_config_file_impl(config: &Config, current_folder: &Path) {
|
|||||||
|
|
||||||
fn process_yaml(config: &Config, current_path: &Path) {
|
fn process_yaml(config: &Config, current_path: &Path) {
|
||||||
let input_folder = Path::new(&config.input);
|
let input_folder = Path::new(&config.input);
|
||||||
let output_folder = Path::new(&config.output);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Read YAML file
|
// Read YAML file
|
||||||
@ -101,10 +100,5 @@ fn process_yaml(config: &Config, current_path: &Path) {
|
|||||||
//
|
//
|
||||||
// Compile MD to HTML
|
// Compile MD to HTML
|
||||||
//
|
//
|
||||||
compile_md_to_html(
|
compile_md_to_html(config, &file_tree, current_path, &tree_html);
|
||||||
config,
|
|
||||||
&file_tree,
|
|
||||||
current_path,
|
|
||||||
&tree_html,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ use std::{fs, path::Path};
|
|||||||
|
|
||||||
use markdown::mdast::Node;
|
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 {
|
pub fn to_html_fragment(text: &String) -> String {
|
||||||
text.clone().replace(" ", "-")
|
text.clone().replace(" ", "-")
|
||||||
@ -28,10 +28,7 @@ pub fn collect_children_text(vec: &Vec<Node>) -> String {
|
|||||||
result.join("-")
|
result.join("-")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn ensure_folder_exists(
|
pub fn ensure_folder_exists(config: &Config, folder: &Path) -> Result<(), String> {
|
||||||
config: &Config,
|
|
||||||
folder: &Path,
|
|
||||||
) -> Result<(), String> {
|
|
||||||
let input_folder = Path::new(&config.input);
|
let input_folder = Path::new(&config.input);
|
||||||
let output_folder = Path::new(&config.output);
|
let output_folder = Path::new(&config.output);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user