Autogenerate a skeleton for a new SpaDES module, a template for a
documentation file, a citation file, a license file, a README.txt
file,
and a folder that contains unit tests information.
The newModuleDocumentation
will not generate the module file, but will
create the other files.
newModule(name, path, ...)
# S4 method for character,character
newModule(name, path, ...)
# S4 method for character,missing
newModule(name, path, ...)
Character string specifying the name of the new module.
Character string. Subdirectory in which to place the new module code file. The default is the current working directory.
Additional arguments. Currently, only the following are supported:
\code{children}. Required when \code{type = "parent"}. A character vector
specifying the names of child modules.
\code{open}. Logical. Should the new module file be opened after creation?
Default \code{TRUE}.\cr\cr
\code{type}. Character string specifying one of \code{"child"} (default),
or \code{"parent"}.\cr\cr
\code{unitTests}. Logical. Should the new module include unit test files?
Default \code{TRUE}. Unit testing relies on the \pkg{testthat} package.\cr\cr
\code{useGitHub}. Logical. Is module development happening on GitHub?
Default \code{TRUE}.
Nothing is returned. The new module file is created at
path/name.R
, as well as ancillary files for documentation, citation,
LICENSE
, README
, and tests
directory.
All files will be created within a subdirectory named name
within the
path
:
path/
name/
R/ # contains additional module R scripts
data/ # directory for all included data
CHECKSUMS.txt # contains checksums for data files
tests/ # contains unit tests for module code
citation.bib # bibtex citation for the module
LICENSE.txt # describes module's legal usage
README.txt # provide overview of key aspects
name.R # module code file (incl. metadata)
name.Rmd # documentation, usage info, etc.
On Windows there is currently a bug in RStudio that prevents the editor
from opening when file.edit
is called.
Similarly, in RStudio on macOS, there is an issue opening files where they
are opened in an overlayed window rather than a new tab.
file.edit
does work if the user types it at the command prompt.
A message with the correct lines to copy and paste is provided.
Other module creation helpers:
newModuleCode()
,
newModuleDocumentation()
,
newModuleTests()
if (FALSE) {
## create a "myModule" module in the "modules" subdirectory.
newModule("myModule", "modules")
## create a new parent module in the "modules" subdirectory.
newModule("myParentModule", "modules", type = "parent", children = c("child1", "child2"))
}