add_shiny_module: Add shiny module file

Description Usage Arguments Details Value See Also Examples

View source: R/utils_dev.R

Description

Create source/test file for a shiny module by template file in templates directory of the packages.

Usage

1
2
3
4
5
6
7
8
9
add_shiny_module(
  name,
  type = c("source", "test"),
  source_template = "mod_template.R",
  test_template = "test-mod_template.R",
  ignore = FALSE,
  open = TRUE,
  package = pkgload::pkg_name()
)

Arguments

name

A character of module name, i.g. "abc".

type

A character of type of target file to produce:

  • source: produce module source file as "mod_abc.R".

  • test: produce module test file as "test-mod_abc.R".

source_template

A character of R source template, default is "mod_template.R".

test_template

A character of R source template, default is "test-mod_template.R".

ignore

A logical to indicate whether the produced file to be ignored by git.

open

A logical to indicate whether open the produced file.

package

A character of package which contains templates files. Default is current package returned by pkgload::pkg_name().

Details

This function is a wrapper of usethis::use_template() to use shiny module template.

It produces source file in "R" directory and test file in "tests/testthat" directory. If target file existed, it would not overwrite it and return FALSE.

Value

A logical vector indicating if file was modified.

See Also

Other utils_dev: add_analysis_module(), debug_mode, save_debug_data()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
## Not run: 

# Create source file for module of "xyz"
add_shiny_module("xyz")

# Try integration test of module
xyz_app()

# Create test file for module of "xyz"
add_shiny_module("xyz", type = "test")

# Make sure tests of module is OK
testthat::test_file("tests/testthat/test-mod_xyz.R")

## End(Not run)

chriszheng2016/zstexplorer documentation built on June 13, 2021, 9:47 a.m.