Thanks to visit codestin.com
Credit goes to github.com

Skip to content

refactor: extract docgen env prep into a shared package - #26827

Merged
nickvigilante merged 4 commits into
mainfrom
vigilante/docs-497-extract-docgen-env-prep-into-a-shared-package-dedupe
Jul 8, 2026
Merged

refactor: extract docgen env prep into a shared package#26827
nickvigilante merged 4 commits into
mainfrom
vigilante/docs-497-extract-docgen-env-prep-into-a-shared-package-dedupe

Conversation

@nickvigilante

@nickvigilante nickvigilante commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

What

clidocgen and the new configdocgen (#26824) both carried a byte-identical prepareEnv() that unsets CODER_* and pins CLIDOCGEN_* / TMPDIR so generated docs don't embed the generating host's home directory.

This extracts it to scripts/docgenenv.Prepare() and migrates clidocgen.

Why

Duplication flagged during review of #26824. configdocgen adopts the shared helper in that PR, removing its copy.

Risk

Behavior-preserving: regenerating the CLI reference (make docs/reference/cli/index.md) yields no diff, and make pre-commit passes (lint/go, lint/ts, build). A focused unit test pins the Prepare() contract, and _test.go files are excluded from CLIDOCGEN_INPUTS so test edits don't mark the generated docs stale.

CI status — blocked by an unrelated main breakage (#24993)

All red checks on this PR are inherited from main, not caused by these changes. This PR touches only Makefile and scripts/{clidocgen,docgenenv}; it does not touch Helm.

main went red at d0f68cb9b0 ("feat: add listenerset", #24993, merged ~18:26 UTC). The committed helm/coder/tests/testdata/listenerset*.golden files don't match what helm template renders, so:

  • gen regenerates those goldens, and the unstaged-files check fails.
  • test-go-pg (ubuntu-latest, pg-17) and test-go-race-pg fail only on TestRenderChart/{coder,default}/listenerset[_redirect] (golden mismatch; the test prints "Run with -update to update golden files"). The same test-go-pg job passes on macOS and Windows, where the Helm render test is skipped, and scripts/docgenenv reports ok on the failing runners.

Base commit 14a61041d9 was green; main is red from d0f68cb9b0 onward. These checks clear once main is fixed and this branch is updated. fmt, lint, Storybook, check-build, and test-e2e are green.


🤖 Opened by Coder Agents on behalf of @nickvigilante.

clidocgen and configdocgen both carried a byte-identical prepareEnv that
unsets CODER_* and pins CLIDOCGEN_*/TMPDIR so generated docs do not depend
on the host. Move it to scripts/docgenenv.Prepare and migrate clidocgen;
configdocgen adopts it separately (#26824).

Generated CLI reference output is unchanged.
@linear-code

linear-code Bot commented Jun 29, 2026

Copy link
Copy Markdown

DOCS-497

@nickvigilante

Copy link
Copy Markdown
Contributor Author

/coder-agents-review

@coder-agents-review

coder-agents-review Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Chat: Review posted | View chat
Requested: 2026-06-29 18:37 UTC by @nickvigilante
Spend: $28.53 / $100.00

Review history
  • R1 (2026-06-29): 13 reviewers, 2 Nit, 1 Note, 1 P4, COMMENT. Review
  • R2 (2026-06-29): 13 reviewers, 3 Nit, 1 Note, 1 P4, COMMENT. Review
  • R3 (2026-06-29): 13 reviewers, 3 Nit, 1 Note, 1 P4, APPROVE. Review

deep-review v0.9.0 | Round 3 | 14a6104..26837ec

Last posted: Round 3, 5 findings (1 P4, 3 Nit, 1 Note), APPROVE. Review

Finding inventory

Findings

# Sev Status Location Summary Round Reviewer Posted
CRF-1 Nit Author fixed (b8cfb7d) docgenenv.go:1 Package doc slightly verbose R1 Gon (P2 downgraded) Yes
CRF-2 Nit Author fixed (b8cfb7d) docgenenv.go:10 Function doc exposes internal details caller doesn't need R1 Gon (P2 downgraded) Yes
CRF-3 Note Author accepted R2 (out of scope, renaming touches consumers) docgenenv.go:24 CLIDOCGEN_ prefix in shared package may confuse readers R1 Gon Yes
CRF-4 P4 Author fixed (b8cfb7d) docgenenv.go:13 Exported Prepare() has no unit test (pre-existing gap) R1 Bisky Yes
CRF-5 Nit Author fixed (26837ec) docgenenv_test.go:14 Test comment carries redundant tail clause R2 Gon (P2 downgraded) Yes

Contested and acknowledged

CRF-3 (Note, docgenenv.go:24) - CLIDOCGEN_ prefix in shared package

  • Finding: Shared docgenenv package pins CLIDOCGEN_*-prefixed env vars, which may confuse readers into thinking they are CLI-specific. They are consumed universally by cli/config/file.go and codersdk/deployment.go.
  • Author accepted: Leaving names as-is because renaming would touch cli/config/file.go (DefaultDir) and codersdk/deployment.go, out of scope for a behavior-preserving extraction. Original finding noted this is not actionable here.

Round log

Round 1

Panel (13 reviewers + Netero). 0 P2, 0 P3, 1 P4, 2 Nit, 1 Note. Gon P2s downgraded to Nit (accurate comments, stylistic preference, not defects). Reviewed against 14a6104..9864d22.

Round 2

Churn guard: PROCEED. 3 fixed (b8cfb7d), 1 acknowledged (CRF-3). Panel (13 reviewers + Netero). All R1 fixes verified by 7 reviewers. 1 new Nit (CRF-5, Gon P2 downgraded). Reviewed against 14a6104..b8cfb7d.

Round 3

Churn guard: PROCEED. CRF-5 fixed (26837ec). All findings resolved. Panel (13 reviewers + Netero). Zero new findings. All prior fixes verified. Reviewed against 14a6104..26837ec.

About deep-review

CRF = Coder Review Finding (P0-P4, Nit, Note)

Reviewer Focus
Bisky tests
Chopper ops/errors
Churn-guard change verification
Ging language modernization
Gon naming
Hisoka edge cases
Killua perf
Kite change integrity
Knov contracts
Knuckle SQL
Komugi flake/determinism
Kurapika security
Law decomposition
Leorio docs
Luffy product
Mafu-san process
Mafuuu contracts
Melody dispatch/pairing
Meruem structural
Nami frontend
Netero mechanical checks
Pariston premise testing
Pen-botter product gaps
Razor verification
Robin duplication
Ryosuke Go arch
Takumi concurrency
Zoro shape

🤖 Managed by Coder Agents.

@coder-agents-review coder-agents-review Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean extraction. The deduplication is well-motivated (byte-identical prepareEnv() in two generators), the fix is proportional, and the behavior is preserved. 13 reviewers and a first-pass scan found only style nits and one observation.

Severity count: 0 P0-P3, 1 P4, 2 Nit, 1 Note.

"I tried to build a case against this and could not. The problem is correctly understood, the solution is proportional, and the fix is at the right causal level." (Pariston)

🤖 This review was automatically generated with Coder Agents.

Comment thread scripts/docgenenv/docgenenv.go Outdated
Comment thread scripts/docgenenv/docgenenv.go
Comment thread scripts/docgenenv/docgenenv.go
Comment thread scripts/docgenenv/docgenenv.go
Address coder-agents-review feedback on the docgen env extraction:

- Add a focused unit test pinning the Prepare contract: CODER_* cleared,
  cache/config/temp directories pinned.
- Trim the package and Prepare doc comments to the behavioral contract,
  dropping internal stdlib detail.
- Keep _test.go files out of CLIDOCGEN_INPUTS so test changes don't mark
  the generated CLI docs stale.
@nickvigilante

Copy link
Copy Markdown
Contributor Author

/coder-agents-review

@coder-agents-review coder-agents-review Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All R1 findings addressed. CRF-1, CRF-2, CRF-4 fixed in b8cfb7d; CRF-3 acknowledged as out of scope. Test addition is well-constructed: hermetic env restore via t.Setenv, correct //nolint:paralleltest annotation, covers both clearing and pinning behaviors.

One new nit on the test comment below. Otherwise this is ready.

"I tried to build a case against this and could not." (Pariston, for the second time)

🤖 This review was automatically generated with Coder Agents.

Comment thread scripts/docgenenv/docgenenv_test.go Outdated
@nickvigilante

Copy link
Copy Markdown
Contributor Author

/coder-agents-review

@coder-agents-review coder-agents-review Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All findings resolved across three rounds. CRF-1/2/4 fixed in b8cfb7d, CRF-3 acknowledged (out of scope), CRF-5 fixed in 26837ec. 14 reviewers found zero new issues on this final pass.

Clean extraction, proportional to the problem, well-tested, behavior-preserving.

"I tried to build a case against this and couldn't. The problem is correctly understood, the solution is proportional, and the fix is at the right level." (Pariston, third pass)

🤖 This review was automatically generated with Coder Agents.

@nickvigilante
nickvigilante marked this pull request as ready for review July 8, 2026 15:12
Comment thread scripts/docgenenv/docgenenv_test.go Outdated
@nickvigilante
nickvigilante enabled auto-merge (squash) July 8, 2026 15:25
@nickvigilante
nickvigilante merged commit 1cc230b into main Jul 8, 2026
28 of 29 checks passed
@nickvigilante
nickvigilante deleted the vigilante/docs-497-extract-docgen-env-prep-into-a-shared-package-dedupe branch July 8, 2026 15:39
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 8, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants