Skip to content

Commit 786057d

Browse files
authored
Add a flag to disable render (close #9) (#10)
1 parent f596d84 commit 786057d

File tree

5 files changed

+49
-24
lines changed

5 files changed

+49
-24
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ Suggests:
2626
knitr,
2727
covr
2828
VignetteBuilder: knitr
29-
RoxygenNote: 6.0.1
29+
RoxygenNote: 7.1.0

R/assignr-package.R

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,9 @@
11
#' @aliases assignr-package
2+
#' @keywords internal
23
"_PACKAGE"
4+
5+
# The following block is used by usethis to automatically manage
6+
# roxygen namespace tags. Modify with care!
7+
## usethis namespace: start
8+
## usethis namespace: end
9+
NULL

R/assignr.R

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ generate_hw_pkg = function(x,
5050
name,
5151
type,
5252
output_dir = paste0(name, "-", type),
53+
render_files = TRUE,
5354
zip_files = TRUE) {
5455

5556
if (length(remove_indexes) > 0) {
@@ -77,13 +78,15 @@ generate_hw_pkg = function(x,
7778
# write to .Rmd, then render as html and pdf
7879
writeLines(x, rmd_material_name)
7980

80-
rmarkdown::render(
81-
rmd_material_name,
82-
encoding = "UTF-8",
83-
envir = new.env(),
84-
output_format = c("html_document", "pdf_document"),
85-
quiet = TRUE
86-
)
81+
if (render_files) {
82+
rmarkdown::render(
83+
rmd_material_name,
84+
encoding = "UTF-8",
85+
envir = new.env(),
86+
output_format = c("html_document", "pdf_document"),
87+
quiet = TRUE
88+
)
89+
}
8790

8891
if (zip_files) {
8992
message("Creating a zip file for ", output_name)
@@ -130,12 +133,14 @@ get_example_filepath = function(x) {
130133
#' Transforms an RMarkdown file into two separate files: `filename-assign`
131134
#' and `filename-solutions`
132135
#'
133-
#' @param file Input `.Rmd` file with `-main.Rmd` in the filename.
134-
#' @param output_dir Output directory. Defaults to name of prefix of filename.
135-
#' @param soln_file Generate Solution Material. Default is `TRUE`.
136-
#' @param assign_file Generate Student Assignment Material. Default is `TRUE`.
137-
#' @param zip_files Create a zip file containing the relevant materials.
138-
#' Default is `TRUE`.
136+
#' @param file Input `.Rmd` file with `-main.Rmd` in the filename.
137+
#' @param output_dir Output directory. Defaults to name of prefix of filename.
138+
#' @param soln_file Generate Solution Material. Default is `TRUE`.
139+
#' @param assign_file Generate Student Assignment Material. Default is `TRUE`.
140+
#' @param zip_files Create a zip file containing the relevant materials.
141+
#' Default is `TRUE`.
142+
#' @param render_files Create HTML and PDF output for each Rmd file.
143+
#' Default is `TRUE`.
139144
#' @export
140145
#' @return The function will generate assignment files for students and
141146
#' solution keys for instructors.
@@ -165,7 +170,8 @@ assignr = function(file,
165170
output_dir = NULL,
166171
assign_file = TRUE,
167172
soln_file = TRUE,
168-
zip_files = TRUE) {
173+
zip_files = TRUE,
174+
render_files = TRUE) {
169175

170176
if (length(file) != 1) {
171177
stop("Only one file may be processed at time.")
@@ -212,7 +218,9 @@ assignr = function(file,
212218
remove_indexes = c(solution_indexes, direction_chunk_indices),
213219
name = hw_name,
214220
type = "assign",
215-
output_dir = output_dir
221+
output_dir = output_dir,
222+
render_files = render_files,
223+
zip_files = zip_files
216224
)
217225
}
218226

@@ -223,6 +231,7 @@ assignr = function(file,
223231
name = hw_name,
224232
type = "soln",
225233
output_dir = output_dir,
234+
render_files = render_files,
226235
zip_files = zip_files
227236
)
228237
}

man/assignr-package.Rd

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/assignr.Rd

Lines changed: 11 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)