diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index cb8cb48..e355476 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -25,7 +25,7 @@ jobs: - uses: r-lib/actions/setup-r-dependencies@v2 with: - extra-packages: any::rcmdcheck + extra-packages: any::rcmdcheck, any::pak needs: check - uses: quarto-dev/quarto-actions/setup@v2 diff --git a/DESCRIPTION b/DESCRIPTION index 7c2d471..f97fe60 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: val.report Title: Validation Reports -Version: 0.0.0.9006 +Version: 0.0.0.9007 Authors@R: c( person("LluĂs", "Revilla Sancho", , "lluis.revilla_sancho@roche.com", role = c("aut", "cre"), comment = c(ORCID = "0000-0001-9747-2570")), diff --git a/R/render_table.R b/R/render_table.R index d8b13e2..b682fd7 100644 --- a/R/render_table.R +++ b/R/render_table.R @@ -3,17 +3,16 @@ #' @param riskmetric_assessment object coming from rismetric::pkg_assess function #' @keywords internal prepare_namespace_table <- function(riskmetric_assessment) { - namespace_table <- riskmetric_assessment$export_help[sort(riskmetric_assessment$exported_namespace)] |> - as.data.frame() - colnames(namespace_table) <- "value" - + namespace_vector <- riskmetric_assessment$export_help[sort(riskmetric_assessment$exported_namespace)] + namespace_table <- data.frame(object = names(namespace_vector), value = namespace_vector) + rownames(namespace_table) <- NULL namespace_table |> reactable::reactable( columns = list( value = reactable::colDef( cell = function(value) { # Please to update icons search for unicodes here: https://icons.getbootstrap.com/ - if (value) { + if (isTRUE(value)) { # Green checkmark htmltools::tags$i(class = "bi bi-check-square", style = "background-color: var(--bs-success); font-weight: bold;") } else { diff --git a/R/reporter.R b/R/reporter.R index d33e41d..42eccab 100644 --- a/R/reporter.R +++ b/R/reporter.R @@ -3,7 +3,7 @@ #' @param package_name Package name. #' @param package_version Package version number. #' @param package Path where to find a package source to retrieve name and version number. -#' @param template_path Path to a custom quarto template file +#' @param template_path Path to a directory with one quarto template file (and the files required for rendering it). #' @param output_format Output format for the report. Default is "all". #' @param params A list of execute parameters passed to the template #' @param ... Additional arguments passed to `quarto::quarto_render()` @@ -13,12 +13,14 @@ #' calling function `riskmetric::pkg_ref` before the risk assessment is executed #' @export #' @examples +#' options("valreport_output_dir" = tempdir()) #' pr <- package_report( #' package_name = "dplyr", #' package_version = "1.1.4", #' params = list( #' assessment_path = system.file("assessments/dplyr.rds", package = "val.report"), -#' image = "rhub/ref-image") +#' image = "rhub/ref-image"), +#' quiet = FALSE #' ) #' pr #' file.remove(pr) @@ -53,17 +55,19 @@ package_report <- function( params$package_version <- package_version params$image <- get_image_name(params) - if (is.null(template_path)) { - template_path <- system.file("report/pkg_template.qmd", + if (is.null(template_path) || !nzchar(template_path)) { + template_path <- system.file("report/package", package = "val.report") + } else if (!dir.exists(template_path)) { + stop("Template directory is not available") } - params$package <- normalizePath(params$package, mustWork = FALSE) - if (!is.null(params$assessment_path)) { - params$assessment_path <- normalizePath(params$assessment_path, mustWork = TRUE) + params$package <- normalizePath(params$package, mustWork = FALSE, winslash = "/") + if (length(params$assessment_path) == 1L && !nzchar(params$assessment_path)) { + params$assessment_path <- normalizePath(params$assessment_path, mustWork = TRUE, winslash = "/") } - # Bug on https://github.com/quarto-dev/quarto-cli/issues/5765 + # Bug on https://github.com/quarto-dev/quarto-cli/issues/5765 v <- quarto::quarto_version() if (v < package_version("1.7.13")) { warning("Please install the latest (devel) version of Quarto") diff --git a/R/utils.R b/R/utils.R index 2982a94..2918d7a 100644 --- a/R/utils.R +++ b/R/utils.R @@ -23,10 +23,11 @@ fill_in <- function(list, names) { } output_dir <- function() { - opt <- getOption("valreport_output_dir", default = NULL) - env <- Sys.getenv("VALREPORT_OUTPUT_DIR", unset = getwd()) - - opt %||% env + getOption("valreport_output_dir", + default = Sys.getenv("VALREPORT_OUTPUT_DIR", + unset = getwd() + ) + ) } rendering_dir <- function() { diff --git a/inst/assessments/dplyr.rds b/inst/assessments/dplyr.rds new file mode 100644 index 0000000..275c8f3 Binary files /dev/null and b/inst/assessments/dplyr.rds differ diff --git a/inst/report/package/pkg_template.qmd b/inst/report/package/pkg_template.qmd index a4151e9..690b107 100644 --- a/inst/report/package/pkg_template.qmd +++ b/inst/report/package/pkg_template.qmd @@ -22,13 +22,17 @@ format: light: [default, custom.scss, custom_light.scss] gfm: html-math-method: webtex - typst: + pdf: toc: true - section-numbering: 1.1.1 - df-print: default - margin: - x: 2cm - y: 2cm + number-depth: 3 + # FIXME: Typst didn't handle well the relative paths to images + # typst: + # toc: true + # section-numbering: 1.1.1 + # df-print: default + # margin: + # x: 2cm + # y: 2cm filters: - foldable_code.lua --- @@ -126,8 +130,6 @@ namespace_table <- val.report:::prepare_namespace_table(d_riskmetric) ``` -::: {.content-visible when-format="html"} - ```{r prepare_tables_dependencies} deps <- d_riskmetric$dependencies deps$package <- gsub("\\n", " ", deps$package) @@ -143,8 +145,6 @@ dependencies_table <- htmltools::div( ) ``` -::: - ```{r prepare_tables_reverse_dependencies} reverse_dependencies <- paste(d_riskmetric$reverse_dependencies, collapse = ", ") ``` @@ -253,7 +253,6 @@ The package uses `r if ("license" %in% names(d_riskmetric) && !is.null(d_riskmet ## Code checks -Code checks for this package are: ```{r r_cmd_check, eval=!is_risk_error(d_riskmetric[["r_cmd_check"]])} d_riskmetric[["r_cmd_check"]] diff --git a/man/package_report.Rd b/man/package_report.Rd index 2416e7f..9b69335 100644 --- a/man/package_report.Rd +++ b/man/package_report.Rd @@ -21,7 +21,7 @@ package_report( \item{package}{Path where to find a package source to retrieve name and version number.} -\item{template_path}{Path to a custom quarto template file} +\item{template_path}{Path to a directory with one quarto template file (and the files required for rendering it).} \item{output_format}{Output format for the report. Default is "all".} @@ -40,12 +40,14 @@ Please include source as part of \code{params} content. Source is returned after calling function \code{riskmetric::pkg_ref} before the risk assessment is executed } \examples{ +options("valreport_output_dir" = tempdir()) pr <- package_report( package_name = "dplyr", package_version = "1.1.4", params = list( assessment_path = system.file("assessments/dplyr.rds", package = "val.report"), - image = "rhub/ref-image") + image = "rhub/ref-image"), + quiet = FALSE ) pr file.remove(pr) diff --git a/tests/testthat/_snaps/card.md b/tests/testthat/_snaps/card.md index dc83597..ab4e274 100644 --- a/tests/testthat/_snaps/card.md +++ b/tests/testthat/_snaps/card.md @@ -1,4 +1,4 @@ -# Card is created with the expected components depending on arguments: only has title if no other argument is set +# Card is created with the expected components depending on arguments / only has title if no other argument is set Code create_info_card("test title") @@ -7,7 +7,7 @@