Skip to content

fix/doc: Add missing commands to helper text - #1375

Open
marcleblanc2 wants to merge 1 commit into
mainfrom
fix/doc-legacy-groups
Open

fix/doc: Add missing commands to helper text#1375
marcleblanc2 wants to merge 1 commit into
mainfrom
fix/doc-legacy-groups

Conversation

@marcleblanc2

@marcleblanc2 marcleblanc2 commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Part of FE-502: src-cli docs broken.

src doc generates the CLI reference pages on sourcegraph.com/docs/cli/references. Two bugs in cmd/src/doc.go leave it incomplete:

  • search-jobs, debug, and snapshot are missing from the commanders map, so each renders as a single page and their 16 subcommands get no page at all.
  • maps.Copy(subcommands, rootSubcommands) has its arguments backwards, so the root index.md lists only the urfave/cli commands and drops batch, repos, search, etc.

This PR adds the three map entries, fixes the maps.Copy order, and adds cmd/src/doc_test.go so both regressions fail CI: a golden list of the generated files, a check that no leaf page lists subcommands, and a check that the root index links every command.

teams is left out on purpose; teams were removed in Sourcegraph 7.0, and #1376 (stacked on this) removes the command. #1377 then generates src help from the same registrations.

Test plan

go test ./cmd/src/... passes. With doc.go reverted to main, all three new tests fail, naming the three leaf pages and the missing root-index commands.

go run ./cmd/src doc -o /tmp/out vs 7.6.0: debug.md, search-jobs.md, snapshot.md become directories (19 files); root index.md grows from 8 to 20 entries; nothing else changes. The search-jobs/* content matches the hand-written pages currently in sourcegraph/docs.

…cy commands in root index

`src doc` only expands legacy command groups that are registered in the
`commanders` map. `search-jobs`, `debug` and `snapshot` were never added,
so each rendered as a single leaf page with the group help text and their
subcommands (19 pages) were never documented.

The root index.md also only listed urfave/cli commands: since #1304,
`maps.Copy(subcommands, rootSubcommands)` copied in the wrong direction
(`maps.Copy(dst, src)`), dropping every legacy command from the landing page.

`teams` is intentionally left as a single page: teams were removed in
Sourcegraph 7.0 (#1257).

Add cmd/src/doc_test.go so both regressions fail CI in future: a golden
file list (mirrors OUTPUT_FILES in sourcegraph/sourcegraph
doc/cli/references/BUILD.bazel), a check that no leaf page lists
"The commands are:", and a check that the root index links every command.

Part of https://linear.app/sourcegraph/issue/FE-502

Amp-Thread-ID: https://ampcode.com/threads/T-01a08410-86ca-72be-9928-2810e837fae1
Co-authored-by: Amp <amp@ampcode.com>
@marcleblanc2 marcleblanc2 changed the title fix/doc: document search-jobs, debug, snapshot subcommands; list legacy commands in root index fix/doc: Add missing commands to helper text Sep 9, 2026
marcleblanc2 added a commit to sourcegraph/docs that referenced this pull request Sep 11, 2026
…; list all commands in index

Pre-seeds the output of the fixed `src doc` generator (sourcegraph/src-cli#1375)
so the CLI reference is correct now rather than after the next src-cli release
and docs sync:

- index.mdx lists all 20 top-level commands again (was only the 8 urfave/cli
  ones since src-cli#1304).
- debug/, snapshot/: new index + subcommand pages (9 files).
- search-jobs/: new index; the 8 hand-written subcommand pages are replaced by
  the generated equivalents (same usage text, plus a flags table).
- Delete the flat debug.mdx, search-jobs.mdx, snapshot.mdx. The sync job never
  deletes, and these would shadow the new <group>/index.mdx in contentlayer
  routing.

Files were produced with the same md2mdx conversion the sync uses; the
sync/generated-docs PR that follows sourcegraph/sourcegraph#15528 should be a
no-op for these paths.

Part of https://linear.app/sourcegraph/issue/FE-502

Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-01a08410-86ca-72be-9928-2810e837fae1
marcleblanc2 added a commit to sourcegraph/docs that referenced this pull request Sep 11, 2026
Part of [FE-502](https://linear.app/sourcegraph/issue/FE-502). **Step 4
of 4** in a cross-repo stack, but **mergeable now** — it pre-seeds what
the generated-docs sync will eventually write, so the live reference
gets fixed without waiting on a src-cli release.

## Why

The `src` CLI reference is generated by `src doc` and synced here by
sourcegraph/sourcegraph's `sync/generated-docs` job. Two generator bugs
(fixed in sourcegraph/src-cli#1375) left this reference incomplete:

- `search-jobs`, `debug` and `snapshot` were never registered in the
generator's `commanders` map, so each is a single page with only the
group help; their 16 subcommands have no reference pages. (The 8
`search-jobs/*.mdx` pages here were hand-written by Travis Lyons in May
2025 to paper over this; nothing links to them.)
- `index.mdx` lists only the 8 urfave/cli commands (`abc`, `api`,
`auth`, `codeowners`, `login`, `orgs`, `users`, `version`) — `batch`,
`repos`, `search`, `config`, etc. are missing from
https://sourcegraph.com/docs/cli/references today.

## What

- `index.mdx`: lists all 19 top-level commands.
- `debug/{index,compose,kube,server}.mdx`,
`snapshot/{index,databases,restore,summary,test,upload}.mdx`: new.
- `search-jobs/index.mdx`: new;
`search-jobs/{cancel,create,delete,get,list,logs,restart,results}.mdx`:
hand-written pages replaced by generated ones (same usage text, plus a
flags table; the `<p className="subtitle">` blurbs go away since the
generator doesn't emit them).
- Deleted `debug.mdx`, `search-jobs.mdx`, `snapshot.mdx`.
- Deleted `teams.mdx` and dropped `teams` from `index.mdx`: teams were
removed in Sourcegraph 7.0 and sourcegraph/src-cli#1376 removes the
command, so the generator no longer emits this page. No redirect (same
call as #1886). The sync job never deletes files, and in contentlayer
routing a flat `foo.mdx` shadows `foo/index.mdx` (the same bug #1886
fixed for `auth.mdx`/`codeowners.mdx`), so these have to go by hand for
the new index pages to be reachable.

Content was produced by running the patched generator (src-cli `main` +
#1375) and the same `tools/md2mdx` conversion the sync uses, so the sync
PR that follows sourcegraph/sourcegraph#15528 should be a no-op for
these paths.

No redirects: the three deleted URLs
(`/cli/references/{debug,search-jobs,snapshot}`) keep resolving, now to
the new index pages.

## Stack

1. sourcegraph/src-cli#1375 — generator fix + tests;
sourcegraph/src-cli#1376 (stacked) — remove `src teams`;
sourcegraph/src-cli#1377 (stacked) — `src help` generated from
registered commands, tests help == docs
2. src-cli 7.7.0 release (none since 7.6.0; blocks 3)
3. sourcegraph/sourcegraph#15528 — pin bump + `OUTPUT_FILES` +
regenerate (draft until 2)
4. **this PR**
5. sourcegraph/sourcegraph#15529 — make the docs sync mirror
`docs/cli/references/` so removed commands disappear automatically
(merge after 3 and this PR)

Related: #1886 (removed 28 stale pages for commands that no longer
exist).

## Test plan

`npx contentlayer build` → 528 documents; routes resolve to the intended
files:

```
/cli/references/debug        <- cli/references/debug/index.mdx
/cli/references/search-jobs  <- cli/references/search-jobs/index.mdx
/cli/references/snapshot     <- cli/references/snapshot/index.mdx
```
plus the 16 subcommand routes. (The `ERR_INVALID_ARG_TYPE`/clipanion
stack trace during the build is pre-existing on `main`.)

## Amp threads

- [Stale command
docs](https://ampcode.com/threads/T-01a08410-86ca-72be-9928-2810e837fae1)

---------

Co-authored-by: Amp <amp@ampcode.com>
@marcleblanc2
marcleblanc2 enabled auto-merge (squash) September 11, 2026 08:22
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