| Title: | Minimal R Documentation Generator |
|---|---|
| Description: | A deterministic, dependency-free documentation generator for R packages. Generates valid Rd files and NAMESPACE from 'roxygen2'-style comments using only base R. Supports a strict subset of tags with no markdown parsing, no inference magic, and explicit-only behavior. |
| Authors: | Troy Hernandez [aut, cre] (ORCID: <https://orcid.org/0009-0005-4248-604X>) |
| Maintainer: | Troy Hernandez <[email protected]> |
| License: | GPL-3 |
| Version: | 0.3.3.8 |
| Built: | 2026-06-24 16:17:49 UTC |
| Source: | https://github.com/cornball-ai/tinyrox |
Scans R files for common CRAN policy violations. Files are parsed and checked token-wise: comments and string literals are never flagged, print()/cat() are allowed inside print./format. S3 methods, and T/F shorthand is not confused with a local variable named T or F.
check_code_cran(path = ".")check_code_cran(path = ".")
path |
Path to package root directory |
List with issues found
# Create a minimal package in tempdir pkg <- file.path(tempdir(), "mypkg") dir.create(file.path(pkg, "R"), recursive = TRUE, showWarnings = FALSE) writeLines("Package: mypkg\nTitle: Test\nVersion: 0.1.0", file.path(pkg, "DESCRIPTION")) writeLines("add <- function(x, y) x + y", file.path(pkg, "R", "add.R")) check_code_cran(pkg) # Clean up unlink(pkg, recursive = TRUE)# Create a minimal package in tempdir pkg <- file.path(tempdir(), "mypkg") dir.create(file.path(pkg, "R"), recursive = TRUE, showWarnings = FALSE) writeLines("Package: mypkg\nTitle: Test\nVersion: 0.1.0", file.path(pkg, "DESCRIPTION")) writeLines("add <- function(x, y) x + y", file.path(pkg, "R", "add.R")) check_code_cran(pkg) # Clean up unlink(pkg, recursive = TRUE)
Runs the CRAN compliance checks for package code and examples.
check_cran(path = ".")check_cran(path = ".")
path |
Path to package root directory |
List with all issues
# Create a minimal package in tempdir pkg <- file.path(tempdir(), "mypkg") dir.create(file.path(pkg, "R"), recursive = TRUE, showWarnings = FALSE) writeLines("Package: mypkg\nTitle: Test\nVersion: 0.1.0\nDescription: A test package.", file.path(pkg, "DESCRIPTION")) writeLines("add <- function(x, y) x + y", file.path(pkg, "R", "add.R")) check_cran(pkg) # Clean up unlink(pkg, recursive = TRUE)# Create a minimal package in tempdir pkg <- file.path(tempdir(), "mypkg") dir.create(file.path(pkg, "R"), recursive = TRUE, showWarnings = FALSE) writeLines("Package: mypkg\nTitle: Test\nVersion: 0.1.0\nDescription: A test package.", file.path(pkg, "DESCRIPTION")) writeLines("add <- function(x, y) x + y", file.path(pkg, "R", "add.R")) check_cran(pkg) # Clean up unlink(pkg, recursive = TRUE)
Identifies exported functions that lack examples in their documentation.
check_examples_cran(path = ".")check_examples_cran(path = ".")
path |
Path to package root directory |
Character vector of function names missing examples
# Create a minimal package in tempdir pkg <- file.path(tempdir(), "mypkg") dir.create(file.path(pkg, "R"), recursive = TRUE, showWarnings = FALSE) writeLines("Package: mypkg\nTitle: Test\nVersion: 0.1.0", file.path(pkg, "DESCRIPTION")) writeLines("#' Add numbers\n#' @export\nadd <- function(x, y) x + y", file.path(pkg, "R", "add.R")) check_examples_cran(pkg) # Clean up unlink(pkg, recursive = TRUE)# Create a minimal package in tempdir pkg <- file.path(tempdir(), "mypkg") dir.create(file.path(pkg, "R"), recursive = TRUE, showWarnings = FALSE) writeLines("Package: mypkg\nTitle: Test\nVersion: 0.1.0", file.path(pkg, "DESCRIPTION")) writeLines("#' Add numbers\n#' @export\nadd <- function(x, y) x + y", file.path(pkg, "R", "add.R")) check_examples_cran(pkg) # Clean up unlink(pkg, recursive = TRUE)
Removes all Rd files from man/ directory.
clean(path = ".", namespace = FALSE)clean(path = ".", namespace = FALSE)
path |
Path to package root directory. |
namespace |
Also remove NAMESPACE? Default FALSE. |
No return value, called for side effects.
# Create a minimal package in tempdir pkg <- file.path(tempdir(), "mypkg") dir.create(file.path(pkg, "man"), recursive = TRUE, showWarnings = FALSE) writeLines("Package: mypkg\nTitle: Test\nVersion: 0.1.0", file.path(pkg, "DESCRIPTION")) writeLines("placeholder", file.path(pkg, "man", "test.Rd")) clean(pkg) # Clean up unlink(pkg, recursive = TRUE)# Create a minimal package in tempdir pkg <- file.path(tempdir(), "mypkg") dir.create(file.path(pkg, "man"), recursive = TRUE, showWarnings = FALSE) writeLines("Package: mypkg\nTitle: Test\nVersion: 0.1.0", file.path(pkg, "DESCRIPTION")) writeLines("placeholder", file.path(pkg, "man", "test.Rd")) clean(pkg) # Clean up unlink(pkg, recursive = TRUE)
Main function for tinyrox. Parses R source files for documentation comments and generates Rd files and NAMESPACE.
document(path = ".", namespace = c("overwrite", "append", "none"), cran_check = TRUE, silent = FALSE, prune_rd = TRUE)document(path = ".", namespace = c("overwrite", "append", "none"), cran_check = TRUE, silent = FALSE, prune_rd = TRUE)
path |
Path to package root directory. Default is current directory. |
namespace |
How to handle NAMESPACE generation. One of
|
cran_check |
Run CRAN compliance checks (code issues and missing examples) and undocumented-parameter warnings. Default TRUE. |
silent |
Operate less verbose without messages. Default FALSE. |
prune_rd |
Remove stale Rd files for topics no longer documented (e.g. after a rename or deletion)? Only files tinyrox generated are removed; hand-written Rd is never touched. Default TRUE. Set FALSE to leave existing Rd in place. |
Invisibly returns a list with: - rd_files: character vector of generated Rd file paths - pruned: character vector of stale Rd file paths removed - namespace: path to NAMESPACE file (or NULL if mode="none")
# Create a minimal package in tempdir pkg <- file.path(tempdir(), "mypkg") dir.create(file.path(pkg, "R"), recursive = TRUE, showWarnings = FALSE) writeLines("Package: mypkg\nTitle: Test\nVersion: 0.1.0", file.path(pkg, "DESCRIPTION")) writeLines(c( "#' Add two numbers", "#' @param x A number", "#' @param y A number", "#' @export", "add <- function(x, y) x + y"), file.path(pkg, "R", "add.R")) # Document the package document(pkg, cran_check = FALSE) # Clean up unlink(pkg, recursive = TRUE)# Create a minimal package in tempdir pkg <- file.path(tempdir(), "mypkg") dir.create(file.path(pkg, "R"), recursive = TRUE, showWarnings = FALSE) writeLines("Package: mypkg\nTitle: Test\nVersion: 0.1.0", file.path(pkg, "DESCRIPTION")) writeLines(c( "#' Add two numbers", "#' @param x A number", "#' @param y A number", "#' @export", "add <- function(x, y) x + y"), file.path(pkg, "R", "add.R")) # Document the package document(pkg, cran_check = FALSE) # Clean up unlink(pkg, recursive = TRUE)
Extract Function Name from Definition Line
extract_function_name(line)extract_function_name(line)
line |
Code line potentially containing function definition |
Function name or NULL
Parses R file content to find @export tags with \dontrun in @examples.
find_dontrun_examples(lines)find_dontrun_examples(lines)
lines |
Character vector of file lines |
Character vector of function names using dontrun
Parses R file content to find @export tags without @examples.
find_exports_without_examples(lines)find_exports_without_examples(lines)
lines |
Character vector of file lines |
Character vector of function names missing examples
Scans @examples blocks for lines that will be truncated in the PDF manual.
find_long_example_lines(lines, filename)find_long_example_lines(lines, filename)
lines |
Character vector of file lines |
filename |
Filename for reporting |
Character vector of warnings (file:line format)
Parse Tags from Documentation Lines
parse_tags(lines, object_name, file = NULL, line_num = NULL)parse_tags(lines, object_name, file = NULL, line_num = NULL)
lines |
Character vector of documentation lines (without #'). |
object_name |
Name of the documented object. |
file |
Source file (for error messages). |
line_num |
Starting line number (for error messages). |
A list with parsed tag values.
lines <- c("Title Here", "", "Description text.", "", "@param x A number.", "@return The number.", "@export") tags <- parse_tags(lines, "my_function") tags$title tags$paramslines <- c("Title Here", "", "Description text.", "", "@param x A number.", "@return The number.", "@export") tags <- parse_tags(lines, "my_function") tags$title tags$params