Skip to content

Commit 1e82f18

Browse files
authored
Support Authors@R in Rcpp.package.skeleton() (#1325)
* Support Authors@R via Rcpp.package.skeleton() * No raw strings in old R versions
1 parent 9db1de4 commit 1e82f18

File tree

3 files changed

+25
-11
lines changed

3 files changed

+25
-11
lines changed

ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2024-08-28 Dirk Eddelbuettel <[email protected]>
2+
3+
* R/Rcpp.package.skeleton.R: Create DESCRIPTION with Auhors@R fiel
4+
* inst/tinytest/test_rcpp_package_skeleton.R: Adjust tests
5+
16
2024-08-20 Dirk Eddelbuettel <[email protected]>
27

38
* inst/tinytest/test_sugar.R: Skip one more NA related test on arm64

R/Rcpp.package.skeleton.R

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,18 +81,27 @@ Rcpp.package.skeleton <- function(name = "anRpackage", list = character(),
8181
DESCRIPTION <- file.path(root, "DESCRIPTION")
8282
if (file.exists(DESCRIPTION)) {
8383
imports <- c(if (isTRUE(module)) "methods", sprintf("Rcpp (>= %s)", getRcppVersion()))
84-
x <- cbind(read.dcf(DESCRIPTION),
84+
splitname <- strsplit(author, " ")[[1]]
85+
x <- cbind(read.dcf(DESCRIPTION, fields = c("Package", "Type", "Title", "Version", "Date",
86+
"Description", "License")),
8587
"Imports" = paste(imports, collapse = ", "),
86-
"LinkingTo" = "Rcpp")
87-
x[, "Author"] <- author
88-
x[, "Maintainer"] <- sprintf("%s <%s>", maintainer, email)
88+
"LinkingTo" = "Rcpp",
89+
"Authors@R" = sprintf("person(\"%s\", \"%s\", role = c(\"aut\", \"cre\"), email = \"%s\")",
90+
paste(splitname[-length(splitname)], collapse=" "),
91+
splitname[length(splitname)],
92+
email))
93+
#x[, "Author"] <- author
94+
#x[, "Maintainer"] <- sprintf("%s <%s>", maintainer, email)
8995
x[, "License"] <- license
90-
x[, "Title"] <- "What the Package Does in One 'Title Case' Line"
91-
x[, "Description"] <- "One paragraph description of what the package does as one or more full sentences."
96+
x[, "Title"] <- "Concise Summary of What the Package Does"
97+
x[, "Description"] <- "More about what it does (maybe more than one line)."
9298
message( " >> added Imports: Rcpp" )
9399
message( " >> added LinkingTo: Rcpp" )
94100
write.dcf(x, file = DESCRIPTION)
95-
101+
write.dcf(x[1, c("Package", "Type", "Title", "Version", "Date",
102+
"Authors@R", "Description", "License", "Imports", "LinkingTo"),
103+
drop = FALSE],
104+
file = DESCRIPTION)
96105
}
97106

98107
## add useDynLib and importFrom to NAMESPACE

inst/tinytest/test_rcpp_package_skeleton.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ checkTrue( "foo" %in% list.files(path), "pkg path generated as named" )
4545

4646
## check the DESCRIPTION
4747
DESCRIPTION <- as.list( read.dcf( file.path(pkg_path, "DESCRIPTION") )[1,] )
48-
checkTrue( DESCRIPTION["Author"] == "Boo-Boo Bear",
49-
"wrote the Author field in DESCRIPTION" )
50-
checkTrue( DESCRIPTION["Maintainer"] == "Yogi Bear <[email protected]>",
51-
"wrote the Maintainer field in DESCRIPTION")
48+
checkEqual(gsub("\\n", " ", DESCRIPTION["Authors@R"]), # need to neutralise a line break
49+
'person("Boo-Boo", "Bear", role = c("aut", "cre"), email = "[email protected]")',
50+
"wrote the Authors@R field in DESCRIPTION" )
51+
checkTrue( DESCRIPTION["Date"] == format(Sys.Date()), "uses current date in DESCRIPTION")
5252
checkTrue( DESCRIPTION["License"] == "An Opensource License",
5353
"wrote the License field in DESCRIPTION" )
5454
checkTrue( DESCRIPTION["LinkingTo"] == "Rcpp",

0 commit comments

Comments
 (0)