From bc808c3b9baedd90d5a888b1ff8d083730f87ac0 Mon Sep 17 00:00:00 2001 From: Federico Marini Date: Fri, 8 May 2020 15:41:04 +0200 Subject: [PATCH 01/14] backbone for handling namespace vis roxygen --- R/codetoolsBioc-pkg.R | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 R/codetoolsBioc-pkg.R diff --git a/R/codetoolsBioc-pkg.R b/R/codetoolsBioc-pkg.R new file mode 100644 index 0000000..d989143 --- /dev/null +++ b/R/codetoolsBioc-pkg.R @@ -0,0 +1,13 @@ +#' codetoolsBioc +#' +#' `codetoolsBioc` is a Bioconductor package that provides ... +#' +#' @import codetools +#' @importFrom methods findClass findFunction getClassDef getClasses +#' getFunction isClass listFromMlist slot +#' @importFrom utils find packageDescription +#' @importFrom stats setNames +#' +#' @name codetoolsBioc-pkg +#' @docType package +NULL From 5421f36a88281e91b42b35b12a623efa43b52dff Mon Sep 17 00:00:00 2001 From: Federico Marini Date: Fri, 8 May 2020 15:41:42 +0200 Subject: [PATCH 02/14] Applied Rd2roxygen on whole package --- R/findExternalDeps.R | 24 ++++++++++++++++++++++++ R/getRdFileNames.R | 25 +++++++++++++++++++++++++ R/writeNamespaceImports.R | 35 +++++++++++++++++++++++++++++++++++ R/writeRUnitRunner.R | 30 ++++++++++++++++++++++++++++++ 4 files changed, 114 insertions(+) diff --git a/R/findExternalDeps.R b/R/findExternalDeps.R index 88dedf9..4451563 100644 --- a/R/findExternalDeps.R +++ b/R/findExternalDeps.R @@ -18,6 +18,30 @@ loadRequiredPackages <- function(package) } } + + +#' Find External Dependencies of a Package +#' +#' Finds external dependencies of a package. +#' +#' The result is an approximation based upon the findings of \code{findGlobals} +#' and an exploration the package namespace. +#' +#' @param package the quoted name of the package to analyze. +#' @return A list with four components: \code{S4Classes}, \code{S4Methods}, +#' \code{functions}, and \code{variables}. Each of these components in turn +#' holds a named list of character vectors of object names from external +#' packages. +#' @author Patrick Aboyoun +#' @export +#' @seealso \code{\link[codetools]{findGlobals}}, +#' %\code{\link[codetools]{checkUsagePackage}}, Rd file not found. +#' @keywords programming +#' @examples +#' +#' library(stats4) +#' findExternalDeps("stats4") +#' findExternalDeps <- function(package) { loadRequiredPackages(package) pkgEnv <- getPackageEnvironment(package) diff --git a/R/getRdFileNames.R b/R/getRdFileNames.R index 2b586d2..b7782ca 100644 --- a/R/getRdFileNames.R +++ b/R/getRdFileNames.R @@ -1,3 +1,28 @@ +#' Track Rd file names at which 'topic' is documented +#' +#' Tracks the Rd file names at which a given 'topic' (alias) is documented. +#' +#' +#' @param topic A length-one character vector specifying the topic (alias). +#' @param package A character vector given the packages to search for Rd file +#' names that document the \code{topic} , or 'NULL'. By default, all the +#' packages in the search path are used. +#' @author Chao-Jen Wong \email{cwon2@@fhcrc.org} +#' @export +#' @keywords programming +#' @examples +#' +#' getRdFileNames("rbind") +#' +#' isInstalled <- function(pkg) +#' inherits(suppressWarnings(packageDescription(pkg)), "packageDescription") +#' +#' if (isInstalled("IRanges")) +#' getRdFileNames("rbind", package=c("base", "IRanges")) +#' +#' if (isInstalled("Biobase")) +#' getRdFileNames("ExpressionSet", "Biobase") +#' getRdFileNames <- function(topic, package=NULL) { ## Imports diff --git a/R/writeNamespaceImports.R b/R/writeNamespaceImports.R index a506ebf..17107ee 100644 --- a/R/writeNamespaceImports.R +++ b/R/writeNamespaceImports.R @@ -1,3 +1,38 @@ +#' Write NAMESPACE file imports statements +#' +#' Writes imports statements that can be included in a package's NAMESPACE +#' file. +#' +#' The result is an approximation based upon the findings of +#' \code{\link{findExternalDeps}}. S4 class dependencies are embedded into +#' importClassesFrom statements, S4 methods dependencies are embedded into +#' importMethodsFrom statements, and all other dependencies are embedded into +#' importFrom statements. +#' +#' See the document "Writing R Extensions" that is hosted on CRAN for more +#' details on the proper construction of a NAMESPACE file. +#' +#' @param package the quoted name of the package to analyze. +#' @param file either a character string naming a file or an open writing +#' connection. \code{""} indicates writing to the console. +#' @param append logical. If \code{TRUE}, the output is appended to the file. +#' If \code{FALSE}, any existing file with the specified name is destroyed and +#' a new one is created. This argument is only used if \code{file} is a +#' character string. +#' @param quote logical. If \code{TRUE}, all import fields will be +#' double-quoted. If \code{FALSE}, only non-standard names like +#' \code{[<-.fractions} will be double-quoted. +#' @param width a positive integer giving the target column for wrapping lines +#' in the output. +#' @author Patrick Aboyoun +#' @export +#' @seealso \code{\link{findExternalDeps}} +#' @keywords programming +#' @examples +#' +#' library(stats4) +#' writeNamespaceImports("stats4") +#' writeNamespaceImports <- function(package, file = "", append = TRUE, quote = FALSE, width = 0.9 * getOption("width")) diff --git a/R/writeRUnitRunner.R b/R/writeRUnitRunner.R index 6caaf03..699849f 100644 --- a/R/writeRUnitRunner.R +++ b/R/writeRUnitRunner.R @@ -1,3 +1,33 @@ +#' Write an R code file containing a .test function to run RUnit tests +#' +#' This function generates an R code file containing a single function +#' \code{.test} that can be used to run the RUnit unit tests of a package. The +#' generated \code{.test} function is customized for the specified package and +#' takes care of setting up RUnit options, configuring the location of unit +#' test files, and generating helpful summary data when tests fail. +#' +#' +#' Copy the generated file, or its contents, into your package source. You can +#' add an additional R script in pkg/tests that loads your package and then +#' calls \code{pkg:::.test()}. This will ensure that unit tests are run during +#' R CMD check and that a unit test failure will result in an ERROR report from +#' R CMD check. +#' +#' @param pkg Package name: a \code{.test} function will be generated +#' customized for the specified package name. +#' @param file Determines the file where code for the \code{.test} function +#' will be written. +#' @return Called for the side-effect of creating a file containing the +#' \code{.test} function definition customized for \code{pkg}. +#' @author Seth Falcon +#' @export +#' @examples +#' +#' tf <- tempfile() +#' writeRUnitRunner("foo", tf) +#' lines <- readLines(tf) +#' file.remove(tf) +#' writeRUnitRunner <- function(pkg, file = "runit_runner.R") { line <- paste0("BiocGenerics:::testPackage(\"", pkg, "\")") From 258421354781ab71e3259b92bb68821e2eee59da Mon Sep 17 00:00:00 2001 From: Federico Marini Date: Fri, 8 May 2020 15:42:03 +0200 Subject: [PATCH 03/14] readded man pages generated via roxygen --- man/findExternalDeps.Rd | 34 ++++++++++-------- man/getRdFileNames.Rd | 30 ++++++++-------- man/writeNamespaceImports.Rd | 68 ++++++++++++++++++++++-------------- man/writeRUnitRunner.Rd | 61 ++++++++++++++------------------ 4 files changed, 105 insertions(+), 88 deletions(-) diff --git a/man/findExternalDeps.Rd b/man/findExternalDeps.Rd index 009aab9..7b9ca52 100644 --- a/man/findExternalDeps.Rd +++ b/man/findExternalDeps.Rd @@ -1,32 +1,38 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/findExternalDeps.R \name{findExternalDeps} \alias{findExternalDeps} \title{Find External Dependencies of a Package} \usage{ -findExternalDeps(package) +findExternalDeps(package) } \arguments{ - \item{package}{the quoted name of the package to analyze.} +\item{package}{the quoted name of the package to analyze.} } \value{ - A list with four components: \code{S4Classes}, \code{S4Methods}, - \code{functions}, and \code{variables}. Each of these components in - turn holds a named list of character vectors of object names from - external packages. +A list with four components: \code{S4Classes}, \code{S4Methods}, +\code{functions}, and \code{variables}. Each of these components in turn +holds a named list of character vectors of object names from external +packages. } \description{ - Finds external dependencies of a package. +Finds external dependencies of a package. } \details{ - The result is an approximation based upon the findings of - \code{findGlobals} and an exploration the package namespace. -} -\author{Patrick Aboyoun} -\seealso{ - \code{\link[codetools]{findGlobals}}, - %\code{\link[codetools]{checkUsagePackage}}, Rd file not found. +The result is an approximation based upon the findings of \code{findGlobals} +and an exploration the package namespace. } \examples{ + library(stats4) findExternalDeps("stats4") + +} +\seealso{ +\code{\link[codetools]{findGlobals}}, +%\code{\link[codetools]{checkUsagePackage}}, Rd file not found. +} +\author{ +Patrick Aboyoun } \keyword{programming} diff --git a/man/getRdFileNames.Rd b/man/getRdFileNames.Rd index 8846136..4e751f7 100644 --- a/man/getRdFileNames.Rd +++ b/man/getRdFileNames.Rd @@ -1,24 +1,23 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/getRdFileNames.R \name{getRdFileNames} - \alias{getRdFileNames} \title{Track Rd file names at which 'topic' is documented} - -\description{ -Tracks the Rd file names at which a given 'topic' (alias) is documented.} \usage{ -getRdFileNames(topic, package=NULL) +getRdFileNames(topic, package = NULL) } - \arguments{ - \item{topic}{A length-one character vector specifying the topic (alias).} - \item{package}{A character vector given the packages to search for - Rd file names that document the \code{topic} , or 'NULL'. By - default, all the packages in the search path are used.} -} - -\author{Chao-Jen Wong \email{cwon2@fhcrc.org}} +\item{topic}{A length-one character vector specifying the topic (alias).} +\item{package}{A character vector given the packages to search for Rd file +names that document the \code{topic} , or 'NULL'. By default, all the +packages in the search path are used.} +} +\description{ +Tracks the Rd file names at which a given 'topic' (alias) is documented. +} \examples{ + getRdFileNames("rbind") isInstalled <- function(pkg) @@ -29,6 +28,9 @@ if (isInstalled("IRanges")) if (isInstalled("Biobase")) getRdFileNames("ExpressionSet", "Biobase") -} +} +\author{ +Chao-Jen Wong \email{cwon2@fhcrc.org} +} \keyword{programming} diff --git a/man/writeNamespaceImports.Rd b/man/writeNamespaceImports.Rd index 00c6f7e..26dfced 100644 --- a/man/writeNamespaceImports.Rd +++ b/man/writeNamespaceImports.Rd @@ -1,43 +1,59 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/writeNamespaceImports.R \name{writeNamespaceImports} \alias{writeNamespaceImports} \title{Write NAMESPACE file imports statements} \usage{ -writeNamespaceImports(package, file = "", append = TRUE, quote = FALSE, - width = 0.9 * getOption("width")) +writeNamespaceImports( + package, + file = "", + append = TRUE, + quote = FALSE, + width = 0.9 * getOption("width") +) } \arguments{ - \item{package}{the quoted name of the package to analyze.} - \item{file}{either a character string naming a file or an open writing - connection. \code{""} indicates writing to the console.} - \item{append}{logical. If \code{TRUE}, the output is appended to the file. - If \code{FALSE}, any existing file with the specified name is destroyed - and a new one is created. This argument is only used if \code{file} - is a character string.} - \item{quote}{logical. If \code{TRUE}, all import fields will be double-quoted. - If \code{FALSE}, only non-standard names like \code{[<-.fractions} will be - double-quoted.} - \item{width}{a positive integer giving the target column for wrapping lines - in the output.} +\item{package}{the quoted name of the package to analyze.} + +\item{file}{either a character string naming a file or an open writing +connection. \code{""} indicates writing to the console.} + +\item{append}{logical. If \code{TRUE}, the output is appended to the file. +If \code{FALSE}, any existing file with the specified name is destroyed and +a new one is created. This argument is only used if \code{file} is a +character string.} + +\item{quote}{logical. If \code{TRUE}, all import fields will be +double-quoted. If \code{FALSE}, only non-standard names like +\code{[<-.fractions} will be double-quoted.} + +\item{width}{a positive integer giving the target column for wrapping lines +in the output.} } \description{ - Writes imports statements that can be included in a package's NAMESPACE file. +Writes imports statements that can be included in a package's NAMESPACE +file. } \details{ - The result is an approximation based upon the findings of - \code{\link{findExternalDeps}}. S4 class dependencies are embedded into - importClassesFrom statements, S4 methods dependencies are embedded into - importMethodsFrom statements, and all other dependencies are embedded into - importFrom statements. +The result is an approximation based upon the findings of +\code{\link{findExternalDeps}}. S4 class dependencies are embedded into +importClassesFrom statements, S4 methods dependencies are embedded into +importMethodsFrom statements, and all other dependencies are embedded into +importFrom statements. - See the document "Writing R Extensions" that is hosted on CRAN for more - details on the proper construction of a NAMESPACE file. -} -\author{Patrick Aboyoun} -\seealso{ - \code{\link{findExternalDeps}} +See the document "Writing R Extensions" that is hosted on CRAN for more +details on the proper construction of a NAMESPACE file. } \examples{ + library(stats4) writeNamespaceImports("stats4") + +} +\seealso{ +\code{\link{findExternalDeps}} +} +\author{ +Patrick Aboyoun } \keyword{programming} diff --git a/man/writeRUnitRunner.Rd b/man/writeRUnitRunner.Rd index 863d529..da0e66c 100644 --- a/man/writeRUnitRunner.Rd +++ b/man/writeRUnitRunner.Rd @@ -1,51 +1,44 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/writeRUnitRunner.R \name{writeRUnitRunner} \alias{writeRUnitRunner} - -\title{ -Write an R code file containing a .test function to run RUnit tests -} -\description{ -This function generates an R code file containing a single function -\code{.test} that can be used to run the RUnit unit tests of a package. -The generated \code{.test} function is customized for the specified -package and takes care of setting up RUnit options, configuring the -location of unit test files, and generating helpful summary data when -tests fail. -} +\title{Write an R code file containing a .test function to run RUnit tests} \usage{ writeRUnitRunner(pkg, file = "runit_runner.R") } - \arguments{ - \item{pkg}{Package name: a \code{.test} function will be generated - customized for the specified package name. -} - \item{file}{Determines the file where - code for the \code{.test} function will be written. -} -} - -\details{ +\item{pkg}{Package name: a \code{.test} function will be generated +customized for the specified package name.} - Copy the generated file, or its contents, into your package source. - You can add an additional R script in pkg/tests that loads your - package and then calls \code{pkg:::.test()}. This will ensure that - unit tests are run during R CMD check and that a unit test failure - will result in an ERROR report from R CMD check. +\item{file}{Determines the file where code for the \code{.test} function +will be written.} } - \value{ - Called for the side-effect of creating a file containing the - \code{.test} function definition customized for \code{pkg}. +Called for the side-effect of creating a file containing the +\code{.test} function definition customized for \code{pkg}. } - -\author{ -Seth Falcon +\description{ +This function generates an R code file containing a single function +\code{.test} that can be used to run the RUnit unit tests of a package. The +generated \code{.test} function is customized for the specified package and +takes care of setting up RUnit options, configuring the location of unit +test files, and generating helpful summary data when tests fail. +} +\details{ +Copy the generated file, or its contents, into your package source. You can +add an additional R script in pkg/tests that loads your package and then +calls \code{pkg:::.test()}. This will ensure that unit tests are run during +R CMD check and that a unit test failure will result in an ERROR report from +R CMD check. } - \examples{ + tf <- tempfile() writeRUnitRunner("foo", tf) lines <- readLines(tf) file.remove(tf) + +} +\author{ +Seth Falcon } From 28a076cd4602270b94e42d9d3fb448d85ca0a3fd Mon Sep 17 00:00:00 2001 From: Federico Marini Date: Fri, 8 May 2020 15:42:31 +0200 Subject: [PATCH 04/14] roxygen handling dependencies and imports --- DESCRIPTION | 4 +++- NAMESPACE | 25 +++++++++++++++++-------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 44d9412..5231b1e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -8,7 +8,9 @@ Authors@R: c( person("Henrik", "Bengtsson", role="ctb"), person("Bioconductor Package Maintainer", role="cre", email="maintainer@bioconductor.org")) Depends: R (>= 2.1) -Imports: codetools, methods, utils +Imports: codetools, methods, utils, stats Suggests: stats4, Matrix, aroma.core License: Artistic-2.0 +Encoding: UTF-8 biocViews: Infrastructure +RoxygenNote: 7.1.0 diff --git a/NAMESPACE b/NAMESPACE index 17903dc..492c504 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,9 +1,18 @@ -import(codetools) - -importFrom("methods", findClass, findFunction, getClassDef, getClasses, - getFunction, isClass, listFromMlist, slot) +# Generated by roxygen2: do not edit by hand -importFrom("utils", find, packageDescription) - -export(findExternalDeps, writeNamespaceImports, getRdFileNames, - writeRUnitRunner) +export(findExternalDeps) +export(getRdFileNames) +export(writeNamespaceImports) +export(writeRUnitRunner) +import(codetools) +importFrom(methods,findClass) +importFrom(methods,findFunction) +importFrom(methods,getClassDef) +importFrom(methods,getClasses) +importFrom(methods,getFunction) +importFrom(methods,isClass) +importFrom(methods,listFromMlist) +importFrom(methods,slot) +importFrom(stats,setNames) +importFrom(utils,find) +importFrom(utils,packageDescription) From 186605323fc49e77102fe191aad505677f40f40e Mon Sep 17 00:00:00 2001 From: Federico Marini Date: Fri, 8 May 2020 15:42:45 +0200 Subject: [PATCH 05/14] added man page for pkg itself --- man/codetoolsBioc-pkg.Rd | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 man/codetoolsBioc-pkg.Rd diff --git a/man/codetoolsBioc-pkg.Rd b/man/codetoolsBioc-pkg.Rd new file mode 100644 index 0000000..e41add9 --- /dev/null +++ b/man/codetoolsBioc-pkg.Rd @@ -0,0 +1,9 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/codetoolsBioc-pkg.R +\docType{package} +\name{codetoolsBioc-pkg} +\alias{codetoolsBioc-pkg} +\title{codetoolsBioc} +\description{ +`codetoolsBioc` is a Bioconductor package that provides ... +} From 0b071b5464c3ea3e2f17bb32314a805bd32f7e03 Mon Sep 17 00:00:00 2001 From: Federico Marini Date: Fri, 8 May 2020 15:43:09 +0200 Subject: [PATCH 06/14] using Rproj from RStudio --- .Rbuildignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.Rbuildignore b/.Rbuildignore index 0bf55fd..ef4edaf 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -1 +1,3 @@ TODO.org +^.*\.Rproj$ +^\.Rproj\.user$ From 97daa0c192fd67d670cf342203eddffa72f7483a Mon Sep 17 00:00:00 2001 From: Federico Marini Date: Fri, 8 May 2020 15:50:56 +0200 Subject: [PATCH 07/14] Added minimal README.md --- .Rbuildignore | 1 + README.md | 10 ++++++++++ 2 files changed, 11 insertions(+) create mode 100644 README.md diff --git a/.Rbuildignore b/.Rbuildignore index ef4edaf..dcf1d51 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -1,3 +1,4 @@ TODO.org ^.*\.Rproj$ ^\.Rproj\.user$ +README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..f1407b6 --- /dev/null +++ b/README.md @@ -0,0 +1,10 @@ +# codetoolsBioC + +The goal of `codetoolsBioc` is... + +## Installation + +``` +remotes::install_github("Bioconductor/codetoolsBioc") +remotes::install_github("federicomarini/codetoolsBioc") # for the current fork... +``` From fab0e3d7bdc1f3758ad4849940c66df5168c7840 Mon Sep 17 00:00:00 2001 From: Federico Marini Date: Fri, 8 May 2020 15:59:27 +0200 Subject: [PATCH 08/14] Version number updated, conform to Bioc --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 5231b1e..32ca550 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: codetoolsBioC Title: Bioconductor Extensions for R Code Analysis Tools Description: Bioconductor extensions for R code analysis tools. -Version: 0.1-0 +Version: 0.99.0 Authors@R: c( person("Patrick", "Aboyoun", role="aut"), person("Martin", "Maechler", role="aut"), From 718b01c7781ff18540e1b01b6eae5615089f6007 Mon Sep 17 00:00:00 2001 From: Federico Marini Date: Fri, 8 May 2020 15:59:35 +0200 Subject: [PATCH 09/14] added NEWS in md format --- NEWS.md | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 NEWS.md diff --git a/NEWS.md b/NEWS.md new file mode 100644 index 0000000..e8c4d34 --- /dev/null +++ b/NEWS.md @@ -0,0 +1,4 @@ +# codetoolsBioC 0.99.0 + +* Added a `NEWS.md` file to track changes to the package. +* Started the process to make this a fully fledged Bioc package From 893a0d8cd69921d54d7d1c747b30b13d122f92db Mon Sep 17 00:00:00 2001 From: Federico Marini Date: Fri, 8 May 2020 16:01:13 +0200 Subject: [PATCH 10/14] replaced tab with 4 spaces --- R/getNamespaceFileImports.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/getNamespaceFileImports.R b/R/getNamespaceFileImports.R index edc389a..fcf3831 100644 --- a/R/getNamespaceFileImports.R +++ b/R/getNamespaceFileImports.R @@ -21,7 +21,7 @@ getNamespaceFileImports <- function(package, lib.loc = .libPaths()) { } else { fgen <- fileContents[["general"]] nms.fgen <- names(fgen) - X <- setNames(seq_along(fgen), nms.fgen) + X <- setNames(seq_along(fgen), nms.fgen) funsAndVars <- lapply(X, function(i) { x.i <- fgen[[i]] isFunction <- vapply(x.i, function(y) From fbbd62c729478bd08d1fb1902f1cace84f4f3ebe Mon Sep 17 00:00:00 2001 From: Federico Marini Date: Tue, 19 May 2020 11:16:51 +0200 Subject: [PATCH 11/14] fixing the wording in the package documentation --- R/findExternalDeps.R | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/R/findExternalDeps.R b/R/findExternalDeps.R index 4451563..16be98e 100644 --- a/R/findExternalDeps.R +++ b/R/findExternalDeps.R @@ -25,7 +25,7 @@ loadRequiredPackages <- function(package) #' Finds external dependencies of a package. #' #' The result is an approximation based upon the findings of \code{findGlobals} -#' and an exploration the package namespace. +#' and an exploration of the package namespace. #' #' @param package the quoted name of the package to analyze. #' @return A list with four components: \code{S4Classes}, \code{S4Methods}, @@ -41,7 +41,6 @@ loadRequiredPackages <- function(package) #' #' library(stats4) #' findExternalDeps("stats4") -#' findExternalDeps <- function(package) { loadRequiredPackages(package) pkgEnv <- getPackageEnvironment(package) From 345ae1d22e01baf7b72e76010b5afb2d47f63345 Mon Sep 17 00:00:00 2001 From: Federico Marini Date: Tue, 19 May 2020 11:17:16 +0200 Subject: [PATCH 12/14] Quick fix for the parenthesis indentation --- R/getRdFileNames.R | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/R/getRdFileNames.R b/R/getRdFileNames.R index b7782ca..9d70b0a 100644 --- a/R/getRdFileNames.R +++ b/R/getRdFileNames.R @@ -2,7 +2,6 @@ #' #' Tracks the Rd file names at which a given 'topic' (alias) is documented. #' -#' #' @param topic A length-one character vector specifying the topic (alias). #' @param package A character vector given the packages to search for Rd file #' names that document the \code{topic} , or 'NULL'. By default, all the @@ -51,5 +50,4 @@ getRdFileNames <- function(topic, package=NULL) paths <- unlist(paths) data.frame(packages=basename(names(paths)), Rd.file=basename(paths)) - } - +} From 4d28943868d507c2c1050ec2f37143077445720a Mon Sep 17 00:00:00 2001 From: Federico Marini Date: Tue, 19 May 2020 11:17:53 +0200 Subject: [PATCH 13/14] Indent fixes; plus, uniform structure of function definitions --- R/utility-functions.R | 4 +--- R/writeNamespaceImports.R | 14 ++++++-------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/R/utility-functions.R b/R/utility-functions.R index d936fb2..7e18421 100644 --- a/R/utility-functions.R +++ b/R/utility-functions.R @@ -11,11 +11,9 @@ getPackageEnvironment <- function(package) { ## common idioms ulapply <- function(...) unlist(lapply(...)) -suniquec <- - function(X, Y, what) +suniquec <- function(X, Y, what) { ## optionally subset Y by elements named 'what', then make unique ## set with X -{ if (!missing(what)) Y <- ulapply(Y, "[[", what) sort(unique(c(X, Y))) diff --git a/R/writeNamespaceImports.R b/R/writeNamespaceImports.R index 17107ee..49e6a7a 100644 --- a/R/writeNamespaceImports.R +++ b/R/writeNamespaceImports.R @@ -33,15 +33,13 @@ #' library(stats4) #' writeNamespaceImports("stats4") #' -writeNamespaceImports <- - function(package, file = "", append = TRUE, quote = FALSE, - width = 0.9 * getOption("width")) -{ +writeNamespaceImports <- function(package, file = "", append = TRUE, quote = FALSE, + width = 0.9 * getOption("width")) { writeImports <- function(x, prefix, file, width) { Rkeywords <- - c("NULL", "NA", "TRUE", "FALSE", "Inf", "NaN", "NA_integer_", - "NA_real_", "NA_character_", "NA_complex_", "function", "while", - "repeat", "for", "if", "in", "else", "next", "break", "...") + c("NULL", "NA", "TRUE", "FALSE", "Inf", "NaN", "NA_integer_", + "NA_real_", "NA_character_", "NA_complex_", "function", "while", + "repeat", "for", "if", "in", "else", "next", "break", "...") for (i in which(!(names(x) %in% ignoredPackages))) { if (quote) { qstring1 <- "\"" @@ -72,7 +70,7 @@ writeNamespaceImports <- } if (!inherits(file, "connection")) stop("'file' must be a character string or connection") - + allDeps <- findExternalDeps(package) allDepNames <- sort(unique(ulapply(allDeps, names))) allDepNames <- allDepNames[!(allDepNames %in% ignoredPackages)] From 2826c640e2375945ef5d669ee2026294e6c9773a Mon Sep 17 00:00:00 2001 From: Federico Marini Date: Tue, 19 May 2020 11:22:31 +0200 Subject: [PATCH 14/14] Reoxygenated man pages --- man/findExternalDeps.Rd | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/man/findExternalDeps.Rd b/man/findExternalDeps.Rd index 7b9ca52..8c3a9a5 100644 --- a/man/findExternalDeps.Rd +++ b/man/findExternalDeps.Rd @@ -20,13 +20,12 @@ Finds external dependencies of a package. } \details{ The result is an approximation based upon the findings of \code{findGlobals} -and an exploration the package namespace. +and an exploration of the package namespace. } \examples{ library(stats4) findExternalDeps("stats4") - } \seealso{ \code{\link[codetools]{findGlobals}},