Skip to content

Wrap overlong \usage lines roxygen2-style - #32

Merged
TroyHernandez merged 4 commits into
mainfrom
fix/usage-line-width
Aug 4, 2026
Merged

TroyHernandez merged 4 commits into
mainfrom
fix/usage-line-width

Conversation

@TroyHernandez

Copy link
Copy Markdown
Contributor

Closes #29.

Problem

format_usage() wrapped only between arguments, so a single argument with a long default (a multi-value c(...) choice vector, a Sys.getenv("LONG_NAME", "") default) produced \usage lines past 90 characters and an R CMD check NOTE. This blocked llm.api 0.1.9 release prep.

Fix

Adopt roxygen2's algorithm exactly:

  • Single line when the bare call (plain name, no \method markup, no <- value suffix) is under 80 characters.
  • Otherwise one argument per line at two-space indent, each overlong argument broken at spaces outside quoted strings to the 90-character limit with four-space continuation indent (new wrap_usage_arg() helper).
  • The width decision on the bare name leaves headroom under 90 for \method{}{} markup and the replacement suffix, matching roxygen2.

wrap_usage_arg() was fuzz-verified byte-identical to roxygen2's C++ wrapUsage() on 1134 cases (real llm.api signatures, quoted strings with spaces, naive-escape behavior, backticks, random char soups, widths 12-90). The end-to-end \usage block for the issue's repro matches roxygen2 output byte-for-byte.

Verification

  • 222 tinytest results pass, including new regression tests for the long-default wrap, the 80-char boundary, S3 method measurement, replacement functions, and quoted-string integrity.
  • Ran the new tinyrox against llm.api: the five previously NOTE'd files (agent, chat, chat_session, create_agent, anthropic_claude_credentials) regenerate wrapped, and tools:::.check_Rd_line_widths() comes back clean.

Note on branch contents

This branch also merges in 797fb23 (Prepare CRAN release 0.4.0), which was on the local release-0.4.0 branch and never made it back to main after CRAN acceptance — main still said 0.3.3.8. Once main is fast-forwarded to 797fb23 (git push origin release-0.4.0:main from the local checkout), this PR shrinks to just the #29 commits. Version bumped to 0.4.0.1.

format_usage() previously wrapped only between arguments, so a single
argument with a long default (a multi-value c(...) or Sys.getenv())
produced \usage lines wider than 90 characters and an R CMD check NOTE.

Adopt roxygen2's algorithm: single line when the bare call is under 80
characters, otherwise one argument per line at two-space indent, with
each overlong argument broken at spaces outside quoted strings to the
90-character Rd limit (new wrap_usage_arg() helper, fuzz-verified
byte-identical to roxygen2's wrapUsage across 1100+ cases). The width
decision is made on the bare name so \method markup and the
replacement-function suffix keep headroom, also matching roxygen2.
@TroyHernandez
TroyHernandez merged commit d638b18 into main Aug 4, 2026
2 checks passed
@TroyHernandez
TroyHernandez deleted the fix/usage-line-width branch August 4, 2026 21:15
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.

document() emits \usage lines >90 chars for long arg defaults (Rd line-width NOTE)

1 participant