framework docs
Notebooks & Scripts

stubs_publish()

Publish Stub Templates for Customization

Copies framework stub templates to your project's stubs/ directory, allowing you to customize them. Similar to Laravel's artisan vendor:publish command.

Usage

stubs_publish(type = "all", overwrite = FALSE, stubs = NULL)

Arguments

type
Character vector. Which stub types to publish: - "notebooks" - Quarto/RMarkdown notebook stubs - "scripts" - R script stubs - "all" - All stubs (default)
overwrite
Logical. Whether to overwrite existing stubs. Default FALSE.
stubs
Character vector. Specific stub names to publish (e.g., "default", "minimal"). If NULL (default), publishes all stubs of the specified type.

Value

Invisible list of published file paths

Details

Stub Customization Workflow

  1. Publish stubs to your project: stubs_publish()
  2. Edit stubs in stubs/ directory to match your preferences
  3. Use make_notebook() or make_script() - your custom stubs are used automatically

Stub Naming Convention

Stubs follow this naming pattern:

  • Notebooks: stubs/notebook-{name}.qmd or stubs/notebook-{name}.Rmd
  • Scripts: stubs/script-{name}.R

Framework searches user stubs first, then falls back to built-in stubs.

Available Placeholders

Stubs can use these placeholders:

  • {filename} - File name without extension
  • {date} - Current date (YYYY-MM-DD)

Examples

if (FALSE) {
# Publish all stubs
stubs_publish()
# Publish only notebook stubs
stubs_publish("notebooks")
# Publish specific stub
stubs_publish(stubs = "default")
# Overwrite existing stubs
stubs_publish(overwrite = TRUE)
}

See also