wflow_view: View research website locally

View source: R/wflow_view.R

wflow_viewR Documentation

View research website locally

Description

wflow_view displays the website locally in your browser or the RStudio Viewer pane.

Usage

wflow_view(files = NULL, latest = FALSE, dry_run = FALSE, project = ".")

Arguments

files

character (default: NULL). Name(s) of the specific file(s) to view. These can be either the name(s) of the R Markdown file(s) in the analysis directory or the HTML file(s) in the docs directory. Supports file globbing.

latest

logical (default: FALSE). Display the HTML file with the most recent modification time (in addition to those specified in files). If files = NULL and latest = FALSE, then index.html is viewed.

dry_run

logical (default: FALSE). Do not actually view file(s). Mainly useful for testing.

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.

Details

wflow_view by default displays the file index.html. To view the most recently modified HTML file, set latest = TRUE. To specify which file(s) to view, specify either the name(s) of the R Markdown or HTML file(s).

wflow_view uses browseURL to view the HTML files in the browser. If you wish to do something non-traditional like view an HTML file that is not in the docs directory or not part of a workflowr project, you can use that function directly.

If wflow_view is run in the RStudio IDE and only one file has been requested to be viewed, the file is displayed in the RStudio Viewer.

If R has no default browser set (determined by getOption("browser")), then wflow_view cannot open any HTML files. See browseURL for setup instructions.

Value

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

files

The input argument files (converted to relative paths).

latest

The input argument latest.

dry_run

The input argument dry_run.

browser

Logical indicating if a default browser has been set. If FALSE, no HTML files can be opened. This is determined by the value returned by getOption("browser").

opened

The HTML files opened by wflow_view.

See Also

browseURL

Examples

## Not run: 

# View index.html
wflow_view()

# View the most recently modified HTML file
wflow_view(latest = TRUE)

# View a file by specifying the R Markdown file
wflow_view("analysis/fname.Rmd")

# View a file by specifying the HTML file
wflow_view("docs/fname.html")

# View multiple files
wflow_view(c("fname1.Rmd", "fname2.Rmd"))
wflow_view("docs/*html")

## End(Not run)

workflowr documentation built on Aug. 23, 2023, 1:09 a.m.