diff --git a/R/DataPackageR-defunct.R b/R/DataPackageR-defunct.R new file mode 100644 index 0000000..dd9833f --- /dev/null +++ b/R/DataPackageR-defunct.R @@ -0,0 +1,29 @@ +## Defunct functions in DataPackageR +#' @title Defunct functions in package \pkg{DataPackageR}. +#' @description These functions are defunct and no longer supported. +#' Calling them will result in an error. +#' +#' When possible, alternatives are suggested. +#' +#' @name DataPackageR-defunct +#' @param ... All arguments are now ignored. +#' @returns Defunct function. No return value. +NULL + +#' @rdname DataPackageR-defunct +#' @export +datapackage.skeleton <- function(...) { + .Defunct('datapackage_skeleton()', package = 'DataPackageR') +} + +#' @rdname DataPackageR-defunct +#' @export +dataVersion <- function(...) { + .Defunct('data_version()', package = 'DataPackageR') +} + +#' @rdname DataPackageR-defunct +#' @export +keepDataObjects <- function(...) { + .Defunct('datapackager.yml', package = 'DataPackageR') +} diff --git a/R/build.R b/R/build.R index 5c38f6f..5c026af 100644 --- a/R/build.R +++ b/R/build.R @@ -131,23 +131,13 @@ package_build <- function(packageName = NULL, cat(crayon::white(" - Add the github repository as a remote of your local package repository."), "\n") # nolint cat(crayon::white(" - ", crayon::red("git push"), " your local repository to gitub."), "\n") # nolint } -#' These functions are no longer available. -#' -#' @name keepDataObjects-defunct -#' @aliases keepDataObjects -#' @param ... arguments -#' @returns Defunct. No return value. -#' @rdname keepDataObjects-defunct -#' @export -keepDataObjects <- function(...) { - .Defunct(msg = "keepDataObjects is defunct as of version 0.12.1 of DataPackageR. \nUse the config.yml file to control packaging.") # nolint -} #' Check that pkg name inferred from pkg path is same as pkg name in DESCRIPTION #' #' @param package_path Package path #' #' @returns Package name (character) if validated +#' @noRd validate_pkg_name <- function(package_path){ desc_pkg_name <- desc::desc( file = file.path(package_path, 'DESCRIPTION') diff --git a/R/dataversion.R b/R/dataversion.R index 31e28d9..82d8ee0 100644 --- a/R/dataversion.R +++ b/R/dataversion.R @@ -9,7 +9,6 @@ #' @seealso \code{\link[utils]{packageVersion}} #' @rdname data_version #' @returns Object of class 'package_version' and 'numeric_version' specifying the DataVersion of the package -#' @note \code{dataVersion()} has been renamed to \code{data_version()} #' @export #' @examples #' if(rmarkdown::pandoc_available()){ @@ -50,13 +49,6 @@ data_version <- function(pkg, lib.loc = NULL) { } } -#' @rdname data_version -#' @export -dataVersion <- function(pkg, lib.loc = NULL) { - warning("Please use data_version() instead of dataVersion().") - data_version(pkg = pkg, lib.loc = lib.loc) -} - .increment_data_version <- function(pkg_description, new_data_digest, which = "patch") { if (!which %in% c("major", "minor", "patch")) { diff --git a/R/processData.R b/R/processData.R index 06770f3..6629597 100644 --- a/R/processData.R +++ b/R/processData.R @@ -29,6 +29,7 @@ #' @importFrom desc desc #' @importFrom rmarkdown render #' @importFrom usethis proj_set proj_get +#' @noRd DataPackageR <- function(arg = NULL, deps = TRUE) { if (! getOption('DataPackageR_verbose', TRUE)){ withr::local_options(list(usethis.quiet = TRUE)) @@ -201,6 +202,7 @@ DataPackageR <- function(arg = NULL, deps = TRUE) { #' @param ymlconf YAML configuration list produced by validate_yml() #' #' @return Character vector of enabled R and Rmd files specified in YAML file +#' @noRd get_yml_r_files <- function(ymlconf) { r_files <- names( Filter( @@ -215,6 +217,7 @@ get_yml_r_files <- function(ymlconf) { #' @param ymlconf YAML configuration list produced by validate_yml() #' #' @return Character vector of object names +#' @noRd get_yml_objects <- function(ymlconf){ ymlconf$configuration$objects } @@ -224,6 +227,7 @@ get_yml_objects <- function(ymlconf){ #' @param pkg_dir Path of top level of data package #' #' @return List object from read_yaml(ymlfile) +#' @noRd validate_yml <- function(pkg_dir){ # read YAML ymlfile <- list.files( @@ -297,6 +301,7 @@ validate_yml <- function(pkg_dir){ #' @param pkg_dir Path of top level of data package #' #' @return Silently returns pkg_dir if no errors thrown +#' @noRd validate_package_skeleton <- function(pkg_dir){ # we know it's a proper package root, but we want to test if we have the # necessary subdirectories @@ -318,6 +323,7 @@ validate_package_skeleton <- function(pkg_dir){ #' @param dataenv The data environment, from DataPackageR #' #' @returns TRUE if success +#' @noRd do_digests <- function(pkg_dir, dataenv) { # Digest each object old_data_digest <- .parse_data_digest(pkg_dir = pkg_dir) @@ -433,6 +439,7 @@ do_digests <- function(pkg_dir, dataenv) { #' @param pkg_dir The top level file path of the data package #' @param dataenv The data environment, from DataPackageR #' @returns TRUE if success +#' @noRd do_doc <- function(pkg_dir, dataenv) { # Run .doc_autogen #needs to be run when we have a partial build.. if (!file.exists(file.path(pkg_dir, 'data-raw', "documentation.R"))) { diff --git a/R/skeleton.R b/R/skeleton.R index 6730acb..11fab03 100644 --- a/R/skeleton.R +++ b/R/skeleton.R @@ -28,8 +28,21 @@ #' @param raw_data_dir \code{character} pointing to a raw data directory. Will be moved with all its subdirectories to "inst/extdata" #' @param dependencies \code{vector} of \code{character}, paths to R files that will be moved to "data-raw" but not included in the yaml config file. e.g., dependency scripts. #' @returns No return value, called for side effects -#' @note renamed \code{datapackage.skeleton()} to \code{datapackage_skeleton()}. #' @importFrom crayon bold green +#' @examples +#' if(rmarkdown::pandoc_available()){ +#' f <- tempdir() +#' f <- file.path(f,"foo.Rmd") +#' con <- file(f) +#' writeLines("```{r}\n tbl = data.frame(1:10) \n```\n",con=con) +#' close(con) +#' pname <- basename(tempfile()) +#' datapackage_skeleton(name = pname, +#' path = tempdir(), +#' force = TRUE, +#' r_object_names = "tbl", +#' code_files = f) +#' } #' @export datapackage_skeleton <- function(name = NULL, @@ -90,7 +103,7 @@ datapackage_skeleton <- "'inst/extdata/'. If the datasets are large,", "they may reside elsewhere outside the package", "source tree. If you passed R and Rmd files to", - "datapackage.skeleton, they should now appear in 'data-raw'.", + "datapackage_skeleton(), they should now appear in 'data-raw'.", "When you call package_build(), your datasets will", "be automatically documented. Edit datapackager.yml to", "add additional files / data objects to the package.", @@ -169,47 +182,6 @@ datapackage_skeleton <- invisible(NULL) } - -#' @rdname datapackage_skeleton -#' @name datapackage.skeleton -#' @param list Not used. -#' @param environment Not used. -#' @aliases datapackage_skeleton -#' @export -#' @examples -#' if(rmarkdown::pandoc_available()){ -#' f <- tempdir() -#' f <- file.path(f,"foo.Rmd") -#' con <- file(f) -#' writeLines("```{r}\n tbl = data.frame(1:10) \n```\n",con=con) -#' close(con) -#' pname <- basename(tempfile()) -#' datapackage_skeleton(name = pname, -#' path = tempdir(), -#' force = TRUE, -#' r_object_names = "tbl", -#' code_files = f) -#' } -datapackage.skeleton <- function(name = NULL, - list = character(), - environment = .GlobalEnv, - path = ".", - force = FALSE, - code_files = character(), - r_object_names = character()) { - warning("Please use datapackage_skeleton() instead of datapackage.skeleton()") - proj_path <- datapackage_skeleton( - name = name, - path = path, - force = force, - code_files = code_files, - r_object_names = r_object_names - ) - if(is.character(proj_path)){ - usethis::proj_set(proj_path) - } -} - .done <- function(...) { .bullet(paste0(...), bullet = crayon::green("\u2714")) } diff --git a/man/DataPackageR-defunct.Rd b/man/DataPackageR-defunct.Rd new file mode 100644 index 0000000..e6ef5c0 --- /dev/null +++ b/man/DataPackageR-defunct.Rd @@ -0,0 +1,27 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/DataPackageR-defunct.R +\name{DataPackageR-defunct} +\alias{DataPackageR-defunct} +\alias{datapackage.skeleton} +\alias{dataVersion} +\alias{keepDataObjects} +\title{Defunct functions in package \pkg{DataPackageR}.} +\usage{ +datapackage.skeleton(...) + +dataVersion(...) + +keepDataObjects(...) +} +\arguments{ +\item{...}{All arguments are now ignored.} +} +\value{ +Defunct function. No return value. +} +\description{ +These functions are defunct and no longer supported. +Calling them will result in an error. + +When possible, alternatives are suggested. +} diff --git a/man/DataPackageR-package.Rd b/man/DataPackageR-package.Rd index 013059d..74b8bc2 100644 --- a/man/DataPackageR-package.Rd +++ b/man/DataPackageR-package.Rd @@ -2,6 +2,7 @@ % Please edit documentation in R/DataPackageR-package.R \docType{package} \name{DataPackageR-package} +\alias{DataPackageR} \alias{DataPackageR-package} \title{DataPackageR} \description{ diff --git a/man/DataPackageR.Rd b/man/DataPackageR.Rd deleted file mode 100644 index 335496f..0000000 --- a/man/DataPackageR.Rd +++ /dev/null @@ -1,22 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/processData.R -\name{DataPackageR} -\alias{DataPackageR} -\title{Process data generation code in 'data-raw'} -\usage{ -DataPackageR(arg = NULL, deps = TRUE) -} -\arguments{ -\item{arg}{\code{character} name of the package to build.} - -\item{deps}{\code{logical} should scripts pass data objects to each other (default=TRUE)} -} -\value{ -logical TRUE if successful, FALSE, if not. -} -\description{ -Assumes .R files in 'data-raw' generate rda files to be stored in 'data'. -Sources datasets.R which can source other R files. -R files sourced by datasets.R must invoke \code{sys.source('myRfile.R',env=topenv())}. -Meant to be called before R CMD build. -} diff --git a/man/data_version.Rd b/man/data_version.Rd index f535388..128b184 100644 --- a/man/data_version.Rd +++ b/man/data_version.Rd @@ -2,12 +2,9 @@ % Please edit documentation in R/dataversion.R \name{data_version} \alias{data_version} -\alias{dataVersion} \title{Get the DataVersion for a package} \usage{ data_version(pkg, lib.loc = NULL) - -dataVersion(pkg, lib.loc = NULL) } \arguments{ \item{pkg}{\code{character} the package name} @@ -20,9 +17,6 @@ Object of class 'package_version' and 'numeric_version' specifying the DataVersi \description{ Retrieves the DataVersion of a package if available } -\note{ -\code{dataVersion()} has been renamed to \code{data_version()} -} \examples{ if(rmarkdown::pandoc_available()){ f <- tempdir() diff --git a/man/datapackage_skeleton.Rd b/man/datapackage_skeleton.Rd index 334ad58..755c165 100644 --- a/man/datapackage_skeleton.Rd +++ b/man/datapackage_skeleton.Rd @@ -2,7 +2,6 @@ % Please edit documentation in R/skeleton.R \name{datapackage_skeleton} \alias{datapackage_skeleton} -\alias{datapackage.skeleton} \title{Create a Data Package skeleton for use with DataPackageR.} \usage{ datapackage_skeleton( @@ -14,16 +13,6 @@ datapackage_skeleton( raw_data_dir = character(), dependencies = character() ) - -datapackage.skeleton( - name = NULL, - list = character(), - environment = .GlobalEnv, - path = ".", - force = FALSE, - code_files = character(), - r_object_names = character() -) } \arguments{ \item{name}{\code{character} name of the package to create.} @@ -40,10 +29,6 @@ into R objects.} \item{raw_data_dir}{\code{character} pointing to a raw data directory. Will be moved with all its subdirectories to "inst/extdata"} \item{dependencies}{\code{vector} of \code{character}, paths to R files that will be moved to "data-raw" but not included in the yaml config file. e.g., dependency scripts.} - -\item{list}{Not used.} - -\item{environment}{Not used.} } \value{ No return value, called for side effects @@ -53,9 +38,6 @@ Creates a package skeleton directory structure for use with DataPackageR. Adds the DataVersion string to DESCRIPTION, creates the DATADIGEST file, and the data-raw directory. Updates the Read-and-delete-me file to reflect the additional necessary steps. } -\note{ -renamed \code{datapackage.skeleton()} to \code{datapackage_skeleton()}. -} \examples{ if(rmarkdown::pandoc_available()){ f <- tempdir() diff --git a/man/do_digests.Rd b/man/do_digests.Rd deleted file mode 100644 index ff73680..0000000 --- a/man/do_digests.Rd +++ /dev/null @@ -1,19 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/processData.R -\name{do_digests} -\alias{do_digests} -\title{do_digests() function extracted out from DataPackageR} -\usage{ -do_digests(pkg_dir, dataenv) -} -\arguments{ -\item{pkg_dir}{The top level file path of the data package} - -\item{dataenv}{The data environment, from DataPackageR} -} -\value{ -TRUE if success -} -\description{ -do_digests() function extracted out from DataPackageR -} diff --git a/man/do_doc.Rd b/man/do_doc.Rd deleted file mode 100644 index 5bf43b9..0000000 --- a/man/do_doc.Rd +++ /dev/null @@ -1,19 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/processData.R -\name{do_doc} -\alias{do_doc} -\title{do_doc() function extracted out from end of DataPackageR} -\usage{ -do_doc(pkg_dir, dataenv) -} -\arguments{ -\item{pkg_dir}{The top level file path of the data package} - -\item{dataenv}{The data environment, from DataPackageR} -} -\value{ -TRUE if success -} -\description{ -do_doc() function extracted out from end of DataPackageR -} diff --git a/man/get_yml_objects.Rd b/man/get_yml_objects.Rd deleted file mode 100644 index 427fe02..0000000 --- a/man/get_yml_objects.Rd +++ /dev/null @@ -1,17 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/processData.R -\name{get_yml_objects} -\alias{get_yml_objects} -\title{Get data objects from YAML configuration} -\usage{ -get_yml_objects(ymlconf) -} -\arguments{ -\item{ymlconf}{YAML configuration list produced by validate_yml()} -} -\value{ -Character vector of object names -} -\description{ -Get data objects from YAML configuration -} diff --git a/man/get_yml_r_files.Rd b/man/get_yml_r_files.Rd deleted file mode 100644 index ddd3950..0000000 --- a/man/get_yml_r_files.Rd +++ /dev/null @@ -1,17 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/processData.R -\name{get_yml_r_files} -\alias{get_yml_r_files} -\title{Get R and Rmd files from YAML configuration} -\usage{ -get_yml_r_files(ymlconf) -} -\arguments{ -\item{ymlconf}{YAML configuration list produced by validate_yml()} -} -\value{ -Character vector of enabled R and Rmd files specified in YAML file -} -\description{ -Get R and Rmd files from YAML configuration -} diff --git a/man/keepDataObjects-defunct.Rd b/man/keepDataObjects-defunct.Rd deleted file mode 100644 index 2547cff..0000000 --- a/man/keepDataObjects-defunct.Rd +++ /dev/null @@ -1,18 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/build.R -\name{keepDataObjects-defunct} -\alias{keepDataObjects-defunct} -\alias{keepDataObjects} -\title{These functions are no longer available.} -\usage{ -keepDataObjects(...) -} -\arguments{ -\item{...}{arguments} -} -\value{ -Defunct. No return value. -} -\description{ -These functions are no longer available. -} diff --git a/man/validate_package_skeleton.Rd b/man/validate_package_skeleton.Rd deleted file mode 100644 index 2f192d6..0000000 --- a/man/validate_package_skeleton.Rd +++ /dev/null @@ -1,17 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/processData.R -\name{validate_package_skeleton} -\alias{validate_package_skeleton} -\title{Validate data package skeleton, extracted out from big DataPackageR function} -\usage{ -validate_package_skeleton(pkg_dir) -} -\arguments{ -\item{pkg_dir}{Path of top level of data package} -} -\value{ -Silently returns pkg_dir if no errors thrown -} -\description{ -Validate data package skeleton, extracted out from big DataPackageR function -} diff --git a/man/validate_pkg_name.Rd b/man/validate_pkg_name.Rd deleted file mode 100644 index 93e067b..0000000 --- a/man/validate_pkg_name.Rd +++ /dev/null @@ -1,17 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/build.R -\name{validate_pkg_name} -\alias{validate_pkg_name} -\title{Check that pkg name inferred from pkg path is same as pkg name in DESCRIPTION} -\usage{ -validate_pkg_name(package_path) -} -\arguments{ -\item{package_path}{Package path} -} -\value{ -Package name (character) if validated -} -\description{ -Check that pkg name inferred from pkg path is same as pkg name in DESCRIPTION -} diff --git a/man/validate_yml.Rd b/man/validate_yml.Rd deleted file mode 100644 index 62a068d..0000000 --- a/man/validate_yml.Rd +++ /dev/null @@ -1,17 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/processData.R -\name{validate_yml} -\alias{validate_yml} -\title{Validate YAML file, extracted out from big DataPackageR function} -\usage{ -validate_yml(pkg_dir) -} -\arguments{ -\item{pkg_dir}{Path of top level of data package} -} -\value{ -List object from read_yaml(ymlfile) -} -\description{ -Validate YAML file, extracted out from big DataPackageR function -} diff --git a/tests/testthat/test-data-version.R b/tests/testthat/test-data-version.R index e423f42..1addb81 100644 --- a/tests/testthat/test-data-version.R +++ b/tests/testthat/test-data-version.R @@ -17,13 +17,13 @@ test_that("assert_data_version", { ) close(con) pname <- basename(tempfile()) - suppressWarnings(datapackage.skeleton( + datapackage_skeleton( name = pname, path = normalizePath(tempdir()), force = TRUE, r_object_names = "tbl", code_files = f - )) + ) package_build(file.path(tempdir(), pname)) on.exit(devtools::unload(pname)) devtools::load_all(file.path(tempdir(), pname)) @@ -114,5 +114,4 @@ test_that("assert_data_version", { acceptable = "equal_or_greater" ) ) - expect_error(keepDataObjects()) })