diff --git a/DESCRIPTION b/DESCRIPTION index c9cab33..919ac23 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -26,4 +26,4 @@ Suggests: knitr, covr VignetteBuilder: knitr -RoxygenNote: 6.0.1 +RoxygenNote: 7.1.0 diff --git a/R/assignr-package.R b/R/assignr-package.R index 8ee1b47..e1f0126 100644 --- a/R/assignr-package.R +++ b/R/assignr-package.R @@ -1,2 +1,9 @@ #' @aliases assignr-package +#' @keywords internal "_PACKAGE" + +# The following block is used by usethis to automatically manage +# roxygen namespace tags. Modify with care! +## usethis namespace: start +## usethis namespace: end +NULL diff --git a/R/assignr.R b/R/assignr.R index 45e3189..2d613f5 100644 --- a/R/assignr.R +++ b/R/assignr.R @@ -50,6 +50,7 @@ generate_hw_pkg = function(x, name, type, output_dir = paste0(name, "-", type), + render_files = TRUE, zip_files = TRUE) { if (length(remove_indexes) > 0) { @@ -77,13 +78,15 @@ generate_hw_pkg = function(x, # write to .Rmd, then render as html and pdf writeLines(x, rmd_material_name) - rmarkdown::render( - rmd_material_name, - encoding = "UTF-8", - envir = new.env(), - output_format = c("html_document", "pdf_document"), - quiet = TRUE - ) + if (render_files) { + rmarkdown::render( + rmd_material_name, + encoding = "UTF-8", + envir = new.env(), + output_format = c("html_document", "pdf_document"), + quiet = TRUE + ) + } if (zip_files) { message("Creating a zip file for ", output_name) @@ -130,12 +133,14 @@ get_example_filepath = function(x) { #' Transforms an RMarkdown file into two separate files: `filename-assign` #' and `filename-solutions` #' -#' @param file Input `.Rmd` file with `-main.Rmd` in the filename. -#' @param output_dir Output directory. Defaults to name of prefix of filename. -#' @param soln_file Generate Solution Material. Default is `TRUE`. -#' @param assign_file Generate Student Assignment Material. Default is `TRUE`. -#' @param zip_files Create a zip file containing the relevant materials. -#' Default is `TRUE`. +#' @param file Input `.Rmd` file with `-main.Rmd` in the filename. +#' @param output_dir Output directory. Defaults to name of prefix of filename. +#' @param soln_file Generate Solution Material. Default is `TRUE`. +#' @param assign_file Generate Student Assignment Material. Default is `TRUE`. +#' @param zip_files Create a zip file containing the relevant materials. +#' Default is `TRUE`. +#' @param render_files Create HTML and PDF output for each Rmd file. +#' Default is `TRUE`. #' @export #' @return The function will generate assignment files for students and #' solution keys for instructors. @@ -165,7 +170,8 @@ assignr = function(file, output_dir = NULL, assign_file = TRUE, soln_file = TRUE, - zip_files = TRUE) { + zip_files = TRUE, + render_files = TRUE) { if (length(file) != 1) { stop("Only one file may be processed at time.") @@ -212,7 +218,9 @@ assignr = function(file, remove_indexes = c(solution_indexes, direction_chunk_indices), name = hw_name, type = "assign", - output_dir = output_dir + output_dir = output_dir, + render_files = render_files, + zip_files = zip_files ) } @@ -223,6 +231,7 @@ assignr = function(file, name = hw_name, type = "soln", output_dir = output_dir, + render_files = render_files, zip_files = zip_files ) } diff --git a/man/assignr-package.Rd b/man/assignr-package.Rd index 48e7fbf..a0e180e 100644 --- a/man/assignr-package.Rd +++ b/man/assignr-package.Rd @@ -6,12 +6,12 @@ \alias{_PACKAGE} \title{assignr: Create Homework Assignments and Solutions using 'RMarkdown'} \description{ -Writing homework assignments for students in the age of 'RMarkdown' -necessitates the creation of two separate documents -- assign.Rmd and soln.Rmd. -The goal of assignr is to create one document main.Rmd that can be broken -apart into the above two documents. Thus, there is no longer a need to copy -and paste between the assign and the soln documents as all of the contents -are together in one file. +Writing homework assignments for students in the age of 'RMarkdown' + necessitates the creation of two separate documents -- assign.Rmd and soln.Rmd. + The goal of assignr is to create one document main.Rmd that can be broken + apart into the above two documents. Thus, there is no longer a need to copy + and paste between the assign and the soln documents as all of the contents + are together in one file. } \seealso{ Useful links: diff --git a/man/assignr.Rd b/man/assignr.Rd index 895f28e..1b93b14 100644 --- a/man/assignr.Rd +++ b/man/assignr.Rd @@ -4,8 +4,14 @@ \alias{assignr} \title{Create Homework and Assignment Materials} \usage{ -assignr(file, output_dir = NULL, assign_file = TRUE, soln_file = TRUE, - zip_files = TRUE) +assignr( + file, + output_dir = NULL, + assign_file = TRUE, + soln_file = TRUE, + zip_files = TRUE, + render_files = TRUE +) } \arguments{ \item{file}{Input `.Rmd` file with `-main.Rmd` in the filename.} @@ -18,6 +24,9 @@ assignr(file, output_dir = NULL, assign_file = TRUE, soln_file = TRUE, \item{zip_files}{Create a zip file containing the relevant materials. Default is `TRUE`.} + +\item{render_files}{Create HTML and PDF output for each Rmd file. +Default is `TRUE`.} } \value{ The function will generate assignment files for students and