Skip to content

Commit cfd3a09

Browse files
set attributes to TRUE by default in Rcpp.package.skeleton, we should encourage people to use them
1 parent 2be8777 commit cfd3a09

File tree

4 files changed

+24
-6
lines changed

4 files changed

+24
-6
lines changed

ChangeLog

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
2013-09-17 JJ Allaire <jj@rstudio.org>
22

33
* R/Attributes.R: Call inlineCxxPlugin and Rcpp.plugin.maker without
4-
qualification rather than with '...'
4+
qualification rather than with ':::'
55

66
2013-09-17 Dirk Eddelbuettel <edd@debian.org>
77

R/Rcpp.package.skeleton.R

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Rcpp.package.skeleton <- function(
2222
path = ".", force = FALSE, namespace = TRUE,
2323
code_files = character(), cpp_files = character(),
2424
example_code = TRUE,
25-
attributes = FALSE,
25+
attributes = TRUE,
2626
module = FALSE,
2727
author = "Who wrote it",
2828
maintainer = if(missing( author)) "Who to complain to" else author,
@@ -32,7 +32,9 @@ Rcpp.package.skeleton <- function(
3232

3333
if (!is.character(cpp_files))
3434
stop("'cpp_files' must be a character vector")
35-
35+
# set example_code if attributes is set
36+
if( isTRUE(attributes) )
37+
example_code <- TRUE
3638
env <- parent.frame(1)
3739

3840
if( !length(list) ){
@@ -115,6 +117,20 @@ Rcpp.package.skeleton <- function(
115117
}
116118
close( ns )
117119
}
120+
121+
# update the package description help page
122+
package_help_page <- file.path( root, "man", sprintf( "%s-package.Rd" ) )
123+
if( file.exists(package_help_page) ){
124+
lines <- readLines(package_help_page)
125+
lines <- gsub( "What license is it under?", license, fixed = TRUE )
126+
lines <- gsub( "Who to complain to <yourfault@somewhere.net>",
127+
sprintf( "%s <%s>", maintainer, email),
128+
fixed = TRUE
129+
)
130+
)
131+
lines <- gsub( "Who wrote it", author, fixed = TRUE )
132+
writeLines( lines, package_help_page )
133+
}
118134

119135
# lay things out in the src directory
120136
src <- file.path( root, "src")

inst/skeleton/rcpp_hello_world.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
* It gives C calling convention to the rcpp_hello_world function so that
1010
* it can be called from .Call in R. Otherwise, the C++ compiler mangles the
11-
* name of the function and .Call can't find it.
11+
* name of the function and .Call cannot find it.
1212
*
1313
* It is only useful to use RcppExport when the function is intended to be called
1414
* by .Call. See the thread http://thread.gmane.org/gmane.comp.lang.r.rcpp/649/focus=672

man/Rcpp.package.skeleton.Rd

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Create a skeleton for a new package depending on Rcpp
1414
Rcpp.package.skeleton(name = "anRpackage", list = character(),
1515
environment = .GlobalEnv, path = ".", force = FALSE,
1616
namespace = TRUE, code_files = character(), cpp_files = character(),
17-
example_code = TRUE, attributes = FALSE, module = FALSE,
17+
example_code = TRUE, attributes = TRUE, module = FALSE,
1818
author = "Who wrote it",
1919
maintainer = if(missing( author)) "Who to complain to" else author,
2020
email = "yourfault@somewhere.net",
@@ -64,7 +64,9 @@ Rcpp.package.skeleton(name = "anRpackage", list = character(),
6464

6565
If the \code{attributes} argument is \code{TRUE}, then rather than generate
6666
the example files as described above, a single \samp{rcpp_hello_world.cpp}
67-
file is created in the \samp{src} directory and it's attributes are compiled.
67+
file is created in the \samp{src} directory and it's attributes are
68+
compiled using the \code{\link{compileAttributes}} function, so files
69+
\samp{RcppExports.R} and \samp{RcppExports.cpp} are generated as well.
6870
6971
If the \code{module} argument is \code{TRUE}, a sample Rcpp module will
7072
be generated as well.

0 commit comments

Comments
 (0)