feat: Create Snaps API documentation from generated schema#2702
feat: Create Snaps API documentation from generated schema#2702
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
c507dbe to
15957dd
Compare
src/components/SnapsAPIReference/Parameters/Parameter/styles.module.scss
Show resolved
Hide resolved
|
General feedback:
|
@bgravenorst Do you have a good way to resolve this? It seems that Docusaurus isn't picking up the conditionally rendered headings. 😕 |
Agreed, I added the list description temporarily until we figure out a better way to show this. Can look into this as a follow-up if that's alright?
Only examples where additional permissions are needed have a manifest.
Intended to remove this from the docs, but didn't push the change to the schema yet. It will be removed soon.
In this case I actually feel like it's pretty clear that
This is a limitation in the schema generation script, will add some extra explanation to the |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
| ::: | ||
|
|
||
| - [`wallet_snap`](/snaps/reference/wallet-api-for-snaps/#wallet_snap) - Gaining permission requires | ||
| - [`wallet_snap`](/snaps/reference/snaps-api/wallet_snap) - Gaining permission requires |
There was a problem hiding this comment.
Working fine with local build of this (drops me into new reference page) but the vercel build here is throwing me elsewhere.
There was a problem hiding this comment.
This links me to the right place in the Vercel build?
| ### `getInterface` | ||
|
|
||
| If your Snap uses [`snap_dialog`](snaps-api.md#snap_dialog) to show user interfaces, you can use the | ||
| If your Snap uses [`snap_dialog`](snaps-api/snap_dialog.mdx) to show user interfaces, you can use the |
There was a problem hiding this comment.
many links from this on are absolute instead of relative
There was a problem hiding this comment.
Not sure what you mean? These links are relative.
There was a problem hiding this comment.
[link](absolute/link)
vs
[link](./relative/sibling-link)
or
[link](../relative/one-level-up-link)
There was a problem hiding this comment.
Markdown links are relative unless they start with / (or some protocol like https://) 😅
|
I have hidden the TOC for now. |




Description
This adds a Docusaurus plugin for dynamically generating Snaps API documentation from a schema file. The schema file will be generated automatically based on the implementations in
MetaMask/snaps. This allows for easier maintenance of the documentation, as some methods have become quite outdated currently.The plugin works by fetching the schema file, and writing a new MDX file to disk for each JSON-RPC method. I've considered a similar approach to the Wallet API documentation, but it had several drawbacks, like needing to hack the sidebar to show the dynamic items. By generating the MDX files before running Docusaurus,
@docusaurus/plugin-content-docswill just pick it up as any other documentation page.Related to: https://consensyssoftware.atlassian.net/browse/WPC-347 and https://consensyssoftware.atlassian.net/browse/WPC-442.
Preview
Checklist
External contributor checklist
Note
Medium Risk
Introduces a new build-time doc generation step that fetches a remote schema and writes MDX files, which could break builds/CI if the schema endpoint or generation logic changes. Also rewires many internal doc links to the new per-method pages, so incorrect IDs/paths would surface as broken links or missing pages.
Overview
Snaps API reference is now generated from schema at build time. A new Docusaurus plugin (
plugin-snaps-docs.ts) adds asnaps:generateCLI command that fetches the Snaps JSON-RPC schema and writes one MDX page per method undersnaps/reference/snaps-api/, rendered via newSnapsAPIReferencecomponents (including markdown rendering for descriptions and structured parameter/return display).The PR replaces the monolithic
snaps/reference/snaps-api.mdandwallet-api-for-snaps.mdpages with a lightweightsnaps/reference/snaps-api/index.mdlanding page and updates the Snaps sidebar to include an autogenerated “Snaps API” section.npm start/buildand CI link checking now run the generation step, generated.mdxfiles are gitignored, and many docs are updated to link to the new per-methodsnaps/reference/snaps-api/<method>.mdxpages (including Wallet docs references towallet_*methods).Written by Cursor Bugbot for commit bcf6802. This will update automatically on new commits. Configure here.