Skip to content

Commit

Permalink
fixing examples
Browse files Browse the repository at this point in the history
  • Loading branch information
daniellga committed May 2, 2024
1 parent 8e70b98 commit f80b8af
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rdocs"
version = "0.1.39"
version = "0.1.40"
edition = "2021"
repository = "https://github.com/daniellga/rdocs/"

Expand Down
2 changes: 1 addition & 1 deletion rdocs/DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: rdocs
Title: Create Quarto documentation for R files from comments
Version: 0.1.39
Version: 0.1.40
Authors@R:
person("Daniel", "Gurgel", , "[email protected]", role = c("aut", "cre"))
Description: Generate R documentation in Quarto format based on comments in code files.
Expand Down
15 changes: 9 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ fn output_file(hash: HashMap<String, Vec<String>>, folder_name_hidden: &str) {
let docs_file_path = contents_folder.join(&key_lowercase).with_extension("qmd");

// 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");
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");
Expand All @@ -189,10 +189,10 @@ fn output_file(hash: HashMap<String, Vec<String>>, folder_name_hidden: &str) {
let output_text = [text, value.join("\n")].join("\n\n");

// Write the output text to the output file.
let mut output_file = File::create(&docs_file_path).expect("could not create output_file");
let mut output_file = File::create(&docs_file_path).expect("Could not create output_file.");
output_file
.write_all(output_text.as_bytes())
.expect("could not write to output_file");
.expect("Could not write to output_file.");
}
}

Expand All @@ -205,11 +205,14 @@ fn eval_examples(examples: Vec<String>) {
.stdout(Stdio::null())
.stderr(Stdio::piped())
.output()
.expect("Failed to execute Rscript");
.expect("Failed to execute Rscript.");

if !output.status.success() {
let error_message = String::from_utf8_lossy(&output.stderr);
panic!("Error running example:\n{}", error_message);
panic!(
"Error running example:\n\n{}\n\n**********\n\nR code executed:\n\n{}",
error_message, output_text
);
}
}

Expand Down

0 comments on commit f80b8af

Please sign in to comment.