Skip to content

Commit

Permalink
proof read doc (#642)
Browse files Browse the repository at this point in the history
  • Loading branch information
ColinFay authored Apr 14, 2021
1 parent 478a4c2 commit 173dde4
Show file tree
Hide file tree
Showing 69 changed files with 522 additions and 343 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@
^doc$
^Meta$
^\.github$
^revdep$
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ inst/rstudio/.DS_Store
.RData
doc
Meta
revdep/
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,4 @@ VignetteBuilder:
Encoding: UTF-8
Language: en-US
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.1.1.9000
RoxygenNote: 7.1.1
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ importFrom(pkgload,pkg_path)
importFrom(remotes,dev_package_deps)
importFrom(remotes,package_deps)
importFrom(rlang,enquo)
importFrom(rlang,is_missing)
importFrom(roxygen2,roxygenise)
importFrom(rstudioapi,getActiveProject)
importFrom(rstudioapi,getSourceEditorContext)
importFrom(rstudioapi,isAvailable)
importFrom(rstudioapi,modifyRange)
Expand Down
60 changes: 25 additions & 35 deletions R/add_dockerfiles.R
Original file line number Diff line number Diff line change
@@ -1,33 +1,40 @@
#' Create a Dockerfile for Shiny App
#' Create a Dockerfile for your App
#'
#' Build a container containing your Shiny App. `add_dockerfile()` creates
#' a "classical" Dockerfile, while `add_dockerfile_shinyproxy()` and
#' a generic Dockerfile, while `add_dockerfile_shinyproxy()` and
#' `add_dockerfile_heroku()` creates platform specific Dockerfile.
#'
#' @inheritParams add_module
#' @inheritParams add_module
#'
#' @param path path to the DESCRIPTION file to use as an input.
#' @param output name of the Dockerfile output.
#' @param from The FROM of the Dockerfile. Default is FROM rocker/r-ver:
#' with `R.Version()$major` and `R.Version()$minor`.
#' @param from The FROM of the Dockerfile. Default is
#' FROM rocker/r-ver:`R.Version()$major`.`R.Version()$minor`.
#' @param as The AS of the Dockerfile. Default it NULL.
#' @param port The `options('shiny.port')` on which to run the Shiny App.
#' @param port The `options('shiny.port')` on which to run the App.
#' Default is 80.
#' @param host The `options('shiny.host')` on which to run the Shiny App.
#' @param host The `options('shiny.host')` on which to run the App.
#' Default is 0.0.0.0.
#' @param sysreqs boolean to check the system requirements
#' @param repos character vector, the base URL of the repositories
#' @param expand boolean, if `TRUE` each system requirement will be known his own RUN line
#' @param open boolean, default is `TRUE` open the Dockerfile file
#' @param build_golem_from_source boolean, if `TRUE` no tar.gz Package is created and the Dockerfile directly mount the source folder to build it
#' @param update_tar_gz boolean, if `TRUE` and build_golem_from_source is also `TRUE` an updated tar.gz Package is created
#' @param extra_sysreqs extra debian system requirements as character vector. Will be installed with apt-get install
#' @param sysreqs boolean. If TRUE, the Dockerfile will contain sysreq installation.
#' @param repos character. The URL(s) of the repositories to use for `options("repos")`.
#' @param expand boolean. If `TRUE` each system requirement will have its own `RUN` line.
#' @param open boolean. Should the Dockerfile be open after creation? Default is `TRUE`.
#' @param build_golem_from_source boolean. If `TRUE` no tar.gz is created and
#' the Dockerfile directly mount the source folder.
#' @param update_tar_gz boolean. If `TRUE` and `build_golem_from_source` is also `TRUE`,
#' an updated tar.gz is created.
#' @param extra_sysreqs character vector. Extra debian system requirements.
#' Will be installed with apt-get install.
#'
#' @export
#' @rdname dockerfiles
#'
#' @importFrom usethis use_build_ignore
#' @importFrom desc desc_get_deps
#' @importFrom dockerfiler Dockerfile
#' @importFrom rstudioapi navigateToFile isAvailable
#' @importFrom fs path path_file
#'
#' @examples
#' \donttest{
#' # Add a standard Dockerfile
Expand All @@ -43,7 +50,7 @@
#' add_dockerfile_heroku()
#' }
#'}
#'@return The `{dockerfiler}` object, invisibly.
#' @return The `{dockerfiler}` object, invisibly.
add_dockerfile <- function(
path = "DESCRIPTION",
output = "Dockerfile",
Expand All @@ -67,8 +74,6 @@ add_dockerfile <- function(

where <- path(pkg, output)

#if ( !check_file_exist(where) ) return(invisible(FALSE))

usethis::use_build_ignore(path_file(where))

dock <- dock_from_desc(
Expand Down Expand Up @@ -137,8 +142,6 @@ add_dockerfile_shinyproxy <- function(

where <- path(pkg, output)

#if ( !check_file_exist(where) ) return(invisible(FALSE))

usethis::use_build_ignore(output)

dock <- dock_from_desc(
Expand Down Expand Up @@ -200,8 +203,6 @@ add_dockerfile_heroku <- function(
){
where <- path(pkg, output)

#if ( !check_file_exist(where) ) return(invisible(FALSE))

usethis::use_build_ignore(output)

dock <- dock_from_desc(
Expand Down Expand Up @@ -287,20 +288,9 @@ alert_build <- function(
}
}

#' Create Dockerfile from DESCRIPTION
#' Create a Dockerfile from a DESCRIPTION
#
#' @param path path to the DESCRIPTION file to use as an input.
#'
#' @param FROM The FROM of the Dockerfile. Default is FROM rocker/r-ver:
#' with `R.Version()$major` and `R.Version()$minor`.
#' @param AS The AS of the Dockerfile. Default it NULL.
#' @param sysreqs boolean to check the system requirements
#' @param repos character vector, the base URL of the repositories
#' @param expand boolean, if `TRUE` each system requirement will be known his own RUN line
#' @param update_tar_gz boolean, if `TRUE` and build_golem_from_source is also `TRUE` an updated tar.gz Package is created
#' @param build_golem_from_source boolean, if `TRUE` no tar.gz Package is created and the Dockerfile directly mount the source folder to build it
#' @param extra_sysreqs extra debian system requirements as character vector. Will be installed with apt-get install
#'
#' @inheritParams add_dockerfile
#' @importFrom utils installed.packages packageVersion
#' @importFrom remotes dev_package_deps
#' @importFrom desc desc_get_deps desc_get
Expand All @@ -322,7 +312,7 @@ dock_from_desc <- function(
extra_sysreqs = NULL
){

packages <- desc::desc_get_deps(path)$package
packages <- desc_get_deps(path)$package
packages <- packages[packages != "R"] # remove R
packages <- packages[ !packages %in% c(
"base", "boot", "class", "cluster",
Expand Down
36 changes: 20 additions & 16 deletions R/add_files.R
Original file line number Diff line number Diff line change
@@ -1,22 +1,37 @@
#' Create Files
#'
#' These functions create files inside the `inst/app` folder.
#' These functions can be used outside of a {golem} project.
#'
#' @inheritParams add_module
#' @param dir Path to the dir where the file while be created.
#' @param with_doc_ready Should the default file include `$( document ).ready()`?
#' @param with_doc_ready For JS file - Should the default file include `$( document ).ready()`?
#' @param template Function writing in the created file.
#' You may overwrite this with your own template function.
#' @param ... Arguments to be passed to the `template` function.
#'
#' @param initialize For JS file - Whether to add the initialize method.
#' Default to FALSE. Some JavaScript API require to initialize components
#' before using them.
#' @param dev Whether to insert console.log calls in the most important
#' methods of the binding. This is only to help building the input binding.
#' Default is FALSE.
#' @param events List of events to generate event listeners in the subscribe method.
#' For instance, `list(name = c("click", "keyup"), rate_policy = c(FALSE, TRUE))`.
#' The list contain names and rate policies to apply to each event. If a rate policy is found,
#' the debounce method with a default delay of 250 ms is applied. You may edit manually according to
#' <https://shiny.rstudio.com/articles/building-inputs.html>
#' @export
#' @rdname add_files
#' @importFrom attempt stop_if
#' @importFrom rlang is_missing
#' @importFrom cli cat_bullet
#' @importFrom utils file.edit
#' @importFrom fs path_abs path file_create file_exists
#'
#' @note `add_ui_server_files` will be deprecated in future version of `{golem}`
#'
#' @seealso \code{\link{js_template}}, \code{\link{js_handler_template}}, and \code{\link{css_template}}
#'
#' @return The path to the file, invisibly.
add_js_file <- function(
name,
pkg = get_golem_wd(),
Expand All @@ -27,8 +42,8 @@ add_js_file <- function(
template = golem::js_template,
...
){
attempt::stop_if(
rlang::is_missing(name),
stop_if(
is_missing(name),
msg = "Name is required"
)

Expand Down Expand Up @@ -86,8 +101,6 @@ add_js_file <- function(
#' @rdname add_files
#'
#' @importFrom fs path_abs path file_create file_exists
#'
#' @seealso [js_handler_template()]
add_js_handler <- function(
name,
pkg = get_golem_wd(),
Expand Down Expand Up @@ -147,15 +160,6 @@ add_js_handler <- function(

#' @export
#' @rdname add_files
#' @param initialize Whether to add the initialize method. Default to FALSE. Some JavaScript API
#' require to initialize components before using them.
#' @param dev Whether to insert console.log calls in the most important methods of the binding.
#' This is only to help building the input binding. Default to FALSE
#' @param events List of events to generate event listeners in the subscribe method. For instance,
#' \code{list(name = c("click", "keyup"), rate_policy = c(FALSE, TRUE))}.
#' The list contain names and rate policies to apply to each event. If a rate policy is found,
#' the debounce method with a default delay of 250 ms is applied. You may edit manually according to
#' \url{https://shiny.rstudio.com/articles/building-inputs.html}.
#' @importFrom fs path_abs path file_create file_exists
add_js_input_binding <- function(
name,
Expand Down
87 changes: 21 additions & 66 deletions R/add_modules.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,29 @@
#'
#' This function creates a module inside the `R/` folder, based
#' on a specific module structure. This function can be used outside
#' of a {golem} project.
#' of a `{golem}` project.
#'
#' @param name The name of the module
#' @param name The name of the module.
#' @param pkg Path to the root of the package. Default is `get_golem_wd()`.
#' @param open Should the file be opened?
#' @param open Should the created file be opened?
#' @param dir_create Creates the directory if it doesn't exist, default is `TRUE`.
#' @param fct If specified, creates a mod_fct file.
#' @param utils If specified, creates a mod_utils file.
#' @param fct If specified, creates a `mod_fct` file.
#' @param utils If specified, creates a `mod_utils` file.
#' @param js,js_handler If specified, creates a module related JavaScript file.
#' @param export Logical. Should the module be exported? Default is `FALSE`.
#' @param js,js_handler Name of a javascript or javascript handler file to create
#' along the module.
#' @param export Should the module be exported? Default is `FALSE`.
#' @param module_template Function that serves as a module template.
#' @param ... Arguments to be passed to the `module_template` function.
#'
#' @note This function will prefix the `name` argument with `mod_`.
#'
#' @export
#' @importFrom cli cat_bullet
#' @importFrom utils file.edit
#' @importFrom fs path_abs path file_create
#'
#' @seealso [module_template()]
#'
#' @return The path to the file, invisibly.
add_module <- function(
name,
pkg = get_golem_wd(),
Expand Down Expand Up @@ -87,61 +89,6 @@ add_module <- function(
}
}

# This is an idea for shiming moduleServer from {shiny} so that
# the server infrastructure is not
#
# #' shim for moduleServer
# #'
# #' This function is a shim for `shiny::moduleServer` that allows passing
# #' arguments via `...`
# #'
# #' @inheritParams shiny::moduleServer
# #' @param ... Arguments to pass to the module server function when it's defined outside of `moduleServer()`
# #'
# #' @return The return value, if any, from executing the module server function
# #'
# #' @export
# #'
# #' @examples
# #' name_ui <- function(id){
# #' ns <- NS(id)
# #' tagList(
# #' actionButton(ns("go"), "go")
# #' )
# #' }
# #'
# #' name_server_core <- function(input, output, session, arg) {
# #' observeEvent( input$go , {
# #' print(arg)
# #' })
# #' }
# #'
# #' name_server <- function(id, arg) {
# #' moduleServer(
# #' id,
# #' name_server_core,
# #' arg = arg
# #' )
# #' }
# moduleServer <- function(
# id,
# module,
# ...,
# session = getDefaultReactiveDomain()
# ) {
# if (inherits(session, "MockShinySession")) {
# body(module) <- rlang::expr({
# session$setEnv(base::environment())
# !!body(module)
# })
# session$setReturned(callModule(module, id, session = session, ...))
# }
# else {
# callModule(module, id, session = session, ...)
# }
# }
#

#' Golem Module Template Function
#'
#' Module template can be used to extend golem module creation
Expand Down Expand Up @@ -181,14 +128,22 @@ add_module <- function(
#'
#' @inheritParams add_module
#' @param path The path to the R script where the module will be written.
#' Note that this path will not be set by the user but internally by
#' Note that this path will not be set by the user but via
#' `add_module()`.
#' @param ph_ui,ph_server Texts to insert inside the modules UI and server. For advanced use.
#' @param ph_ui,ph_server Texts to insert inside the modules UI and server.
#' For advanced use.
#'
#' @return Used for side effect
#' @export
#' @seealso [add_module()]
module_template <- function(name, path, export, ph_ui = " ", ph_server = " ", ...){
module_template <- function(
name,
path,
export,
ph_ui = " ",
ph_server = " ",
...
){
write_there <- function(...){
write(..., file = path, append = TRUE)
}
Expand Down
Loading

0 comments on commit 173dde4

Please sign in to comment.