Skip to content

Commit

Permalink
Have package.skeleton() explicitly list all exports.
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.r-project.org/R/trunk@76945 00db46b3-68df-0310-9c12-caf00c1e9a41
  • Loading branch information
hornik committed Aug 10, 2019
1 parent c89d2f9 commit 36b27d9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 11 deletions.
2 changes: 2 additions & 0 deletions doc/NEWS.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
\item \code{data.matrix()} now converts character columns to
factors and from this to integers.
\item \code{package.skeleton()} now explicitly lists all exports.
}
}
Expand Down
35 changes: 24 additions & 11 deletions src/library/utils/R/package.skeleton.R
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,17 @@ package.skeleton <-
}
usingS4 <- length(classesList) > 0L || length(methodsList) > 0L

## we need to test in the C locale
curLocale <- Sys.getlocale("LC_CTYPE")
on.exit(Sys.setlocale("LC_CTYPE", curLocale), add = TRUE)
if(Sys.setlocale("LC_CTYPE", "C") != "C")
warning("cannot turn off locale-specific chars via LC_CTYPE",
domain = NA)
## <FIXME>
## This should no longer be necessary?
## <COMMENT>
## ## we need to test in the C locale
## curLocale <- Sys.getlocale("LC_CTYPE")
## on.exit(Sys.setlocale("LC_CTYPE", curLocale), add = TRUE)
## if(Sys.setlocale("LC_CTYPE", "C") != "C")
## warning("cannot turn off locale-specific chars via LC_CTYPE",
## domain = NA)
## </COMMENT>
## </FIXME>

have <- vapply(list, exists, NA, envir = environment)
if(any(!have))
Expand Down Expand Up @@ -103,21 +108,29 @@ package.skeleton <-
"Maintainer: Who to complain to <yourfault@somewhere.net>\n",
"Description: More about what it does (maybe more than one line)\n",
"License: What license is it under?\n",
if(usingS4) "Depends: methods\n",
if(usingS4) "Imports: methods\n",
if(nzchar(encoding) && encoding != "unknown")
paste0("Encoding: ", encoding, "\n"),
file = description, sep = "")
close(description)

## NAMESPACE
## <NOTE>
## For the time being, we export all non-internal objects using the pattern
## of names beginning with alpha. All S4 methods and classes are exported.
## S3 methods will be exported if the function's name would be exported.
## For the time being, we export all non-internal objects with names
## beginning with alpha
## All S4 methods and classes are exported.
## S3 methods will be exported if the function's name would be
## exported.
## </NOTE>
message("Creating NAMESPACE ...", domain = NA)
out <- file(file.path(dir, "NAMESPACE"), "wt")
writeLines("exportPattern(\"^[[:alpha:]]+\")", out)
list0 <- list[grepl("^[[:alpha:]]", list)]
if(length(list0))
writeLines(strwrap(sprintf("export(%s)",
paste0("\"", list0, "\"",
collapse = ", ")),
exdent = 7L),
out)
if(length(methodsList)) {
cat("exportMethods(\n ", file = out)
cat(paste0('"', methodsList, '"', collapse = ",\n "), "\n)\n", file = out)
Expand Down

0 comments on commit 36b27d9

Please sign in to comment.