Skip to content

This function reads a directory tree and makes a theme. Each file becomes a step_file(). Each empty directory becomes a step that makes the directory again. An optional _prefab.yml file at the root of the directory can change the strategy and the template data for each file.

Usage

theme_from_dir(path, strategy = "skip")

Arguments

path

The path to a directory of template files. The directory must exist. prefab expands a leading ~. prefab also makes a relative path absolute against the working directory. prefab does these two operations only to find the files. Each step keeps the path in the spelling that you supply in its provenance record.

strategy

The default merge strategy for all files. A _prefab.yml sidecar can change the strategy for each file. Use one of "overwrite", "skip", "union", "append", or "merge_json".

Value

A prefab_theme object.

Details

Each file below path becomes a step_file(). The destination of the step is the path of the file relative to path. prefab includes hidden files. prefab also includes hidden empty directories.

prefab excludes these directories at all levels of the tree:

  • .git

  • .Rproj.user

  • _targets

  • renv/library

prefab does not deploy the symbolic links below path.

This function is called by use_theme(), create_project(), launch_project(), and + when they process a path. They call this function with the default arguments.

Examples

if (FALSE) { # \dontrun{
# Make a theme from a directory of configuration files
use_theme(theme_from_dir("~/my-template"))

# The short form. It calls theme_from_dir() with the default arguments.
use_theme("~/my-template")

# Add the theme to another theme
use_theme(r_analysis() + theme_from_dir("~/my-extras"))
} # }