Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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")),
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
15 changes: 11 additions & 4 deletions R/rd.R
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
}
Expand Down
15 changes: 15 additions & 0 deletions inst/tinytest/test_rd.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")',
Expand Down
Loading