Skip to content

Commit

Permalink
Merge pull request #136 from ropensci/nord
Browse files Browse the repository at this point in the history
Make 3 old functions officially Defunct, create Defunct manpage, rm internal fns from manual
  • Loading branch information
slager committed Apr 26, 2024
2 parents 73b8111 + 0b92120 commit 0bfdb4d
Show file tree
Hide file tree
Showing 19 changed files with 82 additions and 252 deletions.
29 changes: 29 additions & 0 deletions 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')
}
12 changes: 1 addition & 11 deletions R/build.R
Expand Up @@ -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')
Expand Down
8 changes: 0 additions & 8 deletions R/dataversion.R
Expand Up @@ -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()){
Expand Down Expand Up @@ -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")) {
Expand Down
7 changes: 7 additions & 0 deletions R/processData.R
Expand Up @@ -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))
Expand Down Expand Up @@ -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(
Expand All @@ -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
}
Expand All @@ -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(
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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"))) {
Expand Down
58 changes: 15 additions & 43 deletions R/skeleton.R
Expand Up @@ -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,
Expand Down Expand Up @@ -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.",
Expand Down Expand Up @@ -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"))
}
Expand Down
27 changes: 27 additions & 0 deletions man/DataPackageR-defunct.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/DataPackageR-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 0 additions & 22 deletions man/DataPackageR.Rd

This file was deleted.

6 changes: 0 additions & 6 deletions man/data_version.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 0 additions & 18 deletions man/datapackage_skeleton.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 0 additions & 19 deletions man/do_digests.Rd

This file was deleted.

19 changes: 0 additions & 19 deletions man/do_doc.Rd

This file was deleted.

17 changes: 0 additions & 17 deletions man/get_yml_objects.Rd

This file was deleted.

0 comments on commit 0bfdb4d

Please sign in to comment.