Generate a skeleton for a new SpaDES module, a template for a
documentation file, a citation file, a license file, a README.md
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:
children
Required when type = "parent"
. A character vector
specifying the names of child modules.
open
Logical. Should the new module file be opened after creation?
Default TRUE
.
type
Character string specifying one of "child"
(default),
or "parent"
.
unitTests
Logical. Should the new module include unit test files?
Default TRUE
. Unit testing relies on the testthat package.
useGitHub
Logical. Is module development happening on GitHub?
Default 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 # describes module's legal usage
|_ README.md # 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 overlaid 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()
# \donttest{
tmpdir <- tempdir2("exampleNewModule")
## create a "myModule" module in the "modules" subdirectory.
newModule("myModule", tmpdir)
#> New module myModule created at /tmp/RtmpoLaiAE/reproducible/exampleNewModule
#> * edit module code in myModule.R
#> * write tests for your module code in tests/
#> * describe and document your module in myModule.Rmd
#> * tell others how to cite your module by editing citation.bib
#> * choose a license for your module; see LICENSE.md
## create a new parent module in the "modules" subdirectory.
newModule("myParentModule", tmpdir, type = "parent", children = c("child1", "child2"))
#> New module myParentModule created at /tmp/RtmpoLaiAE/reproducible/exampleNewModule
#> * edit module code in myParentModule.R
#> * write tests for your module code in tests/
#> * describe and document your module in myParentModule.Rmd
#> * tell others how to cite your module by editing citation.bib
#> * choose a license for your module; see LICENSE.md
unlink(tmpdir, recursive = TRUE)
# }