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

Devel in details #318

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ jobs:
if: ${ (env.ACT || false)}
run: sudo apt update
- name: Install Tidy Ubuntu
run: sudo apt install -y tidy
run: apt update && sudo apt install -y tidy
- name: build tarball for submission to CRAN
run: R CMD build $GITHUB_WORKSPACE
- name: Grab tarball path
Expand Down
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@

## CHANGES
* Updated `pkgnet-intro` vignette to include information on the Class Inheritance Reporter and other minor edits.
* Recursive function network creation made tolerant to empty lists. (#322)
* Excessive warnings removed for custom `vignette_path` param in `CreatePackageVignette()` (#322)

## BUGFIXES
* `CreatePackageReporter()` failing on Windows to build package coverage when `report_path` specified. (#322)

# pkgnet 0.4.2
## NEW FEATURES
Expand Down
36 changes: 0 additions & 36 deletions R/CreatePackageVignette.R
Original file line number Diff line number Diff line change
Expand Up @@ -85,42 +85,6 @@ CreatePackageVignette <- function(pkg = "."
, dirname(vignette_path)))
}

# Check if vignette_path matches the right package
# if the path is to a file in a directory named vignettes
vignetteDirAbsPath <- normalizePath(dirname(vignette_path))
# If path is a vignettes directory
if (grepl('/vignettes$', vignetteDirAbsPath)) {
# Get path for expected DESCRIPTION file for package
expectedDescriptionPath <- gsub(
pattern = "vignettes$"
, replacement = "DESCRIPTION"
, x = vignetteDirAbsPath
)

# If DESCRIPTION file exists check the name
if (file.exists(expectedDescriptionPath)) {
foundPkgName <- read.dcf(expectedDescriptionPath)[1,][["Package"]]

# If it doesn't match pkg_name, give warning
if (!identical(foundPkgName, pkg_name)) {
log_warn(glue::glue(
"You are writing a report for {pkg_name} to the vignettes "
, "directory for {foundPkgName}"
, pkg_name = pkg_name
, foundPkgName = foundPkgName))
}

# Otherwise, warn that we're writing to a vignettes folder inside
# a directory that is not a package root
} else {
log_warn(paste(
"You specified a path to a vignettes directory"
, vignetteDirAbsPath
, "that is not inside a package root directory."
))
}
}

log_info(sprintf(
"Creating pkgnet package report as vignette for %s..."
, pkg_name
Expand Down
40 changes: 33 additions & 7 deletions R/FunctionReporter.R
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,24 @@ FunctionReporter <- R6::R6Class(

log_info(sprintf("Calculating test coverage for %s...", self$pkg_name))

# workaround for covr conflict with loaded packages on windows
if(.Platform$OS.type == "windows") {
detach(paste0('package:',self$pkg_name), unload = TRUE, character.only = TRUE)
}

pkgCovDT <- data.table::as.data.table(covr::package_coverage(
path = private$pkg_path
, type = "tests"
, combine_types = FALSE
, quiet = FALSE
, clean = FALSE
))

# workaround for covr conflict with loaded packages on windows
if(.Platform$OS.type == "windows") {
attachNamespace(self$pkg_name)
}

pkgCovDT <- pkgCovDT[, .(coveredLines = sum(value > 0)
, totalLines = .N
, coverageRatio = sum(value > 0)/.N
Expand Down Expand Up @@ -395,12 +407,17 @@ FunctionReporter <- R6::R6Class(
if (!is.list(x) && listable) {
x <- as.list(x)

# Check for expression of the form foo$bar
# We still want to split it up because foo might be a function
# but we want to get rid of bar, because it's a symbol in foo's namespace
# and not a symbol that could be reliably matched to the package namespace
if (identical(x[[1]], quote(`$`))) {
x <- x[1:2]
if (length(x) > 0){
# Check for expression of the form foo$bar
# We still want to split it up because foo might be a function
# but we want to get rid of bar, because it's a symbol in foo's namespace
# and not a symbol that could be reliably matched to the package namespace
if (identical(x[[1]], quote(`$`))) {
x <- x[1:2]
}
} else {
# make empty lists "not listable" so recursion stops
listable <- FALSE
}
}

Expand Down Expand Up @@ -643,9 +660,10 @@ FunctionReporter <- R6::R6Class(
if (!is.list(x) && listable) {
xList <- as.list(x)

if (length(xList) > 0){

# Check if expression x is from _$_
if (identical(xList[[1]], quote(`$`))) {

# Check if expression x is of form self$foo, private$foo, or super$foo
# We want to keep those together because they could refer to the class'
# methods. So expression is not listable
Expand All @@ -654,6 +672,7 @@ FunctionReporter <- R6::R6Class(
|| identical(xList[[2]], quote(super))) {
listable <- FALSE


# If expression lefthand side is not keyword, we still want to split
# it up because left might be a function
# but we want to get rid of right, because it's a symbol in left's namespace
Expand All @@ -667,8 +686,15 @@ FunctionReporter <- R6::R6Class(
} else {
x <- xList
}
} else {
# make empty list "non-listable" so recursion stops
listable <- FALSE
}

}



if (listable){
# Filter out atomic values because we don't care about them
x <- Filter(f = Negate(is.atomic), x = x)
Expand Down
1 change: 0 additions & 1 deletion inst/baseballstats/DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,3 @@ Suggests:
License: file LICENSE
LazyData: TRUE
RoxygenNote: 7.1.0
Roxygen: list(r6 = FALSE)
3 changes: 1 addition & 2 deletions inst/milne/DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,4 @@ LinkingTo:
Rcpp
License: file LICENSE
LazyData: TRUE
RoxygenNote: 7.1.0
Roxygen: list(r6 = FALSE)
RoxygenNote: 7.3.1
97 changes: 73 additions & 24 deletions inst/milne/R/The_End.R
Original file line number Diff line number Diff line change
@@ -1,39 +1,59 @@
# R6 Class Definitions for testing

#' @title Age One
#' @name One
#' @family TheEnd
#' @description Age One
#' R6 Class Age One
#'
#' @description
#' Age One
#'
#' @details
#' Age One
#'
#' @importFrom R6 R6Class
#' @export
One <- R6::R6Class(
classname = "One",
public = list(

#' @description
#' Create a New Age One Object
#' @return An Age One Object
initialize = function() {
cat("The End, by A. A. Milne \n")
},

#' @description
#' Print poem
print_poem = function() {
cat("When I was One, \n",
"I had just begun. \n"
)
},

#' @description
#' Get Age
how_old_am_i = function() {private$get_age()}
),
private = list(
get_age = function() {.classname(self)}
)
)

#' @title Age Two
#' @name Two
#' @family TheEnd
#' @description Age Two
#' R6 Class Age Two
#'
#' @description
#' Age Two
#'
#' @details
#' Age Two
#'
#' @importFrom R6 R6Class
#' @export
Two <- R6::R6Class(
classname = "Two",
inherit = One,
public = list(
#' @description
#' Print poem two
print_poem = function() {
super$print_poem()
cat("When I was Two, \n",
Expand All @@ -43,17 +63,23 @@ Two <- R6::R6Class(
)
)

#' @title Age Three
#' @name Three
#' @family TheEnd
#' @description Age Three
#' R6 Class Age Three
#'
#' @description
#' Age Three
#'
#' @details
#' Age Three
#'
#' @importFrom R6 R6Class
#' @export
Three <- R6::R6Class(
# R6 classes don't need classname to match generator name
classname = "HardlyThree",
inherit = Two,
public = list(
#' @description
#' Print poem thrice
print_poem = function() {
super$print_poem()
cat("When I was Three, \n",
Expand All @@ -63,17 +89,23 @@ Three <- R6::R6Class(
)
)

#' @title Age Four
#' @name Four
#' @family TheEnd
#' @description Age Four
#' R6 Class Age Four
#'
#' @description
#' Age Four
#'
#' @details
#' Age Four
#'
#' @importFrom R6 R6Class
#' @export
Four <- R6::R6Class(
# R6 classes don't need classname at all
classname = NULL,
inherit = Three,
public = list(
#' @description
#' Print poem four
print_poem = function() {
super$print_poem()
cat("When I was Four, \n",
Expand All @@ -83,16 +115,24 @@ Four <- R6::R6Class(
)
)

#' @title Age Five
#' @name Five
#' @family TheEnd
#' @description Age Five
#' R6 Class Age Five
#'
#' @description
#' Age Five
#'
#' @details
#' Age Five
#'
#' @importFrom R6 R6Class
#' @export
Five <- R6::R6Class(
classname = "Five",
inherit = Four,
public = list(
#' @description
#' Print poem five times
#' @details
#' Did your hand hit on the river?
print_poem = function() {
super$print_poem()
cat("When I was Five, \n",
Expand All @@ -104,16 +144,24 @@ Five <- R6::R6Class(
)
)

#' @title Age Six
#' @name Six
#' @family TheEnd
#' @description Age Six
#' R6 Class Age Six
#'
#' @description
#' Age Six
#'
#' @details
#' Age Six
#'
#' @importFrom R6 R6Class
#' @export
Six <- R6::R6Class(
classname = "Six",
inherit = Five,
public = list(
#' @description
#' Print poem six times
#' @details
#' I should have looked ahead
print_poem = function() {
super$print_poem()
cat("But now I am Six,",
Expand All @@ -123,6 +171,7 @@ Six <- R6::R6Class(
}
),
private = list(
# I don't think private classes and methods are supported by Roxygen2
print_ending = function() {
cat("So I think I'll be six now",
"for ever and ever."
Expand Down
Loading