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.1
Date: 2026-08-04
Version: 0.4.1.2
Date: 2026-08-31
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.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.

# tinyrox 0.4.1.1

* Rd file names are portable for every topic, not just `%op%` and a leading dot. `$.foo`, `[[.foo` and `$<-.foo` are ordinary S3 methods, and the files named after them were being **dropped from the tarball**: `R CMD build` prints "excluding invalid files" and carries on, and the `R CMD check` that follows reads a tarball those files are no longer in, so nothing fails. glinty shipped four undocumented S3 methods that way with every CI job green.
Expand Down
10 changes: 10 additions & 0 deletions R/parse.R
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,16 @@ parse_object_definition <- function(text, file, line_num) {
return(list(name = "_PACKAGE", type = "package", formals = NULL))
}

# Quoted-string directive: a bare "name" (or 'name') line after the
# block documents the dataset `name` (the roxygen convention for
# data documentation). Without this the block is dropped silently,
# since a string literal matches no assignment pattern below.
fl <- trimws(first_line)
if (grepl('^"[^"]+"$', fl) || grepl("^'[^']+'$", fl)) {
return(list(name = substr(fl, 2L, nchar(fl) - 1L), type = "data",
formals = NULL))
}

# Match: name <- or name =
# Handles: foo <- function(...), foo <- value, foo = function(...)
# Also handles backtick-quoted names: `%||%` <- function(...)
Expand Down
19 changes: 16 additions & 3 deletions R/rd.R
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,16 @@ generate_data_rd <- function(tags, source_file = NULL, format_string = NULL) {
}
lines <- c(lines, paste0("\\title{", escape_rd(title), "}"))

# Format section (roxygen2 auto-generates this)
if (!is.null(format_string)) {
# Format section: an author's @format wins; otherwise fall back to
# the auto-generated description of the object (roxygen2 behavior)
if (!is.null(tags$format)) {
fmt <- escape_rd(tags$format)
} else {
fmt <- format_string
}
if (!is.null(fmt)) {
lines <- c(lines, "\\format{")
lines <- c(lines, format_string)
lines <- c(lines, fmt)
lines <- c(lines, "}")
}

Expand Down Expand Up @@ -226,6 +232,13 @@ generate_data_rd <- function(tags, source_file = NULL, format_string = NULL) {
lines <- c(lines, "}")
}

# Source (where the data came from)
if (!is.null(tags$source)) {
lines <- c(lines, "\\source{")
lines <- c(lines, escape_rd(tags$source))
lines <- c(lines, "}")
}

# Examples (before seealso like roxygen2)
if (!is.null(tags$examples) && nchar(trimws(tags$examples)) > 0) {
lines <- c(lines, "\\examples{")
Expand Down
9 changes: 8 additions & 1 deletion R/tags.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ SUPPORTED_DOC_TAGS <- c("title", "description", "details", "param",
"return", "returns", "value", "examples",
"example", "seealso", "references", "aliases",
"keywords", "family", "name", "rdname", "noRd",
"inheritParams", "section", "author")
"inheritParams", "section", "author", "format",
"source")

#' Supported Namespace Tags
#'
Expand Down Expand Up @@ -227,6 +228,12 @@ save_tag <- function(result, tag, arg, accumulator, file, line_num) {
},
"references" = {
result$references <- value
},
"format" = {
result$format <- value
},
"source" = {
result$source <- value
},
"aliases" = {
# Split on whitespace
Expand Down
25 changes: 25 additions & 0 deletions inst/tinytest/test_parse.R
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,28 @@ expect_warning(blocks <- tinyrox:::parse_file(tmp),
expect_equal(length(blocks), 1)
expect_equal(blocks[[1]]$object, "real_fn")
unlink(tmp)

# Quoted-string data directive: a block over a bare "name" line documents
# the dataset `name` (roxygen convention). Both quote styles; the
# _PACKAGE sentinel keeps its own type and must not be shadowed.
tmp <- tempfile(fileext = ".R")
writeLines(c(
"#' My dataset",
"#'",
"#' @format A data frame.",
"\"mydata\"",
"",
"#' Single-quoted dataset",
"'otherdata'",
"",
"#' The package",
"\"_PACKAGE\""
), tmp)
blocks <- tinyrox:::parse_file(tmp)
expect_equal(length(blocks), 3)
expect_equal(blocks[[1]]$object, "mydata")
expect_equal(blocks[[1]]$type, "data")
expect_equal(blocks[[2]]$object, "otherdata")
expect_equal(blocks[[2]]$type, "data")
expect_equal(blocks[[3]]$type, "package")
unlink(tmp)
51 changes: 51 additions & 0 deletions inst/tinytest/test_rd.R
Original file line number Diff line number Diff line change
Expand Up @@ -395,3 +395,54 @@ test_package_sentinel_document <- function() {
expect_equal(res2$pruned, character(0))
}
test_package_sentinel_document()

# --- Data documentation through the full document() flow: the "name" ---
# directive plus @format and @source. Regression: the block used to be
# dropped silently (no Rd, no warning), leaving the dataset undocumented.
test_data_directive_document <- function() {
pkg <- file.path(tempdir(), "datapkg")
on.exit(unlink(pkg, recursive = TRUE), add = TRUE)
dir.create(file.path(pkg, "R"), recursive = TRUE, showWarnings = FALSE)
writeLines(c(
"Package: datapkg", "Title: T", "Version: 0.0.1",
"Description: D.",
"Authors@R: person('A', 'B', email='a@b.c', role=c('aut','cre'))"
), file.path(pkg, "DESCRIPTION"))
writeLines(c(
"#' Example measurements",
"#'",
"#' Twelve made-up observations.",
"#'",
"#' @format A data frame with 12 rows and 2 columns:",
"#' \\describe{",
"#' \\item{x}{Numeric. The measurement.}",
"#' \\item{g}{Character. The group.}",
"#' }",
"#' @source Simulated for the test.",
"#' @examples",
"#' str(measurements)",
"\"measurements\""),
file.path(pkg, "R", "data.R"))

# No warnings: @format and @source are supported tags, not unknowns.
expect_silent(tinyrox::document(pkg, cran_check = FALSE, silent = TRUE))

rd_path <- file.path(pkg, "man", "measurements.Rd")
expect_true(file.exists(rd_path))
rd <- readLines(rd_path)
expect_true("\\docType{data}" %in% rd)
expect_true("\\alias{measurements}" %in% rd)
expect_true("\\keyword{datasets}" %in% rd)
# The author's @format survives, markup intact, over the auto fallback
expect_true(any(grepl("12 rows and 2 columns", rd)))
expect_true(any(grepl("\\item{x}{Numeric. The measurement.}", rd,
fixed = TRUE)))
# @source is rendered
expect_true("\\source{" %in% rd)
expect_true(any(grepl("Simulated for the test.", rd, fixed = TRUE)))
# Usage is the bare object name, and the dataset is not exported
expect_true("measurements" %in% rd)
ns <- readLines(file.path(pkg, "NAMESPACE"))
expect_false(any(grepl("measurements", ns, fixed = TRUE)))
}
test_data_directive_document()
2 changes: 1 addition & 1 deletion man/SUPPORTED_DOC_TAGS.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
\alias{SUPPORTED_DOC_TAGS}
\title{Supported Documentation Tags}
\format{
An object of class \code{character} of length 20.
An object of class \code{character} of length 22.
}
\usage{
SUPPORTED_DOC_TAGS
Expand Down
2 changes: 1 addition & 1 deletion man/SUPPORTED_TAGS.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
\alias{SUPPORTED_TAGS}
\title{All Supported Tags}
\format{
An object of class \code{character} of length 26.
An object of class \code{character} of length 28.
}
\usage{
SUPPORTED_TAGS
Expand Down
Loading