From d293a29211c00d422e392164f77bb0b850035e19 Mon Sep 17 00:00:00 2001 From: John Helveston Date: Wed, 10 Feb 2021 10:25:07 -0500 Subject: [PATCH] included social output in build_all() --- R/all.R | 39 +++++++++++++++++++-------------------- README.Rmd | 32 ++++++++++++++++---------------- README.md | 26 +++++++++++++------------- man/build_all.Rd | 2 +- 4 files changed, 49 insertions(+), 50 deletions(-) diff --git a/R/all.R b/R/all.R index cd0b870..765725f 100644 --- a/R/all.R +++ b/R/all.R @@ -1,19 +1,3 @@ -# Build hierarchy: -# -# Rmd -# | -# |--> social (png) -# | -# |--> html -# | -# |--> thumbnail (png) -# | -# |--> pdf -# | -# |--> gif -# | -# |--> pptx - #' Build xaringan slides to multiple outputs. #' #' Build xaringan slides to multiple outputs. Options are `"html"`, `"pdf"`, @@ -51,7 +35,7 @@ #' } build_all <- function( input, - include = c("html", "pdf", "gif", "pptx", "thumbnail"), + include = c("html", "pdf", "gif", "pptx", "thumbnail", "social"), exclude = NULL, complex_slides = FALSE, partial_slides = FALSE, @@ -68,9 +52,23 @@ build_all <- function( do_gif <- ("gif" %in% include) && (! "gif" %in% exclude) do_ppt <- ("pptx" %in% include) && (! "pptx" %in% exclude) do_thm <- ("thumbnail" %in% include) && (! "thumbnail" %in% exclude) + do_soc <- ("social" %in% include) && (! "social" %in% exclude) - # each step requires the format of the previous step - # html -> pdf -> gif / pptx + # Build hierarchy: + # + # Rmd + # | + # |--> social (png) + # | + # |--> html + # | + # |--> thumbnail (png) + # | + # |--> pdf + # | + # |--> gif + # | + # |--> pptx # # currently calling a step out of order will create the intermediate steps # if at some point intermediate files are removed if not requested, the @@ -93,7 +91,9 @@ build_all <- function( # Do each step in order to ensure updates propagate # (or we use the current version of the required build step) + if (do_soc) build_html(input) if (do_htm) build_html(input) + if (do_thm) build_thumbnail(input_html) if (do_pdf) { build_pdf( input = input_html, @@ -103,7 +103,6 @@ build_all <- function( } if (do_gif) build_gif(input_pdf) if (do_ppt) build_pptx(input_pdf) - if (do_thm) build_thumbnail(input_html) invisible(input) } diff --git a/README.Rmd b/README.Rmd index 4379c80..6e61914 100644 --- a/README.Rmd +++ b/README.Rmd @@ -45,22 +45,6 @@ library(xaringanBuilder) The xaringan Rmd files used in all examples below can be found [here](https://github.com/jhelvy/xaringanBuilder/tree/master/inst/example) -### Build All Output Types - -Use `build_all()` to build all output types from a Rmd file: - -``` -build_all("slides.Rmd") # Builds every output by default -``` - -Use the `include` or `exclude` arguments to control which output types to include or exclude: - -``` -# Both of these build html, pdf, and gif outputs -build_all("slides.Rmd", include = c("html", "pdf", "gif")) -build_all("slides.Rmd", exclude = c("pptx", "thumbnail")) -``` - ### Build HTML Build an html file from a Rmd file: @@ -127,6 +111,22 @@ Example: +### Build All Output Types + +Use `build_all()` to build all output types from a Rmd file: + +``` +build_all("slides.Rmd") # Builds every output by default +``` + +Use the `include` or `exclude` arguments to control which output types to include or exclude: + +``` +# Both of these build html, pdf, and gif outputs +build_all("slides.Rmd", include = c("html", "pdf", "gif")) +build_all("slides.Rmd", exclude = c("pptx", "thumbnail", "social")) +``` + ## "Complex" slides "Complex" slides are slides that contain [panelsets](https://pkg.garrickadenbuie.com/xaringanExtra/#/panelset) or other html widgets / advanced features that might not render well as a pdf. To render these, set `complex_slides = TRUE` in `build_pdf()`, `build_gif()`, `build_pptx()`, or `build_all()`. diff --git a/README.md b/README.md index 95a11c9..01872a5 100644 --- a/README.md +++ b/README.md @@ -27,19 +27,6 @@ You can install the current version of xaringanBuilder from GitHub: The xaringan Rmd files used in all examples below can be found [here](https://github.com/jhelvy/xaringanBuilder/tree/master/inst/example) -### Build All Output Types - -Use `build_all()` to build all output types from a Rmd file: - - build_all("slides.Rmd") # Builds every output by default - -Use the `include` or `exclude` arguments to control which output types -to include or exclude: - - # Both of these build html, pdf, and gif outputs - build_all("slides.Rmd", include = c("html", "pdf", "gif")) - build_all("slides.Rmd", exclude = c("pptx", "thumbnail")) - ### Build HTML Build an html file from a Rmd file: @@ -97,6 +84,19 @@ Example: +### Build All Output Types + +Use `build_all()` to build all output types from a Rmd file: + + build_all("slides.Rmd") # Builds every output by default + +Use the `include` or `exclude` arguments to control which output types +to include or exclude: + + # Both of these build html, pdf, and gif outputs + build_all("slides.Rmd", include = c("html", "pdf", "gif")) + build_all("slides.Rmd", exclude = c("pptx", "thumbnail", "social")) + ## “Complex” slides “Complex” slides are slides that contain diff --git a/man/build_all.Rd b/man/build_all.Rd index d3dcc07..916544e 100644 --- a/man/build_all.Rd +++ b/man/build_all.Rd @@ -6,7 +6,7 @@ \usage{ build_all( input, - include = c("html", "pdf", "gif", "pptx", "thumbnail"), + include = c("html", "pdf", "gif", "pptx", "thumbnail", "social"), exclude = NULL, complex_slides = FALSE, partial_slides = FALSE,