Skip to content

ci: Document with a patched roxygen2 that keeps the sentence gap - #610

Closed
krlmlr wants to merge 17 commits into
claude/readme-rmdfrom
claude/roxygen2-fork
Closed

krlmlr wants to merge 17 commits into
claude/readme-rmdfrom
claude/roxygen2-fork

Conversation

@krlmlr

@krlmlr krlmlr commented Sep 13, 2026 •

Copy link
Copy Markdown
Member

Split out of #606 so it can be decided on its own.

The problem

commonmark discards the whitespace a line break stands for. roxygen2 turns every softbreak into a bare newline, so the .Rd carries a line break with nothing after it and Rd2txt() renders it as a single space. Prose written one sentence per line therefore comes out single-spaced, while the same words wrapped to a fixed width with two spaces after the period keep the gap.

That makes the two styles mutually exclusive: splitting a sentence pair separated by two spaces silently drops one of them. That is what forced the very long single roxygen lines this package used to carry, because joining was the only way to keep the gap.

Only the text renderer is affected. Rd2HTML() and Rd2latex() differ by whitespace that HTML and TeX collapse — and LaTeX applies its own sentence spacing regardless. But text is what ?topic shows, so it is the version most people read.

The change

A new composite action, .github/workflows/roxygen2-fork, installs roxygen2 from upstream with the R/ part of krlmlr/roxygen2@f-sentence-spacing applied on top, and R-CMD-check.yaml runs it immediately before the Roxygenize step.

It shallow-clones upstream, fetches the branch, computes the diff against their merge base restricted to R/, and applies it with git apply --3way. Restricting to R/ means an unrelated upstream change to a test fixture cannot fail the documentation step. It aborts if the patch is empty or does not apply, rather than silently installing an unpatched build, and afterwards asserts that what it installed really carries the patch.

Config/roxygen2/version becomes 8.1.0.9100. The .9100 suffix distinguishes a patched build from upstream's own .9000 development builds; if upstream moves, the x.y.z part follows it and the suffix stays. DESCRIPTION is DCF and cannot carry a comment line — read.dcf() rejects one as malformed — so the explanation lives in a Config/cynkra/roxygen2 field.

Why it is a separate pull request

Taking it changes rendered help across the package; leaving it means the reformatting below renders exactly as the package renders today, with one space between sentences. Neither half needs the other to be correct, so they should be able to be decided separately.

man/ is not edited by hand here. The .Rd files are generated output, so CI roxygenises and commits them itself — they arrive on this branch as an automated commit rather than in the hand-written diff. That commit has already landed: 10 regenerated .Rd files are part of this pull request's diff, and the hand-written half stays reviewable on its own.

Upstream

The roxygen2 side is krlmlr/roxygen2#8, on the fork, not yet filed with r-lib. It is deliberately narrow: mid-sentence breaks are untouched, links are unaffected, and two guards keep it from firing wrongly — an abbreviation list so a line ending in e.g. or et al. does not gain a mid-sentence gap, and a fix for a determinism bug where a line starting with \doi{} or \code{} gained or lost its gap at random, because the test was reading roxygen2's own random placeholder for protected Rd tags.

🤖 Generated with Claude Code

https://claude.ai/code/session_01WWhverMTZZKgEpUuTK117m


Generated by Claude Code

krlmlr and others added 10 commits September 14, 2026 07:27
One of the items `usethis::use_tidy_upkeep_issue()` prescribes for 2023.
`pak::pak()` resolves system requirements and installs binaries where they exist,
so it does not need a compiler for pure-R dependencies the way `install_github()` does.

The `# install.packages("pak")` comment is kept, matching what the packages in this fleet that already use pak do.
Both usethis and devtools import pak, so most readers already have it,
but a reader with neither of those installed still needs the line.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WWhverMTZZKgEpUuTK117m
Closes #599.

The badge image was pinned to `branch/master`, which has not existed since the rename to `main`.
Codecov kept serving that branch's last recorded figure while `main` moved on,
so the image disagreed with the link beside it, which already pointed at `main`.

The branch is dropped from the image URL rather than corrected to `main`.
A branch-pinned badge goes stale silently the next time a branch is renamed, which is exactly what happened here;
without one, codecov reports the default branch and the badge follows a rename on its own.

The link becomes `app.codecov.io/gh/r-dbi/RPostgres/tree/main`:
the `app.` host is the UI (the bare host serves the badge image),
`/gh/` is the canonical short form,
and `/tree/main` is the branch view rather than the `?branch=` query that redirects to it.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WWhverMTZZKgEpUuTK117m
Reformatting only, no wording changes: prose in README.md, the
vignette and the roxygen and inline comments under R/ now breaks at
sentence and clause boundaries rather than wrapping to a fixed width.

The payoff is sentence-level diffs. A reworded sentence touches one
line instead of reflowing the paragraph around it, so review sees the
change and not the rewrap.

man/*.Rd is regenerated because roxygen2 passes source line breaks
through to the .Rd. The rendered help is byte-identical -- checked with
tools::Rd2txt() over every topic -- as is the rendered README.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WWhverMTZZKgEpUuTK117m
A sentence that spans more than one line now starts at the beginning of
a line, and so does the sentence after it. Line breaks only, no wording
changes.

Where two sentences are separated by two spaces, the pair stays on one
long line: roxygen2 strips leading and trailing whitespace from
continuation lines, so a break at that gap would drop a space from the
rendered help.

man/*.Rd is regenerated because roxygen2 passes source line breaks
through to the .Rd. The rendered help is byte-identical -- checked with
tools::Rd2txt() over every topic.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WWhverMTZZKgEpUuTK117m
Inside a roxygen block the first line of a paragraph, and every tag line,
keeps one space after `#'`; every continuation line of that paragraph now
has two. The paragraph structure of the source becomes visible without
reading ahead, and in packages that do not enable roxygen2 markdown the
extra space is what carries a sentence gap across a line break.

RPostgres enables markdown (`Roxygen: list(markdown = TRUE)`), and commonmark
strips leading whitespace from a paragraph's continuation lines, so here
the indent reaches neither `man/*.Rd` nor the rendered help. Nothing is
regenerated: roxygen2 writes no file, and `tools::Rd2txt()` is unchanged
for every topic.

That also means the one long line this pass created cannot come apart
again. `R/dbConnect_PqDriver.R` keeps the sentence pair that the
previous commit joined on a single line, because under markdown no
leading-space, trailing-space or hard-break form survives into the
`.Rd`, so breaking there would drop a space from the rendered help.

The generated `R/cpp11.R` is left untouched.

Reformatting only, no wording changes: the words either side of the diff
are identical once comment markers and whitespace are collapsed.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WWhverMTZZKgEpUuTK117m
The two-space continuation indent never reached the `.Rd`. RPostgres sets
`Roxygen: list(markdown = TRUE)`, and commonmark strips the leading
whitespace of a continuation line before roxygen2 writes the topic, so the
indent changed no rendered output -- `man/` was byte-identical with it and
without it.

The sentence gap it was meant to carry now comes from roxygen2 itself
(krlmlr/roxygen2#8), which indents the line break after a sentence at the
point where the break is emitted. The source-level indent is redundant, so
it comes out.

This is `git revert` of the indent commit, not a substitution: that pass also
normalised pre-existing three-space tag continuations down to two, and the
revert puts them back at three.

The long joined lines the sembr pass created stay as they are. Undoing those
is a separate decision, and the roxygen2 fix is what will eventually let them
come apart.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WWhverMTZZKgEpUuTK117m
The long joined lines existed to protect a sentence gap:
two spaces after a sentence period are content, Rd2txt() renders them literally, and a line break there drops one of them.
Joining the sentences onto one line was the only way to keep the gap.

The joins come out, so every sentence starts its own line again.

Reformatting only, no wording changes.

man/ is left to CI, which regenerates it from these sources.

A line break which follows the end of a sentence currently renders as one space rather than two.
Restoring that gap needs a patched roxygen2, which is a separate decision and a separate pull request,
so it is deliberately not part of this change.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WWhverMTZZKgEpUuTK117m
Scope drawn from the README's own opening and its "Design notes" section
("This turns out to be too general: a driver has no real state, for PostgreSQL
each connection can only have one result set ... the driver class is just a
dummy class with no contents"), the DESCRIPTION (Imports DBI, bit64, blob, hms,
lubridate; SystemRequirements names libpq >= 9.0), the exported
PostgreSQL-specific helpers in NAMESPACE (postgresWaitForNotify(),
postgresImportLargeObject(), Redshift()), and tests/testthat/test-DBItest.R,
which runs DBItest::test_all().

The type-mapping goal claims a best fit rather than a lossless one.
src/PqResultImpl.cpp maps NUMERIC and MONEY to double, and INTERVAL and UUID to character,
so "without losing information" would not hold.

The Redshift non-goal names BLOBs only, which tests/testthat/helper-DBItest.R
still records as `omit_blob_tests = TRUE` in its Redshift context.
NEWS.md 1.4.0 also reported limitations enumerating temporary and persistent tables,
but 1.4.3 supersedes that entry: "Temporary tables are now discovered correctly
for `Redshift()` connections, all DBItest tests pass".

The "does not bundle a client library" non-goal says that no libpq source ships with the package,
rather than that the build relies on the system libpq.
The latter holds on Unix only: tools/winlibs.R downloads a prebuilt libpq on Windows,
and configure falls back to autobrew on macOS.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WWhverMTZZKgEpUuTK117m
The hand-written `README.md` keeps the package out of the shared rendering pipeline,
so this adds a `README.Rmd` copied from it verbatim,
prefixed with the `cynkratemplate::readme_document` front matter and the canonical generated-file comment.

Rendering with `cynkratemplate::render_readme()` also writes `index.md` for pkgdown,
which is the `README.md` without the code-of-conduct footer.
Both `README.Rmd` and `index.md` are added to `.Rbuildignore` so neither ships in the tarball.

The rendered `README.md` differs from the hand-written one only in pandoc's gfm normalisations:
the generated-file comment, `*` bullets written as `-`, ` ```R ` written as ` ``` r `,
blank lines inserted around headings and `<!-- badges: start -->`, trailing whitespace stripped,
and `---` written as a full-width row of hyphens.
No word, URL, or code-block content changes.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WWhverMTZZKgEpUuTK117m
krlmlr and others added 3 commits September 14, 2026 05:46
commonmark discards the whitespace a line break stands for, so roxygen prose written
one sentence per line loses the gap between sentences in the rendered help.
Only the text renderer is affected, which is what `?topic` shows.

A new composite action installs roxygen2 from upstream with the R/ part of
krlmlr/roxygen2@f-sentence-spacing applied on top, and runs just before the
Roxygenize step. It shallow-clones upstream, fetches the branch, applies the diff
restricted to R/ so conflicts in the test files cannot fail it, and aborts rather
than silently installing an unpatched build. It then asserts that what it installed
really carries the patch.

Config/roxygen2/version becomes 8.1.0.9100. The .9100 suffix distinguishes a patched
build from upstream's own .9000 development builds; if upstream moves, the x.y.z part
follows it and the suffix stays. DESCRIPTION is DCF and cannot carry a comment, so the
explanation lives in a Config/cynkra/roxygen2 field.

This is a separate decision from the line-break reformatting below it, and is kept in
its own pull request so it can be taken or left on its own. Without it, the
reformatting simply renders as it does today, with one space between sentences.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WWhverMTZZKgEpUuTK117m
…l escape

The version stamp passed `"\1"` as the replacement in the `sub()` call that derives the `.9100` build number.
R parses `"\1"` in a string literal as the octal escape for `\001`, not as a regex backreference,
so `DESCRIPTION` received a control character where the `x.y.z` prefix belonged,
and `R CMD INSTALL` aborted with "Malformed package version".
The replacement is now `"\\1"`, which reaches the regex engine as a backreference and stamps `8.1.0.9000` to `8.1.0.9100`.

The post-install guard asserted only the `.9100` suffix, which the corrupt `"\001.9100"` also satisfies.
That is why the bug survived the very check that was meant to catch it.
The guard now asserts the whole `x.y.z.9100` shape, and passes `inherits = FALSE` to `exists()`.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WWhverMTZZKgEpUuTK117m
@krlmlr
krlmlr force-pushed the claude/roxygen2-fork branch from cc34665 to 37a3d78 Compare September 14, 2026 05:46
krlmlr and others added 3 commits September 14, 2026 16:37
commonmark discards the whitespace a line break stands for, so roxygen prose written
one sentence per line loses the gap between sentences in the rendered help.
Only the text renderer is affected, which is what `?topic` shows.

A new composite action installs roxygen2 from upstream with the R/ part of
krlmlr/roxygen2@f-sentence-spacing applied on top, and runs just before the
Roxygenize step. It shallow-clones upstream, fetches the branch, applies the diff
restricted to R/ so conflicts in the test files cannot fail it, and aborts rather
than silently installing an unpatched build. It then asserts that what it installed
really carries the patch.

Config/roxygen2/version becomes 8.1.0.9100. The .9100 suffix distinguishes a patched
build from upstream's own .9000 development builds; if upstream moves, the x.y.z part
follows it and the suffix stays. DESCRIPTION is DCF and cannot carry a comment, so the
explanation lives in a Config/cynkra/roxygen2 field.

This is a separate decision from the line-break reformatting below it, and is kept in
its own pull request so it can be taken or left on its own. Without it, the
reformatting simply renders as it does today, with one space between sentences.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WWhverMTZZKgEpUuTK117m
…l escape

The version stamp passed `"\1"` as the replacement in the `sub()` call that derives the `.9100` build number.
R parses `"\1"` in a string literal as the octal escape for `\001`, not as a regex backreference,
so `DESCRIPTION` received a control character where the `x.y.z` prefix belonged,
and `R CMD INSTALL` aborted with "Malformed package version".
The replacement is now `"\\1"`, which reaches the regex engine as a backreference and stamps `8.1.0.9000` to `8.1.0.9100`.

The post-install guard asserted only the `.9100` suffix, which the corrupt `"\001.9100"` also satisfies.
That is why the bug survived the very check that was meant to catch it.
The guard now asserts the whole `x.y.z.9100` shape, and passes `inherits = FALSE` to `exists()`.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WWhverMTZZKgEpUuTK117m
@krlmlr
krlmlr force-pushed the claude/roxygen2-fork branch from 37a3d78 to 1226d40 Compare September 14, 2026 14:37
@krlmlr
krlmlr marked this pull request as draft September 26, 2026 14:46
@krlmlr

krlmlr commented Nov 27, 2026

Copy link
Copy Markdown
Member Author

Closing: this depended on cynkra/cynkratemplate#131, which was closed on purpose, so this change can no longer land as it is.

@krlmlr krlmlr closed this Nov 27, 2026
An error occurred while trying to automatically change base from claude/readme-rmd to main November 29, 2026 19:04
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.

2 participants