Skip to content

docs: regenerate the aztec.js API reference - #25248

Merged
vezenovm merged 12 commits into
merge-train/fairiesfrom
mv/aztecjs-reference-regen
Aug 18, 2026
Merged

docs: regenerate the aztec.js API reference#25248
vezenovm merged 12 commits into
merge-train/fairiesfrom
mv/aztecjs-reference-regen

Conversation

@vezenovm

@vezenovm vezenovm commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

The committed aztec_js_reference.md was 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.sh is 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:

  • Multi-line types were emitted inside inline code spans. A type body containing a blank line closes the span early, and its braces and angle brackets then reach the MDX parser, failing the build with Unexpected end of file in expression. Multi-line types now use a fenced code block, matching what format_return_type already did. Verified this reproduces on merge-train/fairies itself with none of these commits applied.
  • The table of contents built anchors with its own slug logic that stripped underscores Docusaurus keeps, leaving CAPABILITY_VERSION and the Contract / Protocol_Contracts section unreachable and pointing NO_WAIT/NO_FROM at the NoWait/NoFrom headings. 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 spellcheck on a metadata typo and on on-chain, which is a flagWords entry in the root cspell.json.

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.
@vezenovm
vezenovm force-pushed the mv/aztecjs-reference-regen branch from 8af03a9 to d1cee8c Compare August 17, 2026 11:50
@vezenovm
vezenovm changed the base branch from next to merge-train/fairies August 17, 2026 11:50
@vezenovm
vezenovm marked this pull request as ready for review August 17, 2026 17:50
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.

@nchamo nchamo 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.

Some small comments

# Punctuation that github-slugger, which Docusaurus uses for heading anchors, drops.
SLUG_PUNCTUATION = set("\\'!\"#$%&()*+,./:;<=>?@[]^`{|}~")

def heading_anchor(self, heading_text: str) -> str:

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.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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

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.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah this is unintended, it accidentally generated local gitignored artifacts here. It is not correct to document these contract interfaces here. In dce74ad we moved to ignore them.

In d5db925 the jsdoc bug is fixed.

Formatted markdown string for the labeled type
"""
if '\n' in type_str:
return f"**{label}:**\n\n```typescript\n{type_str}\n```\n"

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.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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(' ', '-')

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.

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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.
@vezenovm
vezenovm merged commit 88bcee5 into merge-train/fairies Aug 18, 2026
10 checks passed
@vezenovm
vezenovm deleted the mv/aztecjs-reference-regen branch August 18, 2026 16:45
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.

2 participants