Skip to content

Commit 8b30d51

Browse files
authored
Fixes package (#3)
1 parent ee5963a commit 8b30d51

File tree

12 files changed

+45
-39
lines changed

12 files changed

+45
-39
lines changed

.github/workflows/R-CMD-check.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525

2626
- uses: r-lib/actions/setup-r-dependencies@v2
2727
with:
28-
extra-packages: any::rcmdcheck
28+
extra-packages: any::rcmdcheck, any::pak
2929
needs: check
3030

3131
- uses: quarto-dev/quarto-actions/setup@v2

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: val.report
22
Title: Validation Reports
3-
Version: 0.0.0.9006
3+
Version: 0.0.0.9007
44
Authors@R: c(
55
person("Lluís", "Revilla Sancho", , "lluis.revilla_sancho@roche.com", role = c("aut", "cre"),
66
comment = c(ORCID = "0000-0001-9747-2570")),

R/render_table.R

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,16 @@
33
#' @param riskmetric_assessment object coming from rismetric::pkg_assess function
44
#' @keywords internal
55
prepare_namespace_table <- function(riskmetric_assessment) {
6-
namespace_table <- riskmetric_assessment$export_help[sort(riskmetric_assessment$exported_namespace)] |>
7-
as.data.frame()
8-
colnames(namespace_table) <- "value"
9-
6+
namespace_vector <- riskmetric_assessment$export_help[sort(riskmetric_assessment$exported_namespace)]
7+
namespace_table <- data.frame(object = names(namespace_vector), value = namespace_vector)
8+
rownames(namespace_table) <- NULL
109
namespace_table |>
1110
reactable::reactable(
1211
columns = list(
1312
value = reactable::colDef(
1413
cell = function(value) {
1514
# Please to update icons search for unicodes here: https://icons.getbootstrap.com/
16-
if (value) {
15+
if (isTRUE(value)) {
1716
# Green checkmark
1817
htmltools::tags$i(class = "bi bi-check-square", style = "background-color: var(--bs-success); font-weight: bold;")
1918
} else {

R/reporter.R

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#' @param package_name Package name.
44
#' @param package_version Package version number.
55
#' @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).
77
#' @param output_format Output format for the report. Default is "all".
88
#' @param params A list of execute parameters passed to the template
99
#' @param ... Additional arguments passed to `quarto::quarto_render()`
@@ -13,12 +13,14 @@
1313
#' calling function `riskmetric::pkg_ref` before the risk assessment is executed
1414
#' @export
1515
#' @examples
16+
#' options("valreport_output_dir" = tempdir())
1617
#' pr <- package_report(
1718
#' package_name = "dplyr",
1819
#' package_version = "1.1.4",
1920
#' params = list(
2021
#' assessment_path = system.file("assessments/dplyr.rds", package = "val.report"),
21-
#' image = "rhub/ref-image")
22+
#' image = "rhub/ref-image"),
23+
#' quiet = FALSE
2224
#' )
2325
#' pr
2426
#' file.remove(pr)
@@ -53,17 +55,19 @@ package_report <- function(
5355
params$package_version <- package_version
5456
params$image <- get_image_name(params)
5557

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",
5860
package = "val.report")
61+
} else if (!dir.exists(template_path)) {
62+
stop("Template directory is not available")
5963
}
6064

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 = "/")
6468
}
65-
# Bug on https://github.com/quarto-dev/quarto-cli/issues/5765
6669

70+
# Bug on https://github.com/quarto-dev/quarto-cli/issues/5765
6771
v <- quarto::quarto_version()
6872
if (v < package_version("1.7.13")) {
6973
warning("Please install the latest (devel) version of Quarto")

R/utils.R

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@ fill_in <- function(list, names) {
2323
}
2424

2525
output_dir <- function() {
26-
opt <- getOption("valreport_output_dir", default = NULL)
27-
env <- Sys.getenv("VALREPORT_OUTPUT_DIR", unset = getwd())
28-
29-
opt %||% env
26+
getOption("valreport_output_dir",
27+
default = Sys.getenv("VALREPORT_OUTPUT_DIR",
28+
unset = getwd()
29+
)
30+
)
3031
}
3132

3233
rendering_dir <- function() {

inst/assessments/dplyr.rds

70.3 KB
Binary file not shown.

inst/report/package/pkg_template.qmd

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,17 @@ format:
2222
light: [default, custom.scss, custom_light.scss]
2323
gfm:
2424
html-math-method: webtex
25-
typst:
25+
pdf:
2626
toc: true
27-
section-numbering: 1.1.1
28-
df-print: default
29-
margin:
30-
x: 2cm
31-
y: 2cm
27+
number-depth: 3
28+
# FIXME: Typst didn't handle well the relative paths to images
29+
# typst:
30+
# toc: true
31+
# section-numbering: 1.1.1
32+
# df-print: default
33+
# margin:
34+
# x: 2cm
35+
# y: 2cm
3236
filters:
3337
- foldable_code.lua
3438
---
@@ -126,8 +130,6 @@ namespace_table <- val.report:::prepare_namespace_table(d_riskmetric)
126130
```
127131

128132

129-
::: {.content-visible when-format="html"}
130-
131133
```{r prepare_tables_dependencies}
132134
deps <- d_riskmetric$dependencies
133135
deps$package <- gsub("\\n", " ", deps$package)
@@ -143,8 +145,6 @@ dependencies_table <- htmltools::div(
143145
)
144146
```
145147

146-
:::
147-
148148
```{r prepare_tables_reverse_dependencies}
149149
reverse_dependencies <- paste(d_riskmetric$reverse_dependencies, collapse = ", ")
150150
```
@@ -253,7 +253,6 @@ The package uses `r if ("license" %in% names(d_riskmetric) && !is.null(d_riskmet
253253

254254
## Code checks
255255

256-
Code checks for this package are:
257256

258257
```{r r_cmd_check, eval=!is_risk_error(d_riskmetric[["r_cmd_check"]])}
259258
d_riskmetric[["r_cmd_check"]]

man/package_report.Rd

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/_snaps/card.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Card is created with the expected components depending on arguments: only has title if no other argument is set
1+
# Card is created with the expected components depending on arguments / only has title if no other argument is set
22

33
Code
44
create_info_card("test title")
@@ -7,7 +7,7 @@
77
<h3 class="card-title">test title</h3>
88
</div>
99

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

1212
Code
1313
create_info_card(title = "test title", header = "Information header")
@@ -17,7 +17,7 @@
1717
<h3 class="card-title">test title</h3>
1818
</div>
1919

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

2222
Code
2323
create_info_card(title = "test title", header = "Information header", text = "Extra test")

tests/testthat/_snaps/render_table.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Namespace table is created: It is created by without error from existing example package assessment
1+
# Namespace table is created / It is created by without error from existing example package assessment
22

33
Code
44
prepare_namespace_table(example_assessment)

0 commit comments

Comments
 (0)