Skip to contents

Checks that all citations in the boilerplate text exist in the bibliography file.

Usage

boilerplate_validate_references(
  db,
  bib_file = NULL,
  categories = c("methods", "results", "discussion", "appendix"),
  quiet = FALSE
)

Arguments

db

Database object to validate

bib_file

Path to bibliography file. If NULL, will try to download from database

categories

Character vector of categories to check. Default is all text categories.

quiet

Logical. Suppress detailed messages

Value

List with validation results including used keys, available keys, and missing keys

Examples

# \donttest{
# Create temporary directory for example
temp_dir <- tempfile()
dir.create(temp_dir)

# Initialise and import
boilerplate_init(data_path = temp_dir, create_dirs = TRUE, confirm = FALSE, quiet = TRUE)
db <- boilerplate_import(data_path = temp_dir, quiet = TRUE)

# Validate references
validation <- boilerplate_validate_references(db)
#> Migrated bibliography cache from old location to /Users/joseph/Library/Caches/org.R-project.R/R/boilerplate
#>  No bibliography URL specified in database
#> ! No bibliography file available for validation
if (length(validation$missing) > 0) {
  warning("Missing references: ", paste(validation$missing, collapse = ", "))
}

# Clean up
unlink(temp_dir, recursive = TRUE)
# }