Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve the looks of the report #19

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from
6 changes: 4 additions & 2 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,7 @@ inst/source/*
inst/source/Library
inst/source/*Rcheck
inst/source/*tar.gz
inst/*.rds = = = = =
=
inst/*.rds
_pkgdown.yaml
pkgdown
.github
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Package: riskreports
Title: Package Validation Reports
Version: 0.0.0.9004
Version: 0.0.0.9006
Authors@R: c(
person("Lluís", "Revilla Sancho", , "lluis.revilla_sancho@roche.com", role = c("aut", "cre"),
comment = c(ORCID = "0000-0001-9747-2570")),
person("R Validation Hub", role = "cph", email = "r-val-hub-maintainers@lists.r-consortium.org")
)
Description: Documents package checks for validation in a pharmaceutic
Description: Documents package checks for validation in a pharmaceutic
context.
License: MIT + file LICENSE
URL: https://github.com/pharmaR/riskreports, https://pharmar.github.io/riskreports/
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ export(check_reporter)
export(environ_report)
export(options_report)
export(package_report)
export(summary_table)
importFrom(methods,is)
importFrom(tools,check_packages_in_dir_details)
36 changes: 36 additions & 0 deletions R/riskmetic.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,39 @@ risk_error <- function(output, y) {
}
y
}

is_logical <- function(x) {
if (x == 1 || isTRUE(x)) {
"Yes"
} else {
x
}
}

simple_cap <- function(x) {
s <- toupper(substr(x, 1, 1))
paste0(s, substring(x, 2))
}

#' Summary table
#'
#' @param risk The output of `assessment()`.
#'
#' @returns A data.frame with the two columns one for the fields and one for the values.
#' @export
summary_table <- function(risk) {
y <- risk
y[] <- lapply(y, is_logical)
y$has_examples <- sprintf("%.2f%%", y$has_examples*100)
y$bugs_status <- sprintf("%.2f%%", y$bugs_status*100)
if (y$has_vignettes > 0) {
y$has_vignettes <- "Yes"
}
x <- t(y)
yx <- simple_cap(gsub("_", " ", rownames(x), fixed = TRUE))
df <- as.data.frame(x)
df <- cbind(Section = yx, Values = df)
colnames(df) <- c("Section", "Values")
rownames(df) <- NULL
df
}
44 changes: 31 additions & 13 deletions inst/report/pkg_template.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,20 @@ params:
package: NULL
image: "rhub/ref-image"
assessment_path: "assessments/dplyr.rds"
hide_reverse_deps: true
format:
html:
toc: true
embed-resources: true
gfm:
html-math-method: webtex
# typst:
# toc: true
# section-numbering: 1.1.1
# df-print: default
# margin:
# x: 2cm
# y: 2cm
typst:
toc: true
section-numbering: 1.1.1
df-print: default
margin:
x: 2cm
y: 2cm
---

```{r setup, include = FALSE}
Expand All @@ -31,6 +32,16 @@ knitr::opts_chunk$set(
cache = FALSE
)
library("tools")
# Adapted from https://stackoverflow.com/a/52327256
library("knitr")
hook_old <- knitr::knit_hooks$get("output")
knit_hooks$set(output = function(x, options) {
if (!is.null(options$summary)){
x <- paste0("<details><br><summary>", options$summary,"</summary><br>", hook_old(x, options), "<br></details>")
}
x
})

```

# Context
Expand Down Expand Up @@ -82,8 +93,11 @@ d_riskmetric <- readRDS(risk_path)

# Assesment produces a data.frame with one row
r_riskmetric <- riskreports::assessment(d_riskmetric)
is_na <- sapply(r_riskmetric, function(x){is.na(x) || (is.character(x) && startsWith(x, "no applicable"))})
knitr::kable(t(r_riskmetric[, !is_na])) # Use this to have some summary text and report it.
is_na <- sapply(x, function(x) {
is.na(x) || (is.character(x) && startsWith(x, "no applicable"))
})
x <- summary_table(r_riskmetric[, !is_na])
knitr::kable(x, row.names = FALSE align = "cc") # Use this to have some summary text and report it.
# d_riskmetric
```

Expand All @@ -100,6 +114,8 @@ row.names(deps) <- NULL
knitr::kable(deps, row.names = TRUE)
```

::: {.content-hidden unless-meta="hide_reverse_deps"}

## Reverse dependencies

Overall the package has `r length(d_riskmetric$reverse_dependencies)` reverse dependencies:
Expand All @@ -108,6 +124,8 @@ Overall the package has `r length(d_riskmetric$reverse_dependencies)` reverse de
cat(paste(d_riskmetric$reverse_dependencies, collapse = ", "))
```

:::

## Namespace

Overall the package has `r length(d_riskmetric$exported_namespace)` exported objects.
Expand All @@ -117,15 +135,15 @@ Overall the package has `r length(d_riskmetric$exported_namespace)` exported obj
d_riskmetric$export_help[sort(d_riskmetric$exported_namespace)]
```

### Examples
## Examples

There are `r if (!is_na["has_examples"]) sum(d_riskmetric$has_examples)` help pages with examples, from `r if (!is_na["has_examples"]) {length(d_riskmetric$has_examples)}` (`r if (!is_na["has_examples"]) {sprintf("%0.2f", sum(d_riskmetric$has_examples)/length(d_riskmetric$has_examples)*100)} else {"?"} ` %).

### NEWS
## NEWS

The package has `r if ("has_news" %in% names(d_riskmetric) && !is.null(d_riskmetric$has_news)) print(d_riskmetric$has_news)` NEWS file and it is `r if (is.null(d_riskmetric$news_current) && !d_riskmetric$news_current) "not"` current.

### License
## License

The package uses `r if ("license" %in% names(d_riskmetric) && !is.null(d_riskmetric$license)) print(d_riskmetric$license)`.

Expand Down Expand Up @@ -167,7 +185,7 @@ unlist(.Platform)

R's capabilities:

```{r capabilities}
```{r capabilities, summary = "Capabilities details"}
capabilities()
```

Expand Down
2 changes: 1 addition & 1 deletion man/riskreports-package.Rd

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

17 changes: 17 additions & 0 deletions man/summary_table.Rd

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

Binary file added pkgdown/favicon/apple-touch-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pkgdown/favicon/favicon-96x96.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pkgdown/favicon/favicon.ico
Binary file not shown.
3 changes: 3 additions & 0 deletions pkgdown/favicon/favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions pkgdown/favicon/site.webmanifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "",
"short_name": "",
"icons": [
{
"src": "/web-app-manifest-192x192.png",
"sizes": "192x192",
"type": "image/png",
"purpose": "maskable"
},
{
"src": "/web-app-manifest-512x512.png",
"sizes": "512x512",
"type": "image/png",
"purpose": "maskable"
}
],
"theme_color": "#ffffff",
"background_color": "#ffffff",
"display": "standalone"
}
Binary file added pkgdown/favicon/web-app-manifest-192x192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pkgdown/favicon/web-app-manifest-512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading