diff --git a/DESCRIPTION b/DESCRIPTION index f851d83..586d6bf 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: tinyrox Title: Minimal R Documentation Generator -Version: 0.3.3.7 +Version: 0.3.3.8 Authors@R: person("Troy", "Hernandez", email = "troy@cornball.ai", role = c("aut", "cre"), comment = c(ORCID = "0009-0005-4248-604X")) diff --git a/R/document.R b/R/document.R index 3e9930d..2fc0d91 100644 --- a/R/document.R +++ b/R/document.R @@ -71,7 +71,13 @@ document <- function(path = ".", if (!silent) { message("No documentation blocks found.") } - return(invisible(list(rd_files = character(), pruned = character(), + # Nothing is generated this run, so every tinyrox-owned Rd is now stale + # (e.g. the last documented topic was deleted). Prune them too. + pruned <- character() + if (prune_rd) { + pruned <- prune_stale_rd(path, character(), silent) + } + return(invisible(list(rd_files = character(), pruned = pruned, namespace = NULL))) } diff --git a/README.md b/README.md index a78d1ca..aff9c6e 100644 --- a/README.md +++ b/README.md @@ -83,30 +83,25 @@ add <- function(x, y) { tinyrox includes automated CRAN compliance checks: ```r -# Check DESCRIPTION for common issues -check_description_cran() -# Warns about: unquoted package names, missing web service links - # Check R code for CRAN policy violations check_code_cran() # Warns about: T/F, print()/cat(), .GlobalEnv, installed.packages(), etc. -# Run all checks -check_cran() +# Check exported functions for missing examples and \dontrun overuse +check_examples_cran() -# Auto-fix DESCRIPTION quoting issues -fix_description_cran() +# Run all checks (code + examples) +check_cran() ``` Issues detected: -- Unquoted package/software names in Title/Description -- Missing web service links for packages like hfhub, gh - `T`/`F` instead of `TRUE`/`FALSE` - `print()`/`cat()` instead of `message()` - `installed.packages()` usage - `.GlobalEnv` modifications - `setwd()` without `on.exit()` restoration - Hardcoded `set.seed()` without parameter +- Exported functions without examples; `\dontrun{}` overuse ## Philosophy @@ -119,7 +114,7 @@ tinyrox follows the [tinyverse](https://www.tinyverse.org) philosophy: - Explicit over implicit - no inference magic - Strict subset of tags - not everything roxygen2 does - Deterministic output - same input = same output -- Fail fast on unknown tags +- Warn and skip unknown tags (roxygen2 behavior), never abort the run **What tinyrox does NOT do:** - Markdown parsing diff --git a/inst/tinytest/test_prune.R b/inst/tinytest/test_prune.R index 8383517..e633646 100644 --- a/inst/tinytest/test_prune.R +++ b/inst/tinytest/test_prune.R @@ -45,3 +45,25 @@ expect_false(file.exists(file.path(pkg, "man", "old_topic.Rd"))) # stale tinyro expect_equal(sort(basename(res$pruned)), c("foo.Rd", "old_topic.Rd")) unlink(pkg, recursive = TRUE) + +# Deleting the last documented topic prunes its Rd: with zero blocks the run +# generates nothing, so every tinyrox-owned Rd is stale (document() must prune +# on the no-blocks path, not return early). +pkg2 <- file.path(tempdir(), "prunelast") +if (dir.exists(pkg2)) unlink(pkg2, recursive = TRUE) +dir.create(file.path(pkg2, "R"), recursive = TRUE) +writeLines(c("Package: prunelast", "Title: Test", "Version: 0.1.0"), + file.path(pkg2, "DESCRIPTION")) +writeLines(c("#' Solo", "#' @export", "solo <- function() 1"), + file.path(pkg2, "R", "solo.R")) +tinyrox::document(pkg2, namespace = "none", cran_check = FALSE, silent = TRUE) +expect_true(file.exists(file.path(pkg2, "man", "solo.Rd"))) + +# Remove the only roxygen -> no blocks; the now-stale solo.Rd must be pruned. +writeLines("solo <- function() 1", file.path(pkg2, "R", "solo.R")) +res2 <- tinyrox::document(pkg2, namespace = "none", cran_check = FALSE, + silent = TRUE, prune_rd = TRUE) +expect_false(file.exists(file.path(pkg2, "man", "solo.Rd"))) +expect_equal(basename(res2$pruned), "solo.Rd") + +unlink(pkg2, recursive = TRUE)