docs: regenerate the aztec.js API reference - #25248
Conversation
Two bugs made a regeneration of the aztec.js API reference unlandable, which is part of why the committed reference had not been refreshed since December. The generator emitted multi-line types inside inline code spans. A type body containing a blank line closes the span early, leaving its braces and angle brackets to be parsed as MDX expressions and JSX tags, so the page no longer compiled and the docs build failed. Emit a fenced code block for multi-line types instead, matching what format_return_type already did, and collapse destructured parameter names onto one line. The table of contents also built anchors with its own slug logic, which stripped underscores that Docusaurus keeps. That left CAPABILITY_VERSION and the Contract / Protocol_Contracts section unreachable, and pointed NO_WAIT and NO_FROM at the NoWait and NoFrom headings instead. Derive the anchor from the rendered heading text the way github-slugger does. Also fix the aztec.js JSDoc that a regenerated reference trips cspell on: a "metadata" typo and the repo-flagged "on-chain" spelling.
Last generated on 2025-12-10, so the committed reference had drifted a long way from the source: 19 documented symbols no longer exist in aztec.js (including getGasLimits, which moved to the wallet SDK) and 82 current exports were missing entirely.
8af03a9 to
d1cee8c
Compare
…ecjs-reference-regen
The parser walked subdirectories in fs.readdirSync order and sorted files with localeCompare, so the module and file order in the generated page depended on the filesystem and on the runtime's locale data: the same sources produced a different page on macOS and on Linux. Sort both by code unit. Reversing every readdir now leaves the regenerated page identical apart from its timestamp.
Nine public members had no return annotation, so the generated API reference documented them through the type checker. Write the types out. They are the types the checker already reported, except waitForProven, which becomes Promise<BlockNumber> rather than retryUntil's Promise<NonNullable<BlockNumber>>.
The parser resolved @aztec/* imports, so an inferred return type depended on which sibling packages the environment had built: a page generated against a full build silently differed from one generated against a partial build, and the difference only surfaced in CI. Resolve relative imports only, so the page is a function of the aztec.js sources and nothing else. Types that cross a package boundary now have to be annotated in the source. Parsing also drops from ~50s to ~8s, since the checker no longer reads the workspace's declaration files.
| # Punctuation that github-slugger, which Docusaurus uses for heading anchors, drops. | ||
| SLUG_PUNCTUATION = set("\\'!\"#$%&()*+,./:;<=>?@[]^`{|}~") | ||
|
|
||
| def heading_anchor(self, heading_text: str) -> str: |
There was a problem hiding this comment.
heading_anchor doesn't model github-slugger's duplicate counter, so four TOC links land on the wrong heading:
| TOC link | Lands on | Should be |
|---|---|---|
[Fee](#fee) |
L1536 ##### fee, mid-Contract |
L4029 ## Fee = #fee-4 |
[Account](#account) |
L225 ## Account, the folder |
L267 #### Account = #account-1 |
[Contract](#contract) |
L647 ## Contract |
L877 #### Contract = #contract-1 |
[Wallet](#wallet) |
L5131 ## Wallet |
L6735 #### Wallet = #wallet-1 |
The other 190 links resolve correctly.
Should the slugger keep a per-slug count? It has to run over every heading in document order, including the ##### fee method headings the TOC never links to, since those are what push ## Fee out to #fee-4.
There was a problem hiding this comment.
Fixed in d5db925. Every heading claims its anchor in document order and the contents are built from the claimed anchors, so all four links land on the intended section. generate() also now verifies its headings, so a heading written as a plain string should break the build instead of silently misdirecting links.
| ### `contract/protocol_contracts/contract-class-registry.ts` | ||
|
|
||
|
|
||
| #### ContractClassRegistryContract |
There was a problem hiding this comment.
Was the page generated before the merge-train/fairies merge? Rerunning update_docs.sh current at this commit adds the static withWallet methods on ContractClassRegistryContract, ContractInstanceRegistryContract and FeeJuiceContract, and nothing else changes apart from the *Generated:* timestamp.
Worth doing, because the page currently doesn't mention them at all: parse_typescript.js drops jsdoc that is only a tag, so the @deprecated marker on at() doesn't survive either and at() renders with an empty description. Readers get a deprecated method presented as the only entry point.
| Formatted markdown string for the labeled type | ||
| """ | ||
| if '\n' in type_str: | ||
| return f"**{label}:**\n\n```typescript\n{type_str}\n```\n" |
There was a problem hiding this comment.
Nit: verify_docs.py's type-label regex needs the type on the same line, so the new multi-line branch makes it report 3 extra "missing **Type:** label" warnings, at the #### Properties sections on L3152, L3236 and L3334. There are 8 bare **Type:** lines in total, but the other four sections holding one also carry a single-line **Type:**, so they still pass. Should the regex learn about the fenced form while you're here? Just checking, it's warning-only and the script isn't in CI.
There was a problem hiding this comment.
We now get the following when running verify_docs.py:
Verifying docs/docs-developers/docs/aztec-js/aztec_js_reference.md...
✅ All checks passed! Documentation is production-ready.
| """ | ||
| slug = heading_text.lower().strip() | ||
| slug = ''.join(c for c in slug if c not in self.SLUG_PUNCTUATION) | ||
| return slug.replace(' ', '-') |
There was a problem hiding this comment.
Now that the TOC uses heading_anchor, is slugify still used? The three remaining calls (131, 192, 258) all assign to a local that's never read, and it produces different anchors than heading_anchor does, so leaving it around might cause someone to pick the wrong one. Should we drop it?
There was a problem hiding this comment.
yup slugify is removed and they are different than the new slug introduced here. updated
yarn-project/aztec.js/src/contract/protocol_contracts is gitignored build output, generated from the compiled Noir protocol contracts. Documenting it made the page depend on noir-projects: a checkout cannot regenerate or verify the reference without those artifacts, and a change to a protocol contract left the committed page stale. The page now covers 8 modules and 182 exports, and generating it with that directory absent produces the same bytes.
check_section_structure treated every H4 as an export, but the generator emits Constructor, Properties, Methods, Getters and Setters as H4 groups alongside them, so all 54 warnings on the aztec.js reference were groups with no Type label of their own. It also asked every export for a Signature, which only functions and type aliases are documented with. Skip the member groups, expect a signature only from the kinds that have one, share the fence tracking so a multi-line type's contents are not read as labels, and check the last section instead of dropping it when the file ends. The aztec.js reference now passes clean, so a real regression is visible instead of being buried.
Docusaurus keeps heading anchors unique by appending -1, -2 and so on, searching for an anchor no
earlier heading has taken. The table of contents computed anchors from the heading text alone, so
four of its links pointed at whichever heading claimed the bare slug first: Fee reached a fee method
rather than the module, and Account, Contract and Wallet reached their folder rather than their
class. Nothing catches this, because the links resolve, just to the wrong section.
Port the suffix search, claim each anchor as its heading is rendered, and build the contents from
what the body claimed. Generating a heading as a plain string would leave the contents wrong again
in the same silent way, so generate() now checks the rendered document against the anchors that were
claimed. This also removes slugify, which produced different anchors and whose three callers already
ignored its result.
Alongside that, two things the reference did not say: an export deprecated by a doc comment carrying
nothing but the tag rendered as though nothing were wrong with it, and `export { x }` with no `from`
rendered as a re-export from an empty module.
hermeticCompilerHost resolved relative imports, which is not hermetic; name it relativeImportsOnlyHost. Also spell out in the README why a heading written as a plain string is silent (the link resolves, to the wrong section) and how generate() catches it.
The committed
aztec_js_reference.mdwas last generated on 2025-12-10. Against today's aztec.js source it documents 125 symbols where the package exports 188: 19 documented symbols no longer exist (AccountInterface,AccountWithSecretKey,DeploySentTx,broadcastPrivateFunction,getGasLimits, ...) and 82 current exports are missing.The v5.1.0 snapshot that production serves carries the same December content, so this is what the live API reference shows today. The release refreshed the CLI references, the aztec-nr API and the TypeDoc TypeScript API in the same commit, but
aztecjs_reference_generation/update_docs.shis not part of the release checklist.This also resolves the contradiction @nchamo spotted in #25220, where the stale block still described the old two-argument form and said gas limits exclude teardown gas.
Why the generator changed too
A straight regeneration does not build, so two generator bugs are fixed first:
Unexpected end of file in expression. Multi-line types now use a fenced code block, matching whatformat_return_typealready did. Verified this reproduces onmerge-train/fairiesitself with none of these commits applied.CAPABILITY_VERSIONand theContract / Protocol_Contractssection unreachable and pointingNO_WAIT/NO_FROMat theNoWait/NoFromheadings. Anchors now derive from the rendered heading text the way github-slugger does.The aztec.js JSDoc edits are comment-only, and are needed because the regenerated page otherwise fails
yarn spellcheckon ametadatatypo and onon-chain, which is aflagWordsentry in the rootcspell.json.