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
src/components/SnapsAPIReference/Parameters/Parameter/ObjectParameter/index.tsx
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)



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
Adds a build-time docs generation step that fetches a remote schema and writes MDX files, which can break builds/CI or produce inconsistent docs if the schema changes or is unavailable.
Overview
Snaps API reference is now generated from a schema instead of maintained manually. A new Docusaurus plugin (
plugin-snaps-docs) adds asnaps:generateCLI command that fetches the Snaps JSON-RPC schema and writes one MDX page per method undersnaps/reference/snaps-api/, rendered via a newSnapsAPIReferencecomponent suite (description/parameters/returns/examples/tags) usingreact-markdown.The docs navigation and content are updated to match the new structure: the old monolithic
snaps/reference/snaps-api.md(andwallet-api-for-snaps.md) are removed, the Snaps sidebar now nests a Snaps API reference section, and many docs links are rewritten to point at the new generated per-method routes.Build/CI now runs generation automatically (
start/buildprependdocusaurus snaps:generate, and the CIlinkCheckjob installs deps and generates the reference before link checking); generated files are added to.gitignore.Written by Cursor Bugbot for commit ebe6f62. This will update automatically on new commits. Configure here.