This vignette demonstrates a robust, idempotent
workflow for generating a roxygen2-style inventory of all
test_that() calls in one test file. The function:
test_that() as the title (without evaluating
expressions)."# -"
prefix) to roxygen markers #' @testsSection.#' @testsList and per-section listings
after each #' @testsSection.{g} (global),
{s} (section), {i} (local within section),
{l} (final line number).@testsItem blocks
immediately following listing markers are regenerated; all other code
and comments remain unchanged.paste("x", y).library(testthatdocs)
res <- document_file(
path = system.file("examples", "tests_sample_before.R", package="testthatdocs"),
section_prefix = "# -",
template = "advanced", # or "simple"
encoding = "UTF-8",
backup = TRUE,
write = TRUE
)
# Summary of tests
res$listing
# Modified test file
res$text```
The result includes:
text: the modified file as a character vector (one line
per element)listing: a data frame with columns
g, s, i, l, title_raw, section_titlewritten: whether the file was writtenbackup: backup path (if created)