Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0001-9747-2570")),
Expand Down
9 changes: 4 additions & 5 deletions R/render_table.R
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
20 changes: 12 additions & 8 deletions R/reporter.R
Original file line number Diff line number Diff line change
Expand Up @@ -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()`
Expand All @@ -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)
Expand Down Expand Up @@ -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 (!is.null(params$assessment_path) || !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")
Expand Down
9 changes: 5 additions & 4 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Binary file added inst/assessments/dplyr.rds
Binary file not shown.
20 changes: 9 additions & 11 deletions inst/report/package/pkg_template.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,16 @@ 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
# typst:
# toc: true
# section-numbering: 1.1.1
# df-print: default
# margin:
# x: 2cm
# y: 2cm
filters:
- foldable_code.lua
---
Expand Down Expand Up @@ -126,8 +129,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)
Expand All @@ -143,8 +144,6 @@ dependencies_table <- htmltools::div(
)
```

:::

```{r prepare_tables_reverse_dependencies}
reverse_dependencies <- paste(d_riskmetric$reverse_dependencies, collapse = ", ")
```
Expand Down Expand Up @@ -253,7 +252,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"]]
Expand Down
6 changes: 4 additions & 2 deletions man/package_report.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions tests/testthat/_snaps/card.md
Original file line number Diff line number Diff line change
@@ -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")
Expand All @@ -7,7 +7,7 @@
<h3 class="card-title">test title</h3>
</div>

# Card is created with the expected components depending on arguments: has title and header
# Card is created with the expected components depending on arguments / has title and header

Code
create_info_card(title = "test title", header = "Information header")
Expand All @@ -17,7 +17,7 @@
<h3 class="card-title">test title</h3>
</div>

# Card is created with the expected components depending on arguments: has all arguments set
# Card is created with the expected components depending on arguments / has all arguments set

Code
create_info_card(title = "test title", header = "Information header", text = "Extra test")
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/_snaps/render_table.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Namespace table is created: It is created by without error from existing example package assessment
# Namespace table is created / It is created by without error from existing example package assessment

Code
prepare_namespace_table(example_assessment)
Expand Down
6 changes: 3 additions & 3 deletions tests/testthat/test-report.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ describe("Run test for the report", {
withr::local_options("valreport_output_dir" = tmp_folder)

it("should be generated in all formats", {
expect_no_error({
pr <- package_report(
expect_no_error(
package_report(
package_name = "dplyr",
package_version = "1.1.4",
params = list(
Expand All @@ -19,7 +19,7 @@ describe("Run test for the report", {
quiet = TRUE,
output_format = "all"
)
})
)
})

})
1 change: 1 addition & 0 deletions val.report.Rproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ StripTrailingWhitespace: Yes
BuildType: Package
PackageUseDevtools: Yes
PackageInstallArgs: --no-multiarch --with-keep.source
PackageCheckArgs: --as-cran
PackageRoxygenize: rd,collate,namespace