Skip to content

Commit

Permalink
✨ add install_workshops_pkgs_remotes() see #1
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Cazelles committed Mar 5, 2020
1 parent 3222f7b commit 19323bc
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 10 deletions.
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
13 changes: 10 additions & 3 deletions R/build_workshops.R
Original file line number Diff line number Diff line change
Expand Up @@ -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$"

Expand All @@ -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)

Expand Down
12 changes: 12 additions & 0 deletions R/install_workshops_pkgs.R
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down
5 changes: 2 additions & 3 deletions R/render_workshops.R
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions man/build_workshops.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions man/install_workshops_pkgs.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/render_workshops.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 19323bc

Please sign in to comment.