clean with pedantic clippy
Some checks are pending
CI/CD Pipeline / deploy-main (push) Waiting to run

This commit is contained in:
philipp 2024-02-21 14:28:16 +01:00
parent e7405c4edb
commit 98aed71ef5
3 changed files with 11 additions and 10 deletions

1
Cargo.lock generated
View File

@ -527,6 +527,7 @@ dependencies = [
[[package]]
name = "risp"
version = "0.1.0"
source = "git+https://git.hofer.link/philipp/risp.git#ad8d5d828e508bd2186e3b6a8ad6f92c6e1baf67"
dependencies = [
"clap",
"directories",

View File

@ -39,10 +39,10 @@ fn print_paragraph(section: Section) -> String {
ret.push_str("<div class='par'>");
ret.push_str(&format!("<span class='symb'>{}</span>", section.symb));
if let Some(par_header) = section.par_header {
ret.push_str(&format!("<span class='header'>{}</span>", par_header));
ret.push_str(&format!("<span class='header'>{par_header}</span>"));
}
if let Some(note) = section.par_note {
ret.push_str(&format!("<span class='note'>Beachte: {}</span>", note));
ret.push_str(&format!("<span class='note'>Beachte: {note}</span>"));
}
ret.push_str(&print_content(section.content));
@ -54,7 +54,7 @@ fn print_header(header: Heading, level: usize) -> String {
let mut ret = String::new();
let mut header_title = header.name.clone();
if let Some(desc) = header.desc {
header_title.push_str(&format!(" ({desc})"))
header_title.push_str(&format!(" ({desc})"));
}
ret.push_str(&format!(
@ -96,15 +96,15 @@ fn get_content(config_path: &str) -> (String, String) {
pub(crate) fn create_law_files() -> String {
let mut configs: Vec<_> = fs::read_dir("./laws")
.unwrap()
.map(|r| r.unwrap())
.map(std::result::Result::unwrap)
.collect();
configs.sort_by_key(|dir| dir.path()); // Order by name
//
configs.sort_by_key(std::fs::DirEntry::path); // Order by name
let mut li_of_files = String::new();
for config in configs {
let filename = config.file_name().into_string().unwrap();
//TODO: use proper logic...
let law_name = filename.replace(".toml", "");
let law_filename = filename.replace(".toml", "");
let path = format!("{}", config.path().display());
let (lawname, content) = get_content(&path);
@ -117,9 +117,9 @@ pub(crate) fn create_law_files() -> String {
let site = Parts::new().perform(site);
li_of_files.push_str(&format!(
"<li><a href='./{law_name}' title='{law_name}' class='contrast'>{lawname}</a></li>"
"<li><a href='./{law_filename}' title='{law_filename}' class='contrast'>{lawname}</a></li>"
));
fs::write(&format!("output/{law_name}.html"), &site).expect("Unable to write file");
fs::write(&format!("output/{law_filename}.html"), &site).expect("Unable to write file");
}
li_of_files

View File

@ -24,7 +24,7 @@ impl Parts {
pub(crate) fn perform(&self, input: String) -> String {
let mut input = input;
for (key, value) in &self.parts {
let replace = format!("{{{{{}}}}}", key);
let replace = format!("{{{{{key}}}}}");
input = input.replace(&replace, value);
}
input