Learn R Programming

workflowr (version 0.7.0)

wflow_build: Build the site

Description

wflow_build builds the website from the files in the analysis directory. This is intended to be used when developing your code to preview the changes. When you are ready to commit the files, use wflow_publish.

Usage

wflow_build(files = NULL, make = is.null(files), update = FALSE,
  republish = FALSE, view = interactive(), seed = 12345, log_dir = NULL,
  local = FALSE, dry_run = FALSE, project = ".")

Arguments

files

character (default: NULL). Files to build. Supports file extensions Rmd and rmd. Only files in the analysis directory are allowed (and therefore any path to a file is ignored). If files is NULL, the default behavior is to build all outdated files (see argument make below).

make

logical (default: is.null(files)). When make = TRUE, use Make-like behavior, i.e. build the files that have been updated more recently than their corresponding HTML files. This is the default action if no files are specified.

update

logical (default: FALSE). Build the files that have been committed more recently than their corresponding HTML files (and do not have any unstaged or staged changes). This ensures that the commit version ID inserted into the HTML corresponds to the exact version of the source file that was used to produce it.

republish

logical (default: FALSE). Build all published R Markdown files. Useful for site-wide changes like updating the theme, navigation bar, or any other setting in _site.yml.

view

logical (default: interactive). View the website after building files. If only one file is built, it is opened. If more than one file is built, the main index page is opened. Not applicable if no files are built or if dry_run = TRUE.

seed

numeric (default: 12345). The seed to set before building each file. Passed to set.seed.

log_dir

character (default: NULL). The directory to save log files from building files. It will be created if necessary and ignored if local = TRUE. The default is to create a directory in /tmp.

local

logical (default: FALSE). Build files locally in the R console. This should only be used for debugging purposes. The default is to build each file in its own separate fresh R process to ensure each file is reproducible in isolation.

dry_run

logical (default: FALSE). List the files to be built, without building them.

project

character (default: ".") By default the function assumes the current working directory is within the project. If this is not true, you'll need to provide the path to the project directory.

Value

An object of class wflow_build, which is a list with the following elements:

  • files: The input argument files

  • make: The input argument make

  • update: The input argument update

  • republish: The input argument republish

  • view: The input argument view

  • seed: The input argument seed

  • log_dir: The directory where the log files were saved

  • local: The input argument local

  • dry_run: The input argument dry_run

  • built: The relative paths to the built R Markdown files

  • html: The relative paths to the corresponding HTML files

Details

wflow_build has multiple, non-mutually exclusive options for deciding which files to build:

  • Files specified via the argument files are always built.

  • If make = TRUE, all files which have been modified more recently than their corresponding HTML files will be built.

  • If update = TRUE, all files which have been committed more recently than their corresponding HTML files will be built. However, files which currently have staged or unstaged changes will be ignored.

  • If republish = TRUE, all published files will be rebuilt.

Under the hood, wflow_build is a wrapper for render_site from the package rmarkdown.

See Also

wflow_publish

Examples

Run this code
# NOT RUN {
# Build all files
wflow_build() # equivalent to wflow_build(make = TRUE)
# Build a single file
wflow_build("file.Rmd")
# Build multiple files
wflow_build(c("file1.Rmd", "file2.Rmd"))
# Build every file
wflow_build(republish = TRUE)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab