Skip to content

Commit 47df44a

Browse files
committed
update Rcpp.package.skeleton()
DESCRIPTION now passes R CMD check in R-devel and R-release
1 parent b58bf98 commit 47df44a

File tree

3 files changed

+123
-112
lines changed

3 files changed

+123
-112
lines changed

ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2016-05-10 Dirk Eddelbuettel <[email protected]>
2+
3+
* R/Rcpp.package.skeleton.R: Also correct Title: and Description: to
4+
satisfy R CMD check in R-release and (current) R-devel
5+
16
2016-05-08 Dirk Eddelbuettel <[email protected]>
27

38
* inst/unitTests/cpp/Matrix.cpp: Made four scalar/matrix tests less

R/Rcpp.package.skeleton.R

Lines changed: 112 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
# -*- tab-width: 4; -*-
2-
3-
# Copyright (C) 2009 - 2015 Dirk Eddelbuettel and Romain Francois
1+
# Copyright (C) 2009 - 2016 Dirk Eddelbuettel and Romain Francois
42
#
53
# This file is part of Rcpp.
64
#
@@ -34,70 +32,72 @@ Rcpp.package.skeleton <- function(name = "anRpackage", list = character(),
3432
call[[1]] <- as.name("package.skeleton")
3533
env <- parent.frame(1)
3634

37-
if (!is.character(cpp_files))
38-
stop("'cpp_files' must be a character vector")
35+
if (!is.character(cpp_files))
36+
stop("'cpp_files' must be a character vector")
3937

40-
if (!length(list)) {
41-
fake <- TRUE
42-
assign("Rcpp.fake.fun", function() {}, envir = env)
43-
if (example_code && !isTRUE(attributes)) {
44-
assign("rcpp_hello_world", function() {}, envir = env)
45-
remove_hello_world <- TRUE
46-
} else {
38+
if (!length(list)) {
39+
fake <- TRUE
40+
assign("Rcpp.fake.fun", function() {}, envir = env)
41+
if (example_code && !isTRUE(attributes)) {
42+
assign("rcpp_hello_world", function() {}, envir = env)
43+
remove_hello_world <- TRUE
44+
} else {
4745
remove_hello_world <- FALSE
48-
}
49-
} else {
46+
}
47+
} else {
5048
if (example_code && !isTRUE(attributes)) {
5149
if (!"rcpp_hello_world" %in% list) {
5250
assign( "rcpp_hello_world", function() {}, envir = env)
5351
call[["list"]] <- as.call(c(as.name("c"),
5452
as.list(c("rcpp_hello_world", list))))
5553
}
56-
remove_hello_world <- TRUE
57-
} else {
58-
remove_hello_world <- FALSE
59-
}
60-
fake <- FALSE
61-
}
54+
remove_hello_world <- TRUE
55+
} else {
56+
remove_hello_world <- FALSE
57+
}
58+
fake <- FALSE
59+
}
6260

6361
## first let the traditional version do its business
64-
## remove Rcpp specific arguments
62+
## remove Rcpp specific arguments
6563

66-
call <- call[ c(1L, which(names(call) %in% names(formals(package.skeleton)))) ]
64+
call <- call[ c(1L, which(names(call) %in% names(formals(package.skeleton)))) ]
6765

68-
if (fake) {
69-
call[["list"]] <- c(if(isTRUE(example_code)
66+
if (fake) {
67+
call[["list"]] <- c(if(isTRUE(example_code)
7068
&& !isTRUE(attributes)) "rcpp_hello_world", "Rcpp.fake.fun")
71-
}
69+
}
7270

73-
tryCatch(eval(call, envir = env), error = function(e){
74-
stop(sprintf("error while calling `package.skeleton` : %s", conditionMessage(e)))
75-
})
71+
tryCatch(eval(call, envir = env), error = function(e){
72+
stop(sprintf("error while calling `package.skeleton` : %s", conditionMessage(e)))
73+
})
7674

77-
message("\nAdding Rcpp settings")
75+
message("\nAdding Rcpp settings")
7876

79-
## now pick things up
80-
root <- file.path(path, name)
77+
## now pick things up
78+
root <- file.path(path, name)
8179

82-
# Add Rcpp to the DESCRIPTION
83-
DESCRIPTION <- file.path(root, "DESCRIPTION")
84-
if (file.exists(DESCRIPTION)) {
85-
imports <- c(if (isTRUE(module)) "methods",
80+
# Add Rcpp to the DESCRIPTION
81+
DESCRIPTION <- file.path(root, "DESCRIPTION")
82+
if (file.exists(DESCRIPTION)) {
83+
imports <- c(if (isTRUE(module)) "methods",
8684
sprintf("Rcpp (>= %s)", packageDescription("Rcpp")[["Version"]]))
87-
x <- cbind(read.dcf(DESCRIPTION),
85+
x <- cbind(read.dcf(DESCRIPTION),
8886
"Imports" = paste(imports, collapse = ", "),
8987
"LinkingTo" = "Rcpp")
90-
x[, "Author"] <- author
91-
x[, "Maintainer"] <- sprintf("%s <%s>", maintainer, email)
92-
x[, "License"] <- license
93-
message( " >> added Imports: Rcpp" )
94-
message( " >> added LinkingTo: Rcpp" )
95-
write.dcf(x, file = DESCRIPTION)
88+
x[, "Author"] <- author
89+
x[, "Maintainer"] <- sprintf("%s <%s>", maintainer, email)
90+
x[, "License"] <- license
91+
x[, "Title"] <- "What the Package Does in One 'Title Case' Line"
92+
x[, "Description"] <- "One paragraph description of what the package does as one or more full sentences."
93+
message( " >> added Imports: Rcpp" )
94+
message( " >> added LinkingTo: Rcpp" )
95+
write.dcf(x, file = DESCRIPTION)
9696

97-
}
97+
}
9898

99-
## add useDynLib and importFrom to NAMESPACE
100-
NAMESPACE <- file.path(root, "NAMESPACE")
99+
## add useDynLib and importFrom to NAMESPACE
100+
NAMESPACE <- file.path(root, "NAMESPACE")
101101
lines <- readLines(NAMESPACE)
102102
ns <- file(NAMESPACE, open="w")
103103
if (! grepl("useDynLib", lines)) {
@@ -114,7 +114,7 @@ Rcpp.package.skeleton <- function(name = "anRpackage", list = character(),
114114
}
115115
close( ns )
116116

117-
## update the package description help page
117+
## update the package description help page
118118
if (havePkgKitten) { # if pkgKitten is available, use it
119119
pkgKitten::playWithPerPackageHelpPage(name, path, maintainer, email)
120120
} else {
@@ -130,82 +130,82 @@ Rcpp.package.skeleton <- function(name = "anRpackage", list = character(),
130130
}
131131
}
132132

133-
## lay things out in the src directory
134-
src <- file.path(root, "src")
135-
if (!file.exists(src)) {
136-
dir.create(src)
137-
}
138-
skeleton <- system.file("skeleton", package = "Rcpp")
139-
140-
if (length(cpp_files) > 0L) {
141-
for (file in cpp_files) {
142-
file.copy(file, src)
143-
message(" >> copied ", file, " to src directory" )
144-
}
145-
compileAttributes(root)
146-
}
147-
148-
if (example_code) {
149-
if (isTRUE(attributes)) {
150-
file.copy(file.path( skeleton, "rcpp_hello_world_attributes.cpp"),
133+
## lay things out in the src directory
134+
src <- file.path(root, "src")
135+
if (!file.exists(src)) {
136+
dir.create(src)
137+
}
138+
skeleton <- system.file("skeleton", package = "Rcpp")
139+
140+
if (length(cpp_files) > 0L) {
141+
for (file in cpp_files) {
142+
file.copy(file, src)
143+
message(" >> copied ", file, " to src directory" )
144+
}
145+
compileAttributes(root)
146+
}
147+
148+
if (example_code) {
149+
if (isTRUE(attributes)) {
150+
file.copy(file.path( skeleton, "rcpp_hello_world_attributes.cpp"),
151151
file.path( src, "rcpp_hello_world.cpp"))
152-
message(" >> added example src file using Rcpp attributes")
153-
compileAttributes(root)
154-
message(" >> compiled Rcpp attributes")
155-
} else {
156-
header <- readLines(file.path(skeleton, "rcpp_hello_world.h"))
157-
header <- gsub("@PKG@", name, header, fixed = TRUE)
158-
writeLines(header , file.path(src, "rcpp_hello_world.h"))
159-
message(" >> added example header file using Rcpp classes")
160-
161-
file.copy(file.path(skeleton, "rcpp_hello_world.cpp"), src)
162-
message(" >> added example src file using Rcpp classes")
163-
164-
rcode <- readLines(file.path( skeleton, "rcpp_hello_world.R"))
165-
rcode <- gsub("@PKG@", name, rcode, fixed = TRUE)
166-
writeLines( rcode , file.path( root, "R", "rcpp_hello_world.R"))
167-
message(" >> added example R file calling the C++ example")
168-
}
169-
170-
hello.Rd <- file.path(root, "man", "rcpp_hello_world.Rd")
171-
unlink(hello.Rd)
172-
file.copy(system.file("skeleton", "rcpp_hello_world.Rd", package = "Rcpp"), hello.Rd)
173-
message( " >> added Rd file for rcpp_hello_world")
174-
}
175-
176-
if (isTRUE(module)) {
177-
file.copy(system.file("skeleton", "rcpp_module.cpp", package="Rcpp"),
152+
message(" >> added example src file using Rcpp attributes")
153+
compileAttributes(root)
154+
message(" >> compiled Rcpp attributes")
155+
} else {
156+
header <- readLines(file.path(skeleton, "rcpp_hello_world.h"))
157+
header <- gsub("@PKG@", name, header, fixed = TRUE)
158+
writeLines(header , file.path(src, "rcpp_hello_world.h"))
159+
message(" >> added example header file using Rcpp classes")
160+
161+
file.copy(file.path(skeleton, "rcpp_hello_world.cpp"), src)
162+
message(" >> added example src file using Rcpp classes")
163+
164+
rcode <- readLines(file.path( skeleton, "rcpp_hello_world.R"))
165+
rcode <- gsub("@PKG@", name, rcode, fixed = TRUE)
166+
writeLines( rcode , file.path( root, "R", "rcpp_hello_world.R"))
167+
message(" >> added example R file calling the C++ example")
168+
}
169+
170+
hello.Rd <- file.path(root, "man", "rcpp_hello_world.Rd")
171+
unlink(hello.Rd)
172+
file.copy(system.file("skeleton", "rcpp_hello_world.Rd", package = "Rcpp"), hello.Rd)
173+
message( " >> added Rd file for rcpp_hello_world")
174+
}
175+
176+
if (isTRUE(module)) {
177+
file.copy(system.file("skeleton", "rcpp_module.cpp", package="Rcpp"),
178178
file.path(root, "src"))
179-
file.copy(system.file("skeleton", "Num.cpp", package="Rcpp"),
179+
file.copy(system.file("skeleton", "Num.cpp", package="Rcpp"),
180180
file.path(root, "src"))
181-
file.copy(system.file("skeleton", "stdVector.cpp", package="Rcpp"),
181+
file.copy(system.file("skeleton", "stdVector.cpp", package="Rcpp"),
182182
file.path(root, "src"))
183-
file.copy(system.file("skeleton", "zzz.R", package ="Rcpp"),
183+
file.copy(system.file("skeleton", "zzz.R", package ="Rcpp"),
184184
file.path(root, "R"))
185-
file.copy(system.file("skeleton", "Rcpp_modules_examples.Rd", package ="Rcpp"),
185+
file.copy(system.file("skeleton", "Rcpp_modules_examples.Rd", package ="Rcpp"),
186186
file.path(root, "man"))
187-
message(" >> copied the example module file ")
188-
}
187+
message(" >> copied the example module file ")
188+
}
189189

190-
lines <- readLines(package.doc <- file.path( root, "man", sprintf("%s-package.Rd", name)))
191-
lines <- sub("~~ simple examples", "%% ~~ simple examples", lines)
190+
lines <- readLines(package.doc <- file.path( root, "man", sprintf("%s-package.Rd", name)))
191+
lines <- sub("~~ simple examples", "%% ~~ simple examples", lines)
192192

193-
lines <- lines[! grepl("~~ package title", lines)]
194-
lines <- lines[! grepl("~~ The author and", lines)]
195-
lines <- sub("Who wrote it", author, lines )
196-
lines <- sub("Who to complain to.*", sprintf("%s <%s>", maintainer, email), lines)
193+
lines <- lines[! grepl("~~ package title", lines)]
194+
lines <- lines[! grepl("~~ The author and", lines)]
195+
lines <- sub("Who wrote it", author, lines )
196+
lines <- sub("Who to complain to.*", sprintf("%s <%s>", maintainer, email), lines)
197197

198-
writeLines(lines, package.doc)
198+
writeLines(lines, package.doc)
199199

200-
if (fake) {
201-
rm("Rcpp.fake.fun", envir = env)
202-
unlink(file.path(root, "R" , "Rcpp.fake.fun.R"))
203-
unlink(file.path(root, "man", "Rcpp.fake.fun.Rd"))
204-
}
200+
if (fake) {
201+
rm("Rcpp.fake.fun", envir = env)
202+
unlink(file.path(root, "R" , "Rcpp.fake.fun.R"))
203+
unlink(file.path(root, "man", "Rcpp.fake.fun.Rd"))
204+
}
205205

206-
if (isTRUE(remove_hello_world)) {
207-
rm("rcpp_hello_world", envir = env)
208-
}
206+
if (isTRUE(remove_hello_world)) {
207+
rm("rcpp_hello_world", envir = env)
208+
}
209209

210-
invisible(NULL)
210+
invisible(NULL)
211211
}

inst/NEWS.Rd

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@
2323
\item The (older) \code{loadRcppModules()} is now deprecated in favour of
2424
\code{loadModule()} introduced around R 2.15.1 and Rcpp 0.9.11.
2525
}
26+
\item Changes in Rcpp support functions:
27+
\itemize{
28+
\item The \code{Rcpp.package.skeleton()} function was once again updated
29+
in order to create a \code{DESCRIPTION} file which passes
30+
\code{R CMD check} without warnings under R-release and R-devel.
31+
}
2632
}
2733
}
2834

0 commit comments

Comments
 (0)