diff --git a/DESCRIPTION b/DESCRIPTION index eb76ff3..572f576 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: tinyrox Title: Minimal R Documentation Generator -Version: 0.4.1.2 -Date: 2026-08-31 +Version: 0.4.1.3 +Date: 2026-10-05 Authors@R: c( person("Troy", "Hernandez", email = "troy@cornball.ai", role = c("aut", "cre"), comment = c(ORCID = "0009-0005-4248-604X")), diff --git a/NEWS.md b/NEWS.md index c7145e8..fb1ec6d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +# tinyrox 0.4.1.3 + +* A replacement S3 method (`$<-.myclass`, `[[<-.myclass`, `dim<-.myclass`) was given the usage `\method{$<-}{myclass}(x, name, value)`, which `R CMD check` reports as a bad `\usage` line: the `<-` sits on the generic, not at the end of the name, so the replacement test never fired. It is `\method{$}{myclass}(x, name) <- value` now, as for a plain replacement function. Found in glinty's two output-registration methods. + # tinyrox 0.4.1.2 * Datasets are documented. A block over a bare `"name"` line (the roxygen data convention) used to be dropped silently: no Rd, no warning, and `R CMD check` then reported the dataset undocumented. The directive now parses like the `"_PACKAGE"` sentinel, `@format` and `@source` are supported tags (an author's `@format` wins over the auto-introspected one), and data pages carry `\source{}`. Found standing up examen's `are` dataset. diff --git a/R/rd.R b/R/rd.R index 87f6765..34fb541 100644 --- a/R/rd.R +++ b/R/rd.R @@ -371,11 +371,18 @@ escape_rd <- function(text) { #' @return Formatted usage string. #' @keywords internal format_usage <- function(name, args, pkg_generics = character()) { - # Check if it's a replacement function (name ends with <-) - is_replacement <- grepl("<-$", name) - # Check if it's an S3 method s3_info <- detect_s3_method(name, pkg_generics) + + # A replacement function's name ends with <-; a replacement S3 + # method's generic does, with the class after it (`$<-.myclass`), + # so the test is on the generic when there is one. + if (!is.null(s3_info)) { + is_replacement <- grepl("<-$", s3_info$generic) + } else { + is_replacement <- grepl("<-$", name) + } + if (!is.null(s3_info)) { gen_display <- s3_info$generic if (is_replacement) { @@ -404,7 +411,7 @@ format_usage <- function(name, args, pkg_generics = character()) { # and the replacement suffix are excluded, leaving headroom under the # 90-character Rd limit for the markup they add. if (is_replacement) { - bare_name <- sub("<-$", "", name) + bare_name <- sub("<-", "", name, fixed = TRUE) } else { bare_name <- name } diff --git a/inst/tinytest/test_rd.R b/inst/tinytest/test_rd.R index bd894d2..a5102f3 100644 --- a/inst/tinytest/test_rd.R +++ b/inst/tinytest/test_rd.R @@ -283,6 +283,21 @@ repl_usage <- tinyrox:::format_usage("dim<-", repl_args) expect_equal(repl_usage, paste0("dim(\n x,\n ", strrep("y", 80), "\n) <- value")) +# A replacement S3 method: the `<-` sits on the generic, not at the end +# of the name, and R CMD check wants the generic without it and value on +# the right (`\method{$}{cls}(x, name) <- value`), never +# `\method{$<-}{cls}(x, name, value)`. +expect_equal(tinyrox:::format_usage("$<-.myclass", c("x", "name", "value")), + "\\method{$}{myclass}(x, name) <- value") +expect_equal(tinyrox:::format_usage("[[<-.myclass", c("x", "i", "value")), + "\\method{[[}{myclass}(x, i) <- value") +expect_equal(tinyrox:::format_usage("dim<-.myclass", c("x", "value")), + "\\method{dim}{myclass}(x) <- value") +# and a replacement generic defined in the package itself +expect_equal(tinyrox:::format_usage("label<-.myclass", c("x", "value"), + pkg_generics = "label<-"), + "\\method{label}{myclass}(x) <- value") + # wrap_usage_arg: quoted strings are never broken expect_equal( tinyrox:::wrap_usage_arg(' x = c("a b c d e f", "g h i", "j k l")',