Skip to content

Commit 186b7ea

Browse files
committed
Extend RcppArmadillo.package.skeleton
1 parent a9d16fa commit 186b7ea

File tree

3 files changed

+60
-26
lines changed

3 files changed

+60
-26
lines changed

ChangeLog

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
2025-02-11 Dirk Eddelbuettel <[email protected]>
2+
3+
* R/RcppArmadillo.package.skeleton.R: Generalise helper function to
4+
support additional DESCRIPTION fields
5+
* man/RcppArmadillo.package.skeleton.Rd: Document
6+
17
2025-02-05 Dirk Eddelbuettel <[email protected]>
28

39
* DESCRIPTION (Version, Date): RcppArmadillo 14.2.3-1

R/RcppArmadillo.package.skeleton.R

+28-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## RcppArmadillo.package.skeleton.R: makes a skeleton for a package that wants to use RcppArmadillo
22
##
3-
## Copyright (C) 2010 - 2021 Dirk Eddelbuettel, Romain Francois and Douglas Bates
3+
## Copyright (C) 2010 - 2025 Dirk Eddelbuettel, Romain Francois and Douglas Bates
44
##
55
## This file is part of RcppArmadillo.
66
##
@@ -17,11 +17,17 @@
1717
## You should have received a copy of the GNU General Public License
1818
## along with RcppArmadillo. If not, see <http://www.gnu.org/licenses/>.
1919

20-
RcppArmadillo.package.skeleton <- function(name="anRpackage", list=character(),
21-
environment=.GlobalEnv,
22-
path=".", force=FALSE,
23-
code_files=character(),
24-
example_code=TRUE) {
20+
RcppArmadillo.package.skeleton <- function(name = "anRpackage", list = character(),
21+
environment = .GlobalEnv,
22+
path = ".", force = FALSE,
23+
code_files = character(),
24+
example_code = TRUE,
25+
author = "Your Name",
26+
maintainer = if (missing(author)) "Your Name"
27+
else author,
28+
email = "[email protected]",
29+
githubuser = NA_character_,
30+
license = "GPL (>= 2)") {
2531

2632
env <- parent.frame(1) # #nocov start
2733

@@ -67,9 +73,24 @@ RcppArmadillo.package.skeleton <- function(name="anRpackage", list=character(),
6773
## Add Rcpp to the DESCRIPTION
6874
DESCRIPTION <- file.path(root, "DESCRIPTION")
6975
if (file.exists(DESCRIPTION)) {
76+
splitname <- strsplit(author, " ")[[1]]
7077
x <- cbind(read.dcf(DESCRIPTION),
7178
"Imports" = sprintf("Rcpp (>= %s)", packageDescription("Rcpp")[["Version"]]),
72-
"LinkingTo" = "Rcpp, RcppArmadillo")
79+
"LinkingTo" = "Rcpp, RcppArmadillo",
80+
"Authors@R" = sprintf("person(\"%s\", \"%s\", role = c(\"aut\", \"cre\"), email = \"%s\")",
81+
paste(splitname[-length(splitname)], collapse=" "),
82+
splitname[length(splitname)],
83+
email),
84+
"License" = license,
85+
"Title" = "Concise Summary of What the Package Does",
86+
"Description" = "More about what it does (maybe more than one line).",
87+
"Version" = "0.0.1")
88+
if (!is.na(githubuser)) {
89+
x <- cbind(x, matrix("", 1, 1, dimnames=list("", "URL")))
90+
x[1, "URL"] <- paste0("https://github.com/", githubuser, "/", name)
91+
x <- cbind(x, matrix("", 1, 1, dimnames=list("", "BugReports")))
92+
x[1, "BugReports"] <- paste0("https://github.com/", githubuser, "/", name, "/issues")
93+
}
7394
write.dcf(x, file=DESCRIPTION)
7495
message(" >> added Imports: Rcpp")
7596
message(" >> added LinkingTo: Rcpp, RcppArmadillo")

man/RcppArmadillo.package.skeleton.Rd

+26-19
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,19 @@
44
Create a skeleton for a new package that intends to use RcppArmadillo
55
}
66
\description{
7-
\code{RcppArmadillo.package.skeleton} automates the creation of
8-
a new source package that intends to use features of RcppArmadilo.
9-
7+
\code{RcppArmadillo.package.skeleton} automates the creation of
8+
a new source package that intends to use features of RcppArmadilo.
9+
1010
It is based on the \link[utils]{package.skeleton} function
1111
which it executes first.
1212
}
1313
\usage{
14-
RcppArmadillo.package.skeleton(name = "anRpackage", list = character(),
15-
environment = .GlobalEnv, path = ".", force = FALSE,
16-
code_files = character(), example_code = TRUE)
14+
RcppArmadillo.package.skeleton(name = "anRpackage", list = character(),
15+
environment = .GlobalEnv, path = ".", force = FALSE,
16+
code_files = character(), example_code = TRUE, author = "Your Name",
17+
maintainer = if (missing(author)) "Your Name" else author,
18+
email = "[email protected]", githubuser = NA_character_,
19+
license = "GPL (>= 2)")
1720
}
1821
\arguments{
1922
\item{name}{See \link[utils]{package.skeleton}}
@@ -23,27 +26,32 @@ RcppArmadillo.package.skeleton(name = "anRpackage", list = character(),
2326
\item{force}{See \link[utils]{package.skeleton}}
2427
\item{code_files}{See \link[utils]{package.skeleton}}
2528
\item{example_code}{If TRUE, example c++ code using RcppArmadillo is added to the package}
29+
\item{author}{Author of the package.}
30+
\item{maintainer}{Maintainer of the package.}
31+
\item{email}{Email of the package maintainer.}
32+
\item{githubuser}{GitHub username for URL and BugReports, if present.}
33+
\item{license}{License of the package.}
2634
}
2735
\details{
28-
In addition to \link[utils]{package.skeleton} :
29-
30-
The \samp{DESCRIPTION} file gains a Depends line requesting that
31-
the package depends on Rcpp and RcppArmadillo and
36+
In addition to \link[utils]{package.skeleton} :
37+
38+
The \samp{DESCRIPTION} file gains a Depends line requesting that
39+
the package depends on Rcpp and RcppArmadillo and
3240
a LinkingTo line so that the package finds Rcpp and RcppArmadillo header files.
33-
41+
3442
The \samp{NAMESPACE}, if any, gains a \code{useDynLib} directive.
35-
36-
The \samp{src} directory is created if it does not exists and
43+
44+
The \samp{src} directory is created if it does not exists and
3745
a \samp{Makevars} file is added setting the environment variable
3846
\samp{PKG_LIBS} to accomodate the necessary flags
39-
to link with the Rcpp library.
40-
41-
If the \code{example_code} argument is set to \code{TRUE},
47+
to link with the Rcpp library.
48+
49+
If the \code{example_code} argument is set to \code{TRUE},
4250
example files \samp{rcpparma_hello_world.h} and \samp{rcpparma_hello_world.cpp}
43-
are also created in the \samp{src}. An R file \samp{rcpparma_hello_world.R} is
51+
are also created in the \samp{src}. An R file \samp{rcpparma_hello_world.R} is
4452
expanded in the \samp{R} directory, the \code{rcpparma_hello_world} function
4553
defined in this files makes use of the C++ function \samp{rcpparma_hello_world}
46-
defined in the C++ file. These files are given as an example and should
54+
defined in the C++ file. These files are given as an example and should
4755
eventually by removed from the generated package.
4856
}
4957
\value{
@@ -65,4 +73,3 @@ RcppArmadillo.package.skeleton( "foobar" )
6573
}
6674
}
6775
\keyword{ programming }
68-

0 commit comments

Comments
 (0)