From 4ac962dac62634ad4483c2c9e7552e57c6cec1cb Mon Sep 17 00:00:00 2001 From: Dirk Eddelbuettel Date: Wed, 28 Aug 2024 11:09:41 -0500 Subject: [PATCH 1/2] Support Authors@R via Rcpp.package.skeleton() --- ChangeLog | 5 +++++ R/Rcpp.package.skeleton.R | 23 +++++++++++++++------- inst/tinytest/test_rcpp_package_skeleton.R | 6 ++---- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8355e95d8..fcd440432 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2024-08-28 Dirk Eddelbuettel + + * R/Rcpp.package.skeleton.R: Create DESCRIPTION with Auhors@R fiel + * inst/tinytest/test_rcpp_package_skeleton.R: Adjust tests + 2024-08-20 Dirk Eddelbuettel * inst/tinytest/test_sugar.R: Skip one more NA related test on arm64 diff --git a/R/Rcpp.package.skeleton.R b/R/Rcpp.package.skeleton.R index e0544eb88..4bc4462c0 100644 --- a/R/Rcpp.package.skeleton.R +++ b/R/Rcpp.package.skeleton.R @@ -81,18 +81,27 @@ Rcpp.package.skeleton <- function(name = "anRpackage", list = character(), DESCRIPTION <- file.path(root, "DESCRIPTION") if (file.exists(DESCRIPTION)) { imports <- c(if (isTRUE(module)) "methods", sprintf("Rcpp (>= %s)", getRcppVersion())) - x <- cbind(read.dcf(DESCRIPTION), + splitname <- strsplit(author, " ")[[1]] + x <- cbind(read.dcf(DESCRIPTION, fields = c("Package", "Type", "Title", "Version", "Date", + "Description", "License")), "Imports" = paste(imports, collapse = ", "), - "LinkingTo" = "Rcpp") - x[, "Author"] <- author - x[, "Maintainer"] <- sprintf("%s <%s>", maintainer, email) + "LinkingTo" = "Rcpp", + "Authors@R" = sprintf(r"(person("%s", "%s", role = c("aut", "cre"), email = "%s"))", + paste(splitname[-length(splitname)], collapse=" "), + splitname[length(splitname)], + email)) + #x[, "Author"] <- author + #x[, "Maintainer"] <- sprintf("%s <%s>", maintainer, email) x[, "License"] <- license - x[, "Title"] <- "What the Package Does in One 'Title Case' Line" - x[, "Description"] <- "One paragraph description of what the package does as one or more full sentences." + x[, "Title"] <- "Concise Summary of What the Package Does" + x[, "Description"] <- "More about what it does (maybe more than one line)." message( " >> added Imports: Rcpp" ) message( " >> added LinkingTo: Rcpp" ) write.dcf(x, file = DESCRIPTION) - + write.dcf(x[1, c("Package", "Type", "Title", "Version", "Date", + "Authors@R", "Description", "License", "Imports", "LinkingTo"), + drop = FALSE], + file = DESCRIPTION) } ## add useDynLib and importFrom to NAMESPACE diff --git a/inst/tinytest/test_rcpp_package_skeleton.R b/inst/tinytest/test_rcpp_package_skeleton.R index b1107c315..cb2bdd8b0 100644 --- a/inst/tinytest/test_rcpp_package_skeleton.R +++ b/inst/tinytest/test_rcpp_package_skeleton.R @@ -45,10 +45,8 @@ checkTrue( "foo" %in% list.files(path), "pkg path generated as named" ) ## check the DESCRIPTION DESCRIPTION <- as.list( read.dcf( file.path(pkg_path, "DESCRIPTION") )[1,] ) -checkTrue( DESCRIPTION["Author"] == "Boo-Boo Bear", - "wrote the Author field in DESCRIPTION" ) -checkTrue( DESCRIPTION["Maintainer"] == "Yogi Bear ", - "wrote the Maintainer field in DESCRIPTION") +checkTrue( DESCRIPTION["Authors@R"] == 'person("Boo-Boo", "Bear", role = c("aut", "cre"), email = "yogibear@yogimail.com")', "wrote the Authors@R field in DESCRIPTION" ) +checkTrue( DESCRIPTION["Date"] == format(Sys.Date()), "uses current date in DESCRIPTION") checkTrue( DESCRIPTION["License"] == "An Opensource License", "wrote the License field in DESCRIPTION" ) checkTrue( DESCRIPTION["LinkingTo"] == "Rcpp", From d7858cb92fe357489cc5ba4b54001b493d1424e7 Mon Sep 17 00:00:00 2001 From: Dirk Eddelbuettel Date: Wed, 28 Aug 2024 11:29:36 -0500 Subject: [PATCH 2/2] No raw strings in old R versions --- R/Rcpp.package.skeleton.R | 2 +- inst/tinytest/test_rcpp_package_skeleton.R | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/R/Rcpp.package.skeleton.R b/R/Rcpp.package.skeleton.R index 4bc4462c0..80be4380a 100644 --- a/R/Rcpp.package.skeleton.R +++ b/R/Rcpp.package.skeleton.R @@ -86,7 +86,7 @@ Rcpp.package.skeleton <- function(name = "anRpackage", list = character(), "Description", "License")), "Imports" = paste(imports, collapse = ", "), "LinkingTo" = "Rcpp", - "Authors@R" = sprintf(r"(person("%s", "%s", role = c("aut", "cre"), email = "%s"))", + "Authors@R" = sprintf("person(\"%s\", \"%s\", role = c(\"aut\", \"cre\"), email = \"%s\")", paste(splitname[-length(splitname)], collapse=" "), splitname[length(splitname)], email)) diff --git a/inst/tinytest/test_rcpp_package_skeleton.R b/inst/tinytest/test_rcpp_package_skeleton.R index cb2bdd8b0..bf02c4a28 100644 --- a/inst/tinytest/test_rcpp_package_skeleton.R +++ b/inst/tinytest/test_rcpp_package_skeleton.R @@ -45,7 +45,9 @@ checkTrue( "foo" %in% list.files(path), "pkg path generated as named" ) ## check the DESCRIPTION DESCRIPTION <- as.list( read.dcf( file.path(pkg_path, "DESCRIPTION") )[1,] ) -checkTrue( DESCRIPTION["Authors@R"] == 'person("Boo-Boo", "Bear", role = c("aut", "cre"), email = "yogibear@yogimail.com")', "wrote the Authors@R field in DESCRIPTION" ) +checkEqual(gsub("\\n", " ", DESCRIPTION["Authors@R"]), # need to neutralise a line break + 'person("Boo-Boo", "Bear", role = c("aut", "cre"), email = "yogibear@yogimail.com")', + "wrote the Authors@R field in DESCRIPTION" ) checkTrue( DESCRIPTION["Date"] == format(Sys.Date()), "uses current date in DESCRIPTION") checkTrue( DESCRIPTION["License"] == "An Opensource License", "wrote the License field in DESCRIPTION" )