-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpkg_template.qmd
More file actions
346 lines (277 loc) · 8.97 KB
/
pkg_template.qmd
File metadata and controls
346 lines (277 loc) · 8.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
---
title: "This report is fully automated and builds on [`r params$image`](`r paste('https://hub.docker.com/r', params$image, sep = '/')`) image."
date-format: "YYYY-MM-DD hh:mm:ss"
date: today
published-title: ""
params:
package_name: dplyr
package_version: 1.0.0
package: NULL
image: "rhub/ref-image"
assessment_path: "assessments/dplyr.rds"
hide_reverse_deps: true
source: "pgk_install"
format:
html:
toc: true
embed-resources: true
include-in-header: "top_page.html"
include-after-body: "transform_pre_class.html"
theme:
dark: [darkly, custom.scss]
light: [default, custom.scss, custom_light.scss]
gfm:
html-math-method: webtex
typst:
toc: true
section-numbering: 1.1.1
df-print: default
margin:
x: 2cm
y: 2cm
filters:
- foldable_code.lua
---
```{r setup, include = FALSE}
options(width = 80L, covr.record_tests = TRUE)
knitr::opts_chunk$set(
echo = FALSE,
eval = TRUE,
error = TRUE,
cache = FALSE
)
library("tools")
library("knitr")
library("riskreports")
```
# Context
```{r loading}
pkg <- params$package
pkg_name <- params$package_name
pkg_version <- params$package_version
risk_path <- params$assessment_path
image <- params$image
```
Documents the installation of this package on an open source R environment, focusing on:
- Installation environment description
- Testing coverage
It is limited to assess whether unit tests and documentation are present and can execute without error.
An assessment would be required that the tests and documentation are meaningful.
# Package `r basename(pkg)`
## Metric based risk assessment
The following metrics are derived from the `riskmetric` R package.
```{r read-riskmetric, warning=FALSE}
d_riskmetric <- readRDS(risk_path)
```
```{r create_r_riskmetric, warning=FALSE}
# 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"))
})
r_riskmetric$origin <- riskreports:::get_pkg_origin(params$source)
```
::: {.content-visible when-format="html"}
```{r info_cards}
riskreports:::create_metrics_cards(r_riskmetric)
```
:::
::: {.content-hidden when-format="html"}
```{r simple_cards}
simple_cards <- data.frame(
"Downloads 1 year" = as.character(r_riskmetric$downloads_1yr),
"Reverse dependencies" = r_riskmetric$reverse_dependencies,
"License" = as.character(r_riskmetric$license),
"Origin" = r_riskmetric$origin
)
r_riskmetric$origin <- NULL
knitr::kable(simple_cards)
```
:::
```{r prepare_tables_namespace}
namespace_table <- riskreports:::prepare_namespace_table(d_riskmetric)
```
::: {.content-visible when-format="html"}
```{r prepare_tables_dependencies}
deps <- d_riskmetric$dependencies
deps$package <- gsub("\\n", " ", deps$package)
row.names(deps) <- NULL
dependencies_table <- htmltools::div(
htmltools::span(
"Overall the package has these dependencies:"
),
reactable::reactable(
deps,
class = "metrics-table"
)
)
```
:::
```{r prepare_tables_reverse_dependencies}
reverse_dependencies <- paste(d_riskmetric$reverse_dependencies, collapse = ", ")
```
```{r prepare_tables_examples}
examples_content <- paste0(
"There are ",
if (!is_na["has_examples"]) sum(d_riskmetric$has_examples),
" examples from ",
if (!is_na["has_examples"]) length(d_riskmetric$has_examples),
" help pages (",
if (!is_na["has_examples"]) {
sprintf("%.2f%%", sum(d_riskmetric$has_examples) / length(d_riskmetric$has_examples) * 100)
} else {
"?"
},
")."
)
```
```{r prepare_tables_news}
news_content <- paste0(
"The package has ",
if ("has_news" %in% names(d_riskmetric) && !is.null(d_riskmetric$has_news)) d_riskmetric$has_news,
" NEWS file and it is ",
if (is.null(d_riskmetric$news_current) && !d_riskmetric$news_current) "not",
"current."
)
```
```{r general-riskmetric, warning=FALSE}
#| tab.cap: "**Package general assessment:** Coverage, check results, size,
#| download the last year, reverse dependencies and number of dependencies."
summary_data <- summary_table(r_riskmetric[, !is.na(as.vector(r_riskmetric))])
values_collapsed_rows <- c(
"Has news",
"Exported namespace",
"Dependencies",
"Reverse dependencies",
"Has examples"
)
indexes_collapsed_rows <- which(summary_data$Section %in% values_collapsed_rows)
is_html <- knitr::is_html_output(excludes = "markdown")
# Certain rows of this table are collapsible, containing detailed information.
if (isTRUE(is_html)) {
reactable::reactable(
summary_data,
rownames = FALSE,
pagination = FALSE,
details = function(index) {
if(index %in% indexes_collapsed_rows) {
collapsed_content <- switch(summary_data$Section[index],
"Exported namespace" = namespace_table,
"Dependencies" = dependencies_table,
"Reverse dependencies" = reverse_dependencies,
"Has examples" = examples_content,
"Has news" = news_content
)
htmltools::div(
style = "padding: 1rem;",
collapsed_content
)
}
},
columns = list(
Section = reactable::colDef(
name = ""
),
Values = reactable::colDef(
name = "",
cell = function(value) {
if (value == "Yes") {
# Green 'Yes'
htmltools::span(value, style = "color:var(--bs-success); font-weight: bold;")
} else if (value == "No") {
# Red 'No'
htmltools::span(value, style = "color: var(--bs-danger); font-weight: bold;")
} else {
htmltools::span(value, style = "color: var(--bs-body-color); font-weight: bold;")
}
},
align = "center"
)
),
class = "metrics-table"
)
} else {
knitr::kable(summary_data)
}
```
::: {.content-hidden unless-meta=`r !is_risk_error(d_riskmetric[["license"]])`}
## License
The package uses `r if ("license" %in% names(d_riskmetric) && !is.null(d_riskmetric$license)) cat(d_riskmetric$license)`.
:::
::: {.content-hidden unless-meta=`r !is_risk_error(d_riskmetric[["r_cmd_check"]]) || !is_risk_error(d_riskmetric[["remote_checks"]])`}
## 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"]]
```
```{r remote_checks, eval=!is_risk_error(d_riskmetric[["remote_checks"]])}
d_riskmetric[["remote_checks"]]
```
:::
::: {.content-hidden unless-meta=`r !is_risk_error(d_riskmetric[["covr_coverage"]])`}
## Code coverage
Code coverage for this package is:
```{r covr_coverage}
d_riskmetric[["covr_coverage"]]
```
:::
# Installation environment
## System Info
```{r execution_info}
#| tab.cap: "**System information**. Table about the system used to check the package."
tt_sys_info_df <- data.frame(
Field = c("Image", "OS", "Platform", "System", "Execution Time"),
Value = c(
image,
sessionInfo()$running,
R.version$platform,
R.version$system,
format(Sys.time(), tz = "UTC", usetz = TRUE)
))
knitr::kable(tt_sys_info_df)
```
<!--
From here we use the lua filter based on this issue from Quarto itself
https://github.com/quarto-dev/quarto-cli/issues/341
Please take into account that not all content in the chunks will be correctly folded
- character vectors are
- reactable tables are not
An alternative is to use callout blocks with collapse = TRUE
The advantage of the foldable_code lua filter is that the code is printed exactly as in the R console
-->
## R Session Info
```{r session_info, attr.output='.details summary="Session info"'}
sessionInfo()
```
```{r Platform, attr.output='.details summary="Platform"'}
unlist(.Platform)
```
```{r capabilities, attr.output='.details summary="R\'s capabilities"'}
capabilities()
```
```{r external-software, attr.output='.details summary="External software"'}
extSoftVersion()
```
```{r graphic-software, attr.output='.details summary="Graphics external software"'}
grSoftVersion()
```
```{r machine, attr.output='.details summary="Numerical characteristics of the machine"'}
unlist(.Machine)
```
```{r RNGKind, attr.output='.details summary="Random number generation process"'}
RNGkind()
```
## Information about the environment
Environmental and options variables affect how package checks and software in it might behave.
```{r computing, attr.output='.details summary="Environmental variables when running this report"'}
riskreports::environ_report(exclude = c("GITHUB_PAT", "APPDATA",
"GITHUB", "GITLAB_PAT", "GITLAB",
"ProgramFiles", "ProgramFiles(x86)",
"R_USER", "USERNAME", "USERPROFILE",
"USERDNSDOMAIN", "USERDOMAIN",
"USERDOMAIN_ROAMINGPROFILE", "R_DptShare"
))
```
```{r options, attr.output='.details summary="These are the options set to generate the report"'}
riskreports::options_report(exclude = c("usethis.full_name", "usethis.description", "usethis.destdir"))
```