Repository navigation
docs(book): add a cargo oxide command reference - #794
Merged
Merged
Conversation
The book documented 11 of the CLI's 15 subcommands, scattered across
pages, with no complete list anywhere. `test`, `fmt`, `update` and
`emit-ltoir` appeared nowhere at all.
Each of those four does something plain cargo cannot, so being absent is
not cosmetic:
* `cargo oxide test` is the only way to run the suite with device code
compiled by the backend.
* `cargo oxide fmt` covers three scopes -- root workspace, codegen
backend, and every example -- because each example carries its own
`[workspace]`, so a single `cargo fmt` at the root misses most of the
tree. That is also what the CI fmt gate checks.
* `cargo oxide update` is how the cached backend is refreshed after a
compiler-crate or toolchain-pin change.
* `cargo oxide emit-ltoir` produces the LTOIR a tile or C++ kernel
links against. The book discusses LTOIR on eight pages and named no
way to generate one.
So this adds a Command reference table to the cargo-oxide section listing
all fifteen, plus worked examples for those four. Descriptions are clap's
own, so `--help` stays the single source of truth.
Verified: the table's fifteen entries match `cargo oxide --help` exactly,
with nothing missing and nothing invented. `cargo oxide fmt`'s three
scopes are confirmed against `format_all` in commands.rs, not inferred
from the help text. `sphinx-build -W --keep-going`, as the book gate runs
it, succeeds; a first draft linked the section by anchor and failed that
gate, since this book sets `heading_anchors=0`, so the reference is plain
prose instead.
Signed-off-by: Vyncint Ng <[email protected]>
Collaborator
|
Verified:
Happy to take the drift guard as a follow-up if you are up for it. Merging. |
nihalpasham
approved these changes
Aug 11, 2026
nihalpasham
pushed a commit
that referenced
this pull request
Aug 11, 2026
…803) The follow-up offered on #794. That PR added a Command reference table because the book documented 11 of the CLI's 15 subcommands; `test`, `fmt`, `update` and `emit-ltoir` appeared nowhere. Nothing stops the table falling behind again -- adding a variant to the clap enum is a one-line change and no build compares the two. `scripts/check-cli-doc-coverage.sh` compares the `Commands` enum in `crates/cargo-oxide/src/main.rs` against the rows under `### Command reference`, in both directions. A missing row is the common case; a row for a command that no longer exists is worse, because a reader trusts it and gets `unrecognized subcommand`. Subcommands come from the enum rather than from `cargo oxide --help`: the enum is the definition, reading it needs no cargo and no build, and that keeps the guard in the same source-only class as its siblings. A guard that needed a backend build to answer a documentation question would not get run. The parse is cross-checked against the built binary -- both report the same 15 commands, with no disagreement. Deliberately not required to appear: anything carrying `hide = true` (`__materializer-provenance` today) and clap's generated `help`, which is not in the enum at all. Descriptions are out of scope, because clap's short help is the doc-comment first line while the table's cells add MyST backticks around names like `cuda-gdb`; comparing them literally would fail on correct prose. While wiring it up: `check-guards` was running five of the seven guards. The crate-inventory and toolchain-parity jobs went into status-guard.yml in #793 and #790 without being added to the recipe, so `just check` could pass while status-guard failed -- exactly the drift #729 and #788 built that recipe to prevent. My omission; all three are in now, and the stale counts in its comment ("the status-guard pair", "two of the four") are fixed. Verified: passes on the clean tree (15 documented, 1 hidden excluded), and seven mutations each fail naming the cause -- new subcommand, deleted row, invented row, a row for the hidden command, a rename, and both parse self-tests. `just check-guards` is green end to end. Signed-off-by: Vyncint Ng <[email protected]>
nihalpasham
added a commit
that referenced
this pull request
Aug 11, 2026
…805) * ci: guard the book's CLI command reference against subcommand drift The follow-up offered on #794. That PR added a Command reference table because the book documented 11 of the CLI's 15 subcommands; `test`, `fmt`, `update` and `emit-ltoir` appeared nowhere. Nothing stops the table falling behind again -- adding a variant to the clap enum is a one-line change and no build compares the two. `scripts/check-cli-doc-coverage.sh` compares the `Commands` enum in `crates/cargo-oxide/src/main.rs` against the rows under `### Command reference`, in both directions. A missing row is the common case; a row for a command that no longer exists is worse, because a reader trusts it and gets `unrecognized subcommand`. Subcommands come from the enum rather than from `cargo oxide --help`: the enum is the definition, reading it needs no cargo and no build, and that keeps the guard in the same source-only class as its siblings. A guard that needed a backend build to answer a documentation question would not get run. The parse is cross-checked against the built binary -- both report the same 15 commands, with no disagreement. Deliberately not required to appear: anything carrying `hide = true` (`__materializer-provenance` today) and clap's generated `help`, which is not in the enum at all. Descriptions are out of scope, because clap's short help is the doc-comment first line while the table's cells add MyST backticks around names like `cuda-gdb`; comparing them literally would fail on correct prose. While wiring it up: `check-guards` was running five of the seven guards. The crate-inventory and toolchain-parity jobs went into status-guard.yml in #793 and #790 without being added to the recipe, so `just check` could pass while status-guard failed -- exactly the drift #729 and #788 built that recipe to prevent. My omission; all three are in now, and the stale counts in its comment ("the status-guard pair", "two of the four") are fixed. Verified: passes on the clean tree (15 documented, 1 hidden excluded), and seven mutations each fail naming the cause -- new subcommand, deleted row, invented row, a row for the hidden command, a rename, and both parse self-tests. `just check-guards` is green end to end. Signed-off-by: Vyncint Ng <[email protected]> * ci: cover the codegen backend's own workspace in both license guards The second pass asked for in the #662 review: "a second pass over `crates/rustc-codegen-cuda` (its own workspace, invisible to both cargo-deny and this guard today)". Still true, and it had already cost a row. That crate carries its own `[workspace]` for the rustc-private dylibs, so it is a third resolution alongside the root and the examples, and neither existing guard reached it. The inventory guard read the root workspace through `cargo metadata`, which stops at that boundary; the policy side ran `cargo deny check` on the root and a script over the examples. **Inventory, and a live omission.** `rustc_codegen_cuda` had no row in dependency-licenses.csv at all -- the largest first-party crate in the tree, missing from the inventory, while every other member carried a `1st Party (workspace)` row. Nothing could have caught it. The guard now unions the declared crates of both first-party workspaces, which takes it from 41 to 55, and the missing row is added. **Policy.** `cargo deny` now runs over that workspace too, in the same job as the root run so the install is shared. This is narrower than it looks and worth stating precisely: all 82 of its third-party crate *names* also appear in the root graph, so nothing is unlicensed today. What differs is versions -- 17 (name, version) pairs resolve there and nowhere else, including `anyhow 1.0.100`, `libc 0.2.187` and `linkme 0.3.35` -- and advisory and license verdicts are per version, so an advisory against one of those 17 is invisible to the root run. Verified: * the inventory guard passes with the row (55 crates) and, with the row removed again, fails naming exactly `rustc_codegen_cuda`; * banning `anyhow =1.0.100`, a backend-only version, leaves the root run at `bans ok` and makes the backend run fail with `error[banned]` -- the new leg covers crates the root one cannot see; * `cargo deny --manifest-path crates/rustc-codegen-cuda/Cargo.toml --locked check` is clean on the current tree, so the policy half is prevention rather than a fix; * `just check-guards` green end to end, and both workflow files parse. No `--config` on the new run: cargo-deny walks up from the manifest directory to the repository-root deny.toml, the same resolution the example-policy script already relies on. Stacked on #803, which adds the CLI-reference guard to the same `check-guards` recipe -- review only the second commit. Signed-off-by: Vyncint Ng <[email protected]> --------- Signed-off-by: Vyncint Ng <[email protected]> Co-authored-by: nihalpasham <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The gap
The book documents 11 of the CLI's 15 subcommands, scattered across pages, with
no complete list anywhere.
test,fmt,updateandemit-ltoirappearnowhere at all.
None of those four is cosmetic — each does something plain
cargocannot:cargo oxide testis the only way to run the suite with device codecompiled by the backend.
cargo oxide fmtcovers three scopes — root workspace, codegen backend,and every example — because each example carries its own
[workspace], so asingle
cargo fmtat the root misses most of the tree. That is also what theCI fmt gate checks, which makes it the command a contributor most needs to
know and the one least discoverable.
cargo oxide updaterefreshes the cached backend after a compiler-crateor toolchain-pin change.
cargo oxide emit-ltoirproduces the LTOIR a tile or C++ kernel linksagainst. The book discusses LTOIR on eight pages and named no way to generate
one.
The change
A Command reference table in the
cargo-oxidesection listing all fifteen, plusworked examples for those four. Descriptions are clap's own, so
--helpremainsthe single source of truth rather than a second one drifting alongside it.
Verification
cargo oxide --helpexactly — diffedboth directions, nothing missing and nothing invented.
cargo oxide fmt's three scopes are confirmed againstformat_allincrates/cargo-oxide/src/commands.rs, not inferred from its help text.sphinx-build -W --keep-going -b html, exactly as the book gate runs it:build succeeded, exit 0.One note on that last point, since it is a trap for the next person editing this
book: my first draft linked the new section with
[the command reference](#command-reference), which fails the book gate —WARNING: 'myst' cross-reference target not foundwith-Wturning it into anerror. The rendered HTML contains both the
hrefand a matchingid, so itworks in a browser; the gate still rejects it, because this book sets
heading_anchors=0. The cross-reference is plain prose instead.Possible follow-up
The table will drift the moment a subcommand is added, exactly as the toolchain
pin did in #790. The subcommand enum in
main.rsis cleanly parseable (variantskebab-cased, hidden ones carry
hide = true), so a coverage guard in the shapeof #790/#793 is straightforward. I have deliberately not included one here —
that would be a third guard in one batch, and this PR is worth reviewing on its
own. Happy to add it if you want the table kept honest automatically.