install.packages("testthatdocs")
testthatdocs::document()
testthatdocs::document(template = "advanced")
| Before | After |
|---|---|
|
|
[!NOTE]
- Generates a global list of tests and per-section test listings as roxygen comments.
- Inserts the generated listings immediately after the corresponding markers.
[!TIP]
- The function is idempotent:
- Only replaces content between existing
@testsListand@testsSectionmarkers.- Leaves all other code and comments unchanged.
- If section headers are provided using a plain-text prefix (e.g.
# -):
- They are automatically converted to roxygen markers
#' @testsSection.- Any text following the prefix is treated as the section title.
Numbering is customisable via templates that use placeholders:
{g} – global incremental index across all tests{s} – section index (1-based, in order of appearance){i} – local index within a section (1-based){l} – line index (line number in the final, modified text)The following templates are available:
"simple" → {g}
"advanced" → {g}.{s}.{i}
"full" → {g}.{s}.{i}.{l}
You can fully override the numbering format by providing custom values for:
global_fmtsection_fmtThis allows complete control over how numbers are generated.