diff --git a/NAMESPACE b/NAMESPACE index 6795372..722225d 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -10,6 +10,7 @@ export(install_cran_pkgs) export(install_repos_pkgs) export(install_workshop_pkgs_indiv) export(install_workshops_pkgs) +export(install_workshops_pkgs_remotes) export(mail_workshop) export(render_workshops) export(update_template) @@ -18,6 +19,7 @@ importFrom(crayon,blue) importFrom(crayon,green) importFrom(knitr,purl) importFrom(pagedown,chrome_print) +importFrom(remotes,install_deps) importFrom(remotes,install_github) importFrom(rmarkdown,render) importFrom(tools,md5sum) diff --git a/NEWS.md b/NEWS.md index b715c1b..1a12f08 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,7 @@ # qcbsRworkshops 0.1.0.9000 -* Simplify message when HTML presentations are successfully rendered. +* Simplify message when HTML presentations are successfully rendered. +* `install_workshops_pkgs_remotes()` use package `remotes` to install packages required for a given workshop. # qcbsRworkshops 0.1.0 diff --git a/R/build_workshops.R b/R/build_workshops.R index 5391a24..918e5e9 100644 --- a/R/build_workshops.R +++ b/R/build_workshops.R @@ -8,11 +8,14 @@ #' @param Rmdfiles R Markdown source files, if `NULL` (default) then, files will be searched for in the current directory. #' @param update_template a logical. Should the template files be updated. Note that if these files are missing then they will be downloaded. #' @param pdf a logical. Should a pdf version of the template be produced? +#' @param upgrade Should how of date packages be updated? One of "default", +#' "ask", "always", or "never". "default", see [remotes::install_deps()] for +#' further details. #' @param verbose a logical. Should extra information be reported on progress? #' #' @export -build_workshops <- function(path = ".", download = FALSE, id = NULL, Rmdfiles = NULL, update_template = FALSE, pdf = FALSE, verbose = TRUE) { +build_workshops <- function(path = ".", download = FALSE, id = NULL, Rmdfiles = NULL, update_template = FALSE, pdf = FALSE, upgrade = "never", verbose = TRUE) { rx <- "^workshop[0-9]{2}-[ef][nr].[Rr]md$" @@ -28,11 +31,15 @@ build_workshops <- function(path = ".", download = FALSE, id = NULL, Rmdfiles = } if (!length(Rmdfiles)) stop("No source file found!") - install_workshops_pkgs(find_f(path, "^pkgs.yaml$"), verbose = verbose) + if (length(find_f(path, "^pkgs.yaml$"))) { + install_workshops_pkgs(find_f(path, "^pkgs.yaml$"), verbose = verbose) + } + ## New way to install packages using remotes + install_workshops_pkgs_remotes(path, upgrade = "never") # check/update template files + path2 <- gsub("/[^/]*$", "", Rmdfiles) t_files <- find_f(path, "^qcbsR.*[msj][ls]$") - path2 <- gsub(paste0("/", rx), "", Rmdfiles) if (!all(template_files(path2) %in% t_files) | update_template) update_template(path, verbose = verbose) diff --git a/R/install_workshops_pkgs.R b/R/install_workshops_pkgs.R index 4583ee3..1f93146 100644 --- a/R/install_workshops_pkgs.R +++ b/R/install_workshops_pkgs.R @@ -3,6 +3,8 @@ #' @param file path to the list of dependencies #' @param verbose a logical. Should extra information be reported on progress? #' @param x a character string of the name of a package. +#' @param path path where the workshops files +#' @param ... further arguments passed to [remotes::install_deps()]. #' #' @export @@ -15,6 +17,16 @@ install_workshops_pkgs <- function(file = "pkgs.yaml", verbose = TRUE) { invisible(NULL) } + +#' @rdname install_workshops_pkgs +#' @export +install_workshops_pkgs_remotes <- function(path, ...) { + des <- find_f(path, "^DESCRIPTION") + lapply(gsub("/[^/]*$", "", des), function(x) install_deps(x, ...)) + invisible(NULL) +} + + #' @rdname install_workshops_pkgs #' @export diff --git a/R/render_workshops.R b/R/render_workshops.R index 3399279..d219fad 100644 --- a/R/render_workshops.R +++ b/R/render_workshops.R @@ -1,11 +1,10 @@ #' Render workshops #' -#' Convert RMarkdown files to html presentations. +#' Convert R Markdown files to HTML presentations. #' -#' @param files path to the workshops Rmd file(s() to be rendered. +#' @param files path to the workshops' Rmd file(s) to be rendered. #' @param verbose a logical. Should extra information be reported on progress? #' -#' #' @export render_workshops <- function(files, verbose = TRUE) { diff --git a/R/zzz.R b/R/zzz.R index 1bc06ec..40c6610 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -9,7 +9,7 @@ #' @importFrom crayon blue green #' @importFrom knitr purl #' @importFrom pagedown chrome_print -#' @importFrom remotes install_github +#' @importFrom remotes install_github install_deps #' @importFrom rmarkdown render #' @importFrom tools md5sum #' @importFrom utils download.file install.packages unzip diff --git a/man/build_workshops.Rd b/man/build_workshops.Rd index a60e570..4195faf 100644 --- a/man/build_workshops.Rd +++ b/man/build_workshops.Rd @@ -11,6 +11,7 @@ build_workshops( Rmdfiles = NULL, update_template = FALSE, pdf = FALSE, + upgrade = "never", verbose = TRUE ) } @@ -27,6 +28,10 @@ build_workshops( \item{pdf}{a logical. Should a pdf version of the template be produced?} +\item{upgrade}{Should how of date packages be updated? One of "default", +"ask", "always", or "never". "default", see \code{\link[remotes:install_deps]{remotes::install_deps()}} for +further details.} + \item{verbose}{a logical. Should extra information be reported on progress?} } \description{ diff --git a/man/install_workshops_pkgs.Rd b/man/install_workshops_pkgs.Rd index 6cb92d0..d39f06d 100644 --- a/man/install_workshops_pkgs.Rd +++ b/man/install_workshops_pkgs.Rd @@ -2,6 +2,7 @@ % Please edit documentation in R/install_workshops_pkgs.R \name{install_workshops_pkgs} \alias{install_workshops_pkgs} +\alias{install_workshops_pkgs_remotes} \alias{install_workshop_pkgs_indiv} \alias{install_cran_pkgs} \alias{install_cran_archived_pkgs} @@ -10,6 +11,8 @@ \usage{ install_workshops_pkgs(file = "pkgs.yaml", verbose = TRUE) +install_workshops_pkgs_remotes(path, ...) + install_workshop_pkgs_indiv(file = "pkgs.yaml", verbose = TRUE) install_cran_pkgs(x) @@ -23,6 +26,10 @@ install_repos_pkgs(x) \item{verbose}{a logical. Should extra information be reported on progress?} +\item{path}{path where the workshops files} + +\item{...}{further arguments passed to \code{\link[remotes:install_deps]{remotes::install_deps()}}.} + \item{x}{a character string of the name of a package.} } \description{ diff --git a/man/render_workshops.Rd b/man/render_workshops.Rd index 0faa3fa..3a7acd1 100644 --- a/man/render_workshops.Rd +++ b/man/render_workshops.Rd @@ -7,10 +7,10 @@ render_workshops(files, verbose = TRUE) } \arguments{ -\item{files}{path to the workshops Rmd file(s() to be rendered.} +\item{files}{path to the workshops' Rmd file(s) to be rendered.} \item{verbose}{a logical. Should extra information be reported on progress?} } \description{ -Convert RMarkdown files to html presentations. +Convert R Markdown files to HTML presentations. }