|
3 | 3 | #' @param package_name Package name. |
4 | 4 | #' @param package_version Package version number. |
5 | 5 | #' @param package Path where to find a package source to retrieve name and version number. |
6 | | -#' @param template_path Path to a custom quarto template file |
| 6 | +#' @param template_path Path to a directory with one quarto template file (and the files required for rendering it). |
7 | 7 | #' @param output_format Output format for the report. Default is "all". |
8 | 8 | #' @param params A list of execute parameters passed to the template |
9 | 9 | #' @param ... Additional arguments passed to `quarto::quarto_render()` |
|
13 | 13 | #' calling function `riskmetric::pkg_ref` before the risk assessment is executed |
14 | 14 | #' @export |
15 | 15 | #' @examples |
| 16 | +#' options("valreport_output_dir" = tempdir()) |
16 | 17 | #' pr <- package_report( |
17 | 18 | #' package_name = "dplyr", |
18 | 19 | #' package_version = "1.1.4", |
19 | 20 | #' params = list( |
20 | 21 | #' assessment_path = system.file("assessments/dplyr.rds", package = "val.report"), |
21 | | -#' image = "rhub/ref-image") |
| 22 | +#' image = "rhub/ref-image"), |
| 23 | +#' quiet = FALSE |
22 | 24 | #' ) |
23 | 25 | #' pr |
24 | 26 | #' file.remove(pr) |
@@ -53,17 +55,19 @@ package_report <- function( |
53 | 55 | params$package_version <- package_version |
54 | 56 | params$image <- get_image_name(params) |
55 | 57 |
|
56 | | - if (is.null(template_path)) { |
57 | | - template_path <- system.file("report/pkg_template.qmd", |
| 58 | + if (is.null(template_path) || !nzchar(template_path)) { |
| 59 | + template_path <- system.file("report/package", |
58 | 60 | package = "val.report") |
| 61 | + } else if (!dir.exists(template_path)) { |
| 62 | + stop("Template directory is not available") |
59 | 63 | } |
60 | 64 |
|
61 | | - params$package <- normalizePath(params$package, mustWork = FALSE) |
62 | | - if (!is.null(params$assessment_path)) { |
63 | | - params$assessment_path <- normalizePath(params$assessment_path, mustWork = TRUE) |
| 65 | + params$package <- normalizePath(params$package, mustWork = FALSE, winslash = "/") |
| 66 | + if (length(params$assessment_path) == 1L && !nzchar(params$assessment_path)) { |
| 67 | + params$assessment_path <- normalizePath(params$assessment_path, mustWork = TRUE, winslash = "/") |
64 | 68 | } |
65 | | - # Bug on https://github.com/quarto-dev/quarto-cli/issues/5765 |
66 | 69 |
|
| 70 | + # Bug on https://github.com/quarto-dev/quarto-cli/issues/5765 |
67 | 71 | v <- quarto::quarto_version() |
68 | 72 | if (v < package_version("1.7.13")) { |
69 | 73 | warning("Please install the latest (devel) version of Quarto") |
|
0 commit comments