Skip to contents

This function checks all R script files in a specified folder to ensure that all `@examples` sections in Roxygen documentation are wrapped in dontrun. It ensures proper package building and simplifies function documentation development for users.

Usage

checkPkg_add_roxygen_dontrun(folder = "R", test_individually = T)

Arguments

folder

Character. The folder containing the R scripts to process. Defaults to "R".

test_individually

Logical. If TRUE, prompts the user to press a key to continue after processing each file. Defaults to TRUE.

Details

The function performs the following checks on each script: - Ensures the script contains only one function. - Verifies that Roxygen documentation is present. - Checks if an `@examples` section exists. - Ensures dontrun is not already present around the `@examples` section.

If all conditions are met, the function automatically adds dontrun around the `@examples` section and relocates the `@export` tag if it appears after the `@examples` section.

Examples

if (FALSE) { # \dontrun{
# Assuming you have an "R" folder with R script files:
checkPkg_add_roxygen_dontrun(folder = "R", test_individually = TRUE)

# To process another folder:
checkPkg_add_roxygen_dontrun(folder = "path/to/your/folder", test_individually = FALSE)
} # }