Skip to content

Rd file names R CMD build will not throw away - #36

Merged
TroyHernandez merged 1 commit into
mainfrom
fix/rd-filenames
Aug 6, 2026
Merged

TroyHernandez merged 1 commit into
mainfrom
fix/rd-filenames

Conversation

@TroyHernandez

Copy link
Copy Markdown
Contributor

Reported against glinty:

Subdirectory 'man' contains invalid file names:
  ‘$.glinty_input.Rd’ ‘$<-.glinty_output.Rd’ ‘[[.glinty_input.Rd’
  ‘[[<-.glinty_output.Rd’

Why this is worse than a NOTE

R CMD build does not fail on those names. It prints * excluding invalid files and drops them from the tarball. The R CMD check that follows then reads a tarball those files are no longer in, so it has nothing to report.

glinty shipped four undocumented S3 methods that way, with four green CI jobs over it. Confirmed both directions:

before:  $.glinty_input -> 0 Rd files in the tarball
after:   $.glinty_input -> 1

The fix

write_rd() sanitized exactly two shapes — a leading dot, and %op% — and left every other name to chance. $.foo, [[.foo and $<-.foo are ordinary S3 methods.

rd_filename() applies roxygen2's substitution table. Two reasons for using theirs rather than inventing one:

  • a package moving between the two tools does not churn its man directory;
  • the two cases tinyrox already handled come out spelled exactly as before — %||% is still grapes-or-or-grapes, .onLoad still dot-onLoad — so this renames nothing that was already working.

The \name{} inside the file keeps the real topic, so help resolves under it either way; only the file on disk is renamed.

document() now refuses outright if a name it just wrote would still be dropped. A failure that is silent in both directions deserves something that says no.

Tests

135 assertions in test_rd_filenames.R: the four reported names, the two that must not change, ordinary names left alone, the rest of the operator table, and a sweep over 27 awkward topics asserting each result is portable, has no leading dot or dangling separator, and that no two topics collide. Plus an end-to-end write through write_rd() checking the name it actually lands under.

Suite: 374 assertions, 0 failures.

write_rd() sanitized two shapes -- a leading dot, and %op% -- and left
everything else to chance. `$.foo`, `[[.foo` and `$<-.foo` are
ordinary S3 methods, and the files named after them are not legal
file names on every platform R runs on.

R CMD build does not fail on those. It prints

    * excluding invalid files
    Subdirectory 'man' contains invalid file names: ...

and carries on, and the R CMD check that follows reads a tarball those
files are no longer in, so it has nothing to report. glinty shipped
four undocumented S3 methods that way with four green CI jobs over it.
The report came from a human running R CMD build by hand.

rd_filename() applies roxygen2's substitution table, so a package
moving between the two tools does not churn its man directory, and the
two cases tinyrox already handled come out spelled exactly as they
were: %||% is still grapes-or-or-grapes, .onLoad still dot-onLoad. The
\name{} inside the file keeps the real topic, so help resolves under
it either way.

document() also refuses now if a name it just wrote would still be
dropped. A silent failure in both directions deserves something that
says no.
@TroyHernandez
TroyHernandez merged commit ab233e7 into main Aug 6, 2026
2 checks passed
@TroyHernandez
TroyHernandez deleted the fix/rd-filenames branch August 6, 2026 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant