Skip to content

Commit

Permalink
Support Authors@R in Rcpp.package.skeleton() (#1325)
Browse files Browse the repository at this point in the history
* Support Authors@R via Rcpp.package.skeleton()

* No raw strings in old R versions
  • Loading branch information
eddelbuettel authored Aug 28, 2024
1 parent 9db1de4 commit 1e82f18
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 11 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2024-08-28 Dirk Eddelbuettel <[email protected]>

* 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 <[email protected]>

* inst/tinytest/test_sugar.R: Skip one more NA related test on arm64
Expand Down
23 changes: 16 additions & 7 deletions R/Rcpp.package.skeleton.R
Original file line number Diff line number Diff line change
Expand Up @@ -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("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
Expand Down
8 changes: 4 additions & 4 deletions inst/tinytest/test_rcpp_package_skeleton.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ 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 <[email protected]>",
"wrote the Maintainer field in DESCRIPTION")
checkEqual(gsub("\\n", " ", DESCRIPTION["Authors@R"]), # need to neutralise a line break
'person("Boo-Boo", "Bear", role = c("aut", "cre"), email = "[email protected]")',
"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",
Expand Down

0 comments on commit 1e82f18

Please sign in to comment.