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

Release 0.4.0 #203

Merged
merged 66 commits into from
Nov 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
64a5a0a
Add initial cheatsheet
Jul 20, 2021
d3f6584
Initial addition of validation packets vignette and code
Jul 21, 2021
1d81e19
argument corrections and cleaning up the external resources vignette
Jul 21, 2021
3ab4a7a
Add valtools hex to package. Thanks @MayaGans
Aug 5, 2021
30b67b9
Add cheatsheets to .Rbuildignore & to readme
Aug 5, 2021
d5a70da
convert cheatsheet pdf to png, update readme to reflect that
Aug 6, 2021
5092f7e
some wording and spacing updates to the packet vignette
Aug 6, 2021
c163714
Add a packet template - similar to standard but removes the expectati…
Aug 6, 2021
0b58993
improve config test coverage
Aug 6, 2021
bcf68ca
correct packet creation function & test cleanup
Aug 6, 2021
e9f39c3
set covr nocov
Aug 9, 2021
e459695
Move cheatsheets to man/figures
thebioengineer Aug 10, 2021
ced5d77
update .Rbuildignore cheatsheet paths
thebioengineer Aug 10, 2021
0aca7db
Merge pull request #180 from phuse-org/add_cheatsheet_flow
Aug 10, 2021
b61a4ef
Add to roxygen_copy tests
Aug 11, 2021
8bb4dd5
example of figure comparisons
Aug 13, 2021
6adc9ff
spelling and make reference to location saved within validation infra
Aug 13, 2021
a959267
Update tests and remove cases where coverage tag has no ":" as allowable
Aug 19, 2021
44b0d96
Add missed space and closing parenthesis for test
Aug 19, 2021
0a47f42
Merge pull request #181 from phuse-org/validation_packet
Aug 19, 2021
8df1104
Merge pull request #188 from phuse-org/malformed_coverage_tags
Aug 19, 2021
8eeb9bf
Merge branch 'develop' into test_coverage_improvements
Aug 20, 2021
eb601e2
remove extra space, affects sorting
mariev Aug 20, 2021
376132e
ordering at export
mariev Aug 20, 2021
f0c9269
update tests
mariev Aug 21, 2021
7076710
remove dplyr dependency in tests
mariev Aug 21, 2021
b83e3bd
lingering dplyr
mariev Aug 21, 2021
ac3a4e8
Merge pull request #189 from phuse-org/hotfix-coverage-matrix
mariev Aug 23, 2021
225a389
develop should be ahead of main
mariev Aug 26, 2021
0c56533
Merge pull request #192 from phuse-org/hotfix-versioning
mariev Aug 27, 2021
6cd61fd
update to return file path if file already exists.
thebioengineer Sep 5, 2021
1d22d5d
move adding file to config only if file didnt exist before
thebioengineer Sep 5, 2021
cb5cae0
Update dynamic referencing to handle NA entries in data.frames
thebioengineer Sep 5, 2021
6b1058f
Use grepl rather than exact matching in template so user could have m…
thebioengineer Sep 5, 2021
094a78a
Apply suggestions from code review
Sep 5, 2021
44cdbc7
Clean up file comparison vignette
thebioengineer Sep 8, 2021
3339e9a
add p2 of cheatsheet
mariev Sep 17, 2021
c183014
Merge pull request #195 from phuse-org/vt_file_overwriting
Sep 17, 2021
e051ae8
Merge pull request #196 from phuse-org/dynamic_ref_na_fix
thebioengineer Sep 17, 2021
633f6a5
Merge pull request #197 from phuse-org/cleaner_validation_lead_template
thebioengineer Sep 17, 2021
7109417
add cheatsheet links to readme
mariev Sep 19, 2021
e6090e0
Merge pull request #199 from phuse-org/cheatsheet-p2
mariev Sep 20, 2021
8fdab52
Update vignettes/validation_figure_tests.Rmd
thebioengineer Oct 2, 2021
2010e46
Update vignettes/validation_figure_tests.Rmd
thebioengineer Oct 2, 2021
5921905
Merge pull request #185 from phuse-org/testing_figure_comparisons
thebioengineer Oct 7, 2021
22cefec
citation added
mariev Oct 14, 2021
9077203
eol
mariev Oct 14, 2021
ae2c987
fix versioning
mariev Oct 14, 2021
c19f136
Merge pull request #182 from phuse-org/test_coverage_improvements
thebioengineer Oct 14, 2021
1351a09
Merge pull request #201 from phuse-org/citation
mariev Oct 14, 2021
6abb8df
Merge Develop version 0.4.0 into Main
thebioengineer Oct 18, 2021
7d2585a
Update extension checker to allow for Rmd
thebioengineer Oct 19, 2021
eb9ea95
Set skip params if pandoc was not 2.7.3
thebioengineer Oct 19, 2021
8ff6d60
Add interactive previewing of vt_file
thebioengineer Oct 19, 2021
800d96e
Added tests for multiple extension options
thebioengineer Oct 19, 2021
6f468c5
Allow interactive printing of md and Rmd files
thebioengineer Oct 19, 2021
98fa8c5
Merge pull request #206 from phuse-org/extend_file_extensions
thebioengineer Oct 20, 2021
069f946
Merge pull request #207 from phuse-org/vt_file_interactive_knitting
thebioengineer Oct 28, 2021
7e4f250
Merge branch 'develop' into release_0.4.0
thebioengineer Oct 28, 2021
bffffab
Giving informative error message when root cannot be found
thebioengineer Oct 28, 2021
34df0b0
Correct sentence structure
thebioengineer Oct 28, 2021
7a56d39
NOrmalize paths for error messages?
thebioengineer Oct 28, 2021
8cb4b0c
Merge pull request #210 from phuse-org/out_of_project_warnings
thebioengineer Nov 2, 2021
5282766
Merge branch 'develop' into release_0.4.0
thebioengineer Nov 2, 2021
00e4f7c
Add Maya as a contributor (resolves #211)
thebioengineer Nov 4, 2021
a28a050
Merge branch 'develop' into release_0.4.0
thebioengineer Nov 4, 2021
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
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ CONTRIBUTING.md
^validation\.yml$

vignettes/validation/validation.yml
^man/figures/cheatsheets/*
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
valtools.Rproj
.Rproj.user
.Rhistory
inst/doc
11 changes: 8 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Package: valtools
Title: Automate Validated Package Creation
Version: 0.3.0
Version: 0.4.0
Authors@R:
c(
person(given = "Ellis",
family = "Hughes",
role = c("aut","cre"),
email = "[email protected]",
email = "[email protected]",
comment = c(ORCID = "0000-0003-0637-4436")),
person(given = "Eli",
family = "Miller",
Expand All @@ -23,6 +23,11 @@ Authors@R:
role = "aut",
email = "[email protected]",
comment = c(ORCID = "0000-0003-1613-2705")),
person(given = "Maya",
family = "Gans",
role = "ctb",
email = "[email protected]",
comment = c(ORCID = "0000-0002-5452-6089")),
person(given = "PHUSE",
role = "cph")
)
Expand All @@ -35,7 +40,7 @@ License: MIT + file LICENSE
Encoding: UTF-8
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.1.1
RoxygenNote: 7.1.2
Suggests:
covr,
XML,
Expand Down
5 changes: 5 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ S3method(roxy_tag_rd,roxy_tag_riskAssessment)
export(vt_add_file_to_config)
export(vt_add_user_to_config)
export(vt_create_package)
export(vt_create_packet)
export(vt_drop_file_from_config)
export(vt_drop_user_from_config)
export(vt_dynamic_referencer)
Expand Down Expand Up @@ -87,6 +88,7 @@ importFrom(kableExtra,kable_styling)
importFrom(knitr,asis_output)
importFrom(knitr,current_input)
importFrom(knitr,kable)
importFrom(knitr,knit)
importFrom(knitr,knit_child)
importFrom(knitr,opts_knit)
importFrom(lubridate,parse_date_time)
Expand Down Expand Up @@ -128,9 +130,12 @@ importFrom(tools,file_ext)
importFrom(tools,file_path_sans_ext)
importFrom(usethis,create_package)
importFrom(usethis,edit_file)
importFrom(usethis,local_project)
importFrom(usethis,proj_activate)
importFrom(usethis,ui_stop)
importFrom(usethis,ui_value)
importFrom(usethis,use_git_ignore)
importFrom(usethis,use_rstudio)
importFrom(usethis,write_union)
importFrom(utils,capture.output)
importFrom(utils,getFromNamespace)
Expand Down
15 changes: 9 additions & 6 deletions R/case.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
vt_use_test_case <- function(name, username = vt_username(), title = NULL, open = interactive(),
add_before = NULL, add_after = NULL) {

name <- vt_set_ext(name, ext = "md")
name <- vt_set_ext(name, ext = c("md","rmd"))

is_valid_name(name)

Expand All @@ -60,14 +60,17 @@ vt_use_test_case <- function(name, username = vt_username(), title = NULL, open
username = username,
editDate = as.character(Sys.Date())
))


# Add file to validation configuration
vt_add_file_to_config(
filename = name,
after = {{add_after}},
before = {{add_before}}
)
}

# Add file to validation configuration
vt_add_file_to_config(filename = name, after = {{add_after}}, before = {{add_before}})

if(open){
edit_file(case_name)
edit_file(case_name) # nocov
}

invisible(case_name)
Expand Down
13 changes: 9 additions & 4 deletions R/code.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,19 @@ vt_use_test_code <- function(name, username = vt_username(), open = interactive(
username = username,
editDate = as.character(Sys.Date())
))

# Add file to validation configuration
vt_add_file_to_config(
filename = name,
after = {{add_after}},
before = {{add_before}}
)
}

# Add file to validation configuration
vt_add_file_to_config(filename = name, after = {{add_after}},
before = {{add_before}})


if(open){
edit_file(code_name)
edit_file(code_name) # nocov
}

invisible(code_name)
Expand Down
27 changes: 19 additions & 8 deletions R/coverage-matrix.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@ vt_scrape_coverage_matrix <- function(type = c("long", "wide"),
do.call("rbind", apply(vals, 1, FUN = function(x){

this_row <- strsplit(x[["coverage"]], split = ":")[[1]]
if(length(this_row) == 1){
this_row <- rep(this_row, 2)

} else if(length(this_row) != 2){
rlang::abort(paste("Coverage details must follow format Test_Case:Requirement.",
"See", x[["tc_title"]]),
if(length(this_row) != 2){
rlang::abort(paste0("Coverage details must follow format Test_Case:Requirement.",
" See ", x[["tc_title"]], ", Coverage Entry: ",trimws(x[["coverage"]])),
class = "vt.coverage_format")
}
names(this_row) <- c("tc_id", "req_id")
Expand All @@ -31,19 +29,31 @@ vt_scrape_coverage_matrix <- function(type = c("long", "wide"),
}

split_req <- function(vals){
do.call("rbind", apply(vals, 1, FUN = function(x){
out <- do.call("rbind", apply(vals, 1, FUN = function(x){


req_one_row <- data.frame(tc_title = x[["tc_title"]],
tc_id = x[["tc_id"]],
req_id = strsplit(trimws(x[["req_id"]]), split = ", ")[[1]],
req_id = trimws(strsplit(trimws(x[["req_id"]]), split = ", ")[[1]]),
deprecate = x[["deprecate"]],
stringsAsFactors = FALSE)



req_one_row$req_title <- paste0("Requirement ", gsub(req_one_row$req_id,
pattern = "^(\\d+)\\.*.*",
replacement = "\\1"))

req_one_row
}))

# req_title uses only first numeric position
out$req_title <- factor(out$req_title,
levels = paste0("Requirement ",
sort(as.numeric(unique(unlist(lapply(strsplit(out$req_title, split = " "),
function(x){x[2]})))))))
out[order(out$req_title),]

}

# avoids dependency on tidyr::pivot_wider
Expand All @@ -64,6 +74,7 @@ vt_scrape_coverage_matrix <- function(type = c("long", "wide"),
x
})
out <- do.call("rbind", list_all_x)

row.names(out) <- 1:nrow(out)
out[, c("req_title", "req_id", sort(names(out)[-1:-2]))]
}
Expand Down Expand Up @@ -91,7 +102,7 @@ vt_scrape_coverage_matrix <- function(type = c("long", "wide"),
vals_all <- split_req(numbered_cov_vals)

if(type[1] == "long"){
out_data <- vals_all[order(vals_all$req_id),]
out_data <- vals_all[order(vals_all$req_title),]
row.names(out_data) <- 1:nrow(out_data)
out_data <- out_data[, c("req_title", "req_id", "tc_title", "tc_id", "deprecate")]
attr(out_data, "table_type") <- "long"
Expand Down
5 changes: 4 additions & 1 deletion R/dynamic_referencing.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,12 @@ vt_dynamic_referencer <- R6::R6Class("vt_dynamic_referencer",
#' ref$list_references()

scrape_references = function(text){

## Drop roxygen comment headers from text for scraping references.
text <- unname(unlist(text[!grepl("^#'", text)]))

## drop NA text from scraping
text <- text[!is.na(text)]

reference_locations <-
gregexpr(
Expand Down
14 changes: 12 additions & 2 deletions R/file_and_path_utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,18 @@ vt_path <- function(...){
#'
#' @export
vt_find_config <- function(){

root <- find_root(has_file(".here") | is_rstudio_project | is_r_package | is_vcs_root)

tryCatch({
root <- find_root(has_file(".here") | is_rstudio_project | is_r_package | is_vcs_root)
}, error = function(e){
abort(
paste0(
"Could not find root directory. ",
"Is your working directory inside a package, validation packet, or project?\n"
),
class = "vt.validation_root_missing"
)
})

tryCatch({

Expand Down
67 changes: 66 additions & 1 deletion R/init.R
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ vt_use_validation <- function( pkg = ".", working_dir, ...) {
#' @inheritParams usethis::create_package
#'
#' @importFrom usethis create_package
#' @importFrom rlang inform abort
#' @importFrom rlang inform abort is_interactive
#'
#' @rdname val_init
#'
Expand Down Expand Up @@ -89,6 +89,62 @@ vt_create_package <- function(pkg = ".", ..., fields = list(), rstudio = rstudio

}

#' @description Create the validation packet infrastructure. Intended to create
#' validation infrastructure external to an R package.
#'
#' @param target target of validation. Character name of package or scope validation packet is being performed for.
#' @param ... Additional argument passed to `vt_use_config()`
#' @inheritParams usethis::create_project
#'
#' @importFrom usethis use_rstudio local_project proj_activate
#' @importFrom rlang inform abort is_interactive
#'
#' @rdname val_init
#'
#' @export
vt_create_packet <- function(path = ".", target, ..., rstudio = rstudioapi::isAvailable(), open = rlang::is_interactive()) {

if(is_package(path)){
abort(paste0(
"`vt_create_packet()` is not intended to add validation infrastructure",
" to an existing package. Use `vt_use_validation()` instead."
))
}

tryCatch({

if(!dir.exists(path)){
dir.create(path = path, recursive = TRUE, showWarnings = FALSE)
usethis::with_project(path = path,force = TRUE,{
if(rstudio){
usethis::use_rstudio()
}else{
file.create(".here")
}
})
}

## set up validation structure in package & create basic config for validation
vt_use_validation(pkg = path, working_dir = ".", package = target, ...)

inform("Created validation packet",
class = "vt.initPacket")

}, error = function(e) {
abort(paste0("Failed to create validation packet.\n", #nocov
e, sep = "\n"), #nocov
class = "vt.initPacketFail") #nocov

})

if(open){
usethis::proj_activate(path = path)
}

invisible()

}

#' Internal wrapper function to call vt_create_package().
#' To be used by RStudio project wizard, preventing opening the project twice.
#'
Expand All @@ -99,5 +155,14 @@ vt_create_package_wizard <- function(path, ...){
vt_create_package(pkg= path, open= FALSE, ...) # nocov
}

#' Internal wrapper function to call vt_create_packet().
#' To be used by RStudio project wizard, preventing opening the project twice.
#'
#' @param path Project directory, collected through project wizard
#'
#' @noRd
vt_create_packet_wizard <- function(path, ...){
vt_create_packet(path = path, open= FALSE, ...) # nocov
}


11 changes: 8 additions & 3 deletions R/req.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ vt_use_req <- function(name, username = vt_username(), title = NULL, open = inte
add_before = NULL, add_after = NULL){

# ensure file extensions are of the acceptable type
name <- vt_set_ext(name, ext = "md")
name <- vt_set_ext(name, ext = c("md", "rmd"))

is_valid_name(name)

Expand All @@ -29,12 +29,17 @@ vt_use_req <- function(name, username = vt_username(), title = NULL, open = inte
title = title,
editDate = as.character(Sys.Date())
))

vt_add_file_to_config(
filename = name,
after = {{add_after}},
before = {{add_before}}
)
}

vt_add_file_to_config(filename = name, after = {{add_after}}, before = {{add_before}})

if(open){
edit_file(req_name)
edit_file(req_name) # nocov
}

invisible(req_name)
Expand Down
3 changes: 3 additions & 0 deletions R/roxygen_extension.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ roxy_tag_parse.roxy_tag_deprecate <- function(x) {
tag_markdown(x)
}

# nocov start

#' @export
#' @importFrom roxygen2 rd_section roxy_tag_rd
roxy_tag_rd.roxy_tag_editor <- function(x, base_path, env) {
Expand Down Expand Up @@ -97,6 +99,7 @@ format.rd_section_deprecate <- function(x, ...) {
)
}

# nocov end

format_coverage_text <- function(x){

Expand Down
Loading