diff --git a/Cargo.toml b/Cargo.toml index f7ecb2d..bb0f793 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rdocs" -version = "0.1.19" +version = "0.1.20" edition = "2021" repository = "https://github.com/daniellga/rdocs/" diff --git a/rdocs/DESCRIPTION b/rdocs/DESCRIPTION index b99534b..96f822e 100644 --- a/rdocs/DESCRIPTION +++ b/rdocs/DESCRIPTION @@ -1,6 +1,6 @@ Package: rdocs Title: Create Quarto documentation for R files from comments -Version: 0.1.19 +Version: 0.1.20 Authors@R: person("Daniel", "Gurgel", , "daniellga@gmail.com", role = c("aut", "cre")) Description: Generate R documentation in Quarto format based on comments in R scripts. diff --git a/src/main.rs b/src/main.rs index c282216..eb60720 100644 --- a/src/main.rs +++ b/src/main.rs @@ -177,15 +177,14 @@ fn generate_r_docs( fn output_file(hash: HashMap>, folder_name_hidden: &str) { for (key, value) in hash { let key_lowercase = key.to_lowercase(); + let contents_folder = Path::new(folder_name_hidden).join("contents"); // Construct the output file path as the input file path with a .qmd extension. - let docs_file_path = Path::new(folder_name_hidden) - .join("contents") - .join(&key_lowercase) - .with_extension("qmd"); + let docs_file_path = contents_folder.join(&key_lowercase).with_extension("qmd"); - // Create the folder if it doesn't exist. + // Create the folders if they don't exist. std::fs::create_dir_all(folder_name_hidden).expect("directory could not be created"); + std::fs::create_dir_all(contents_folder).expect("directory could not be created"); let title = format!("title: {}", key); let text = ["---", &title, "---"].join("\n");