Skip to content

Commit

Permalink
included social output in build_all()
Browse files Browse the repository at this point in the history
  • Loading branch information
jhelvy committed Feb 10, 2021
1 parent ec4092d commit d293a29
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 50 deletions.
39 changes: 19 additions & 20 deletions R/all.R
Original file line number Diff line number Diff line change
@@ -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"`,
Expand Down Expand Up @@ -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,
Expand All @@ -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
Expand All @@ -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,
Expand All @@ -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)
}
32 changes: 16 additions & 16 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -127,6 +111,22 @@ Example:

<img src="man/figures/slides_social.png" width=500>

### 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()`.
Expand Down
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -97,6 +84,19 @@ Example:

<img src="man/figures/slides_social.png" width=500>

### 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
Expand Down
2 changes: 1 addition & 1 deletion man/build_all.Rd

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

0 comments on commit d293a29

Please sign in to comment.