Skip to content

docs(cli): auto-generate CLI reference from Cobra#43

Merged
dcmcand merged 3 commits into
mainfrom
issue-41-docs-gen
Apr 16, 2026
Merged

docs(cli): auto-generate CLI reference from Cobra#43
dcmcand merged 3 commits into
mainfrom
issue-41-docs-gen

Conversation

@dcmcand

@dcmcand dcmcand commented Apr 16, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add tools/docs-gen which walks the skillsctl Cobra tree and emits per-command Markdown under docs/site/content/cli/reference/.
  • Wire the generator into .github/workflows/docs.yml so every push builds the reference fresh before hugo --minify. Generated files are gitignored; only _index.md is checked in.
  • Hand-written pages under docs/site/content/cli/*.md (with prose and worked examples) are untouched.
  • Delete the unused cli/internal/config package. It had one caller (its own test) and duplicated the viper wiring already in cli/cmd/root.go. Its TestDefaults also failed any time a real config file existed at ~/.config/skillsctl/config.yaml because viper's global singleton picked it up. Net -73 lines.

Closes #41.

Test plan

  • `go run ./tools/docs-gen -o /tmp/cli-ref` produces one Markdown file per command
  • `cd docs/site && hugo --minify` builds (37 -> 53 pages after generation)
  • `golangci-lint run ./tools/...` clean
  • `go test ./... -race` passes (was failing on main due to the deleted config test)
  • Verify Docs workflow runs the generator step on merge to main

dcmcand added 3 commits April 16, 2026 09:14
Add tools/docs-gen which walks the skillsctl Cobra tree and emits one
Markdown file per command under docs/site/content/cli/reference/. The
generator runs in the Docs workflow before 'hugo --minify', so the
published site always matches the current release.

Generated files are gitignored (only _index.md is checked in) - the
source of truth lives in cli/cmd/ and the CI job materializes them at
build time. Hand-written pages under docs/site/content/cli/ continue
to cover prose and worked examples.

Closes #41
The package had exactly one caller — its own test — and duplicated
the viper wiring already in cli/cmd/root.go. Its TestDefaults failed
locally any time the user had a real config at
~/.config/skillsctl/config.yaml, since viper's global singleton read
the on-disk file even when the test expected defaults.

The code it 'provides' still exists in root.go where it is actually
used. Deleting removes the drift surface and the flaky test.
- Require -o explicitly and reject positional args; the old relative
  default would silently write to the wrong place when run outside the
  repo root.
- Factor run() out of main() and add a table-driven golden test that
  verifies the expected files, Hugo frontmatter, and that
  DisableAutoGenTag suppresses the spf13/cobra stamp.
- Point the Docs workflow's setup-go at root go.mod (bumped from
  1.25.7 to 1.25.8 to satisfy the docs/site Hugo module). This puts
  docs-gen's toolchain on the same pin as every other Go job and
  removes the accidental coupling where Hugo's go.mod was driving the
  root compile.
- Narrow the docs workflow's paths trigger from cli/** to cli/cmd/**;
  internal packages do not affect the generated reference.
@dcmcand dcmcand merged commit e0f2252 into main Apr 16, 2026
10 checks passed
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.

docs: auto-generate CLI reference from Cobra definitions

1 participant