Skip to content

Commit

Permalink
Use tinytable
Browse files Browse the repository at this point in the history
  • Loading branch information
walkowif committed May 9, 2024
1 parent ff3a8b1 commit 915ae38
Showing 1 changed file with 35 additions and 7 deletions.
42 changes: 35 additions & 7 deletions template.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ remotes::install_local(
upgrade = "never"
)
library(magrittr)
library(tinytable)
```

# Context
Expand Down Expand Up @@ -62,7 +63,7 @@ gd <- system(
# define reused git args to be sure we're picking up the right git info
gd <- sprintf("--git-dir='%s'", gd)
wt <- sprintf("--work-tree='%s'", Sys.getenv('INPUT_REPORT_PACKAGE_DIR', '.'))
data.frame(
tt_git_df <- data.frame(
Field = c("server", "repository", "git ref", "branch", "commit `SHA1`", "commit date"),
Value = c(
Sys.getenv('GITHUB_SERVER_URL'),
Expand All @@ -80,6 +81,12 @@ data.frame(
stdout = TRUE
)
))
tt(
tt_git_df,
caption = "Git information",
theme = "striped"
)
```

## R Session Info
Expand Down Expand Up @@ -108,14 +115,20 @@ d_riskmetric <- Sys.getenv('INPUT_REPORT_PACKAGE_DIR', '.') %>%
by = c("name" = "column_name")
)
d_riskmetric %>%
tt_riskmetric_df <- d_riskmetric %>%
dplyr::filter(
name %in% c(
"news_current", "has_vignettes",
"license", "downloads_1yr"
)
) %>%
dplyr::select(Metric = label, Status = value)
tt(
tt_riskmetric_df,
caption = "Package info assessed by the R package riskmetric",
theme = "striped"
)
```

# Installation documentation
Expand Down Expand Up @@ -156,7 +169,6 @@ between intended use and testing.
### Testing matrix

```{r traceability, echo = FALSE, eval = TRUE}
library(tinytable)
if (require("covtracer", quietly = TRUE)) {
covtracer_df <- test_trace_df(covr_results)
covtracer_df$filename <- basename(covtracer_df$filepath)
Expand All @@ -176,7 +188,7 @@ if (require("covtracer", quietly = TRUE)) {
dplyr::mutate(alias = paste0(alias, "()")) %>%
dplyr::mutate(file = paste0("man/", file))
tt_df <- covtracer_df_clean %>%
tt_covtracer_df <- covtracer_df_clean %>%
dplyr::filter(!duplicated(.)) %>%
dplyr::filter(!is.na(test_name)) %>%
dplyr::filter(!is.na(file)) %>% # unexported?
Expand All @@ -185,7 +197,11 @@ if (require("covtracer", quietly = TRUE)) {
dplyr::mutate(file = paste0("``` ", file, " ```")) %>%
dplyr::select(`Test Description` = test_name, Documentation = file)
tt(tt_df, caption = "Some table caption", theme = "striped")
tt(
tt_covtracer_df,
caption = "Tracebility matrix mapping unit tests to documented behaviours.",
theme = "striped"
)
} else {
cat("{covtracer} not available to produce a traceability matrix")
}
Expand All @@ -195,10 +211,16 @@ if (require("covtracer", quietly = TRUE)) {

```{r traceability2, echo = FALSE, eval = TRUE}
if (require("covtracer", quietly = TRUE)) {
covtracer_df_clean %>%
tt_untested_df <- covtracer_df_clean %>%
dplyr::filter(is.na(test_name)) %>%
dplyr::arrange(alias) %>%
dplyr::select(`Exported package object` = alias, Documentation = file)
tt(
tt_untested_df,
caption = "Untested behaviours: documentation that is not covered by any test.",
theme = "striped"
)
} else {
cat("{covtracer} not available to produce a traceability matrix")
}
Expand All @@ -210,11 +232,17 @@ An indicator of test granularity by whether the function is directly tested.

```{r traceability3, echo = FALSE, eval = TRUE}
if (require("covtracer", quietly = TRUE)) {
covtracer_df_clean %>%
tt_granularity_df <- covtracer_df_clean %>%
dplyr::group_by(alias) %>%
dplyr::summarize(any_direct_tests = any(direct, na.rm = TRUE)) %>%
dplyr::arrange(alias) %>%
dplyr::select(`Exported package object` = alias, `Tested Directly` = any_direct_tests)
tt(
tt_granularity_df,
caption = "Granularity of unit tests: directly tested exported functions.",
theme = "striped"
)
} else {
cat("{covtracer} not available to produce a traceability matrix")
}
Expand Down

0 comments on commit 915ae38

Please sign in to comment.