-
-
Notifications
You must be signed in to change notification settings - Fork 279
feat: add @metamask/platform-api-docs package #8012
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
cryptodev-2s
wants to merge
94
commits into
main
Choose a base branch
from
feat/messenger-docs-site
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 9 commits
Commits
Show all changes
94 commits
Select commit
Hold shift + click to select a range
9af5f7d
feat: add Messenger API docs site with local search
cryptodev-2s 6f5169f
feat: add --client flag to generate messenger docs from client depend…
cryptodev-2s 09b2c92
refactor: split generate-messenger-docs into modular folder structure
cryptodev-2s 9396df8
refactor: replace sync fs calls with async fs/promises
cryptodev-2s b91a407
feat: extract messenger-docs into publishable package (#8014)
cryptodev-2s 195a811
docs: update messenger-docs README with monorepo and client usage
cryptodev-2s 15006c5
fix: restore eslint.config.js scripts changes
cryptodev-2s 17adacd
fix: derive GitHub Pages URL from repo owner and name
cryptodev-2s 8ee4add
Merge remote-tracking branch 'origin/main' into feat/messenger-docs-site
cryptodev-2s 726937a
refactor: remove public API exports, CLI-only package
cryptodev-2s 3c7be5e
fix: remove unused custom footer from docusaurus config
cryptodev-2s 5d791fa
fix: replace Euclid font with Geist
cryptodev-2s 82b3e45
refactor: use glob package for file discovery
cryptodev-2s 196cd2c
refactor: use directoryExists from @metamask/utils
cryptodev-2s c8e5285
refactor: resolve scanDirs in cli.ts instead of generate.ts
cryptodev-2s e5a9c27
refactor: simplify package scripts, pass project path from root
cryptodev-2s b4b841a
refactor: rewrite CLI with yargs and execa
cryptodev-2s 2726f4f
Merge remote-tracking branch 'origin/main' into feat/messenger-docs-site
cryptodev-2s 2b77320
fix: update workflow to use renamed docs:messenger script
cryptodev-2s 808fd3c
refactor: merge messenger-docs into messenger-cli
cryptodev-2s 0c0f5e3
fix: restore yarn.config.cjs
cryptodev-2s 8f51c7a
fix: .gitignore
cryptodev-2s 519826e
fix: use existing.kind for dedup list lookup in docs generator
cryptodev-2s f439b61
fix: handle single-line JSDoc comments in docs extraction
cryptodev-2s e19d372
refactor: use fileExists from @metamask/utils instead of local helper
cryptodev-2s 2a71f63
fix: escape braces in single-line JSDoc and use fileExists from @meta…
cryptodev-2s 9999b19
fix: use relative font URL for baseUrl compatibility
cryptodev-2s b18ca18
fix: use bareSpec for non-DTS import resolution in docs extraction
cryptodev-2s 3ca6451
fix: case-insensitive home-package detection in dedup scoring
cryptodev-2s b450618
fix: guard against empty prefix in dedup home-score check
cryptodev-2s d690a4f
fix: use exact anchor match to prevent false cross-reference links
cryptodev-2s 925e551
fix: replace broken glob dep with recursive readdir, add discovery tests
cryptodev-2s 2449194
test: add unit and functional tests for docs generator
cryptodev-2s f9a7d4b
test: improve docs test coverage to ~89%
cryptodev-2s e805340
test: adjust coverage thresholds for docs module
cryptodev-2s b6a517f
fix: use singular/plural in docs generation log messages
cryptodev-2s 325e1ab
Merge remote-tracking branch 'origin/main' into feat/messenger-docs-site
cryptodev-2s 5baf2a7
fix: lint misc
cryptodev-2s b0c93dd
refactor: split messenger-docs back into its own package
cryptodev-2s 0a1c767
fix: restore execa devDependency in messenger-cli
cryptodev-2s 4b5247d
docs: run readme-content:update
cryptodev-2s 6d28783
refactor: merge hashbang override into existing scripts entry
cryptodev-2s 3dc5593
fix: prettier formatting for messenger-docs package.json
cryptodev-2s 0c5d2c0
test: boost extraction coverage to ~89% with additional edge case tests
cryptodev-2s 2e2a7a0
fix: remove .DS_Store
cryptodev-2s c904bee
fix: handle single-line @deprecated, dedup kind mismatch, remove dupl…
cryptodev-2s cbae825
fix: lint:misc
cryptodev-2s 166e62f
fix: correct test assertion and prettier formatting
cryptodev-2s b441b46
fix: revert eslint glob broadening, strip all tags in single-line JSDoc
cryptodev-2s 0e30615
Merge branch 'main' into feat/messenger-docs-site
mcmire 170f9ea
Bump all Docusaurus dependencies
mcmire b7921f1
Rename template/ to site/ to better match intended usage
mcmire e940db5
Add tsx to messenger-docs so it's possible to run the CLI within the …
mcmire f95346b
Show stack traces for 'file not found' warnings
mcmire 985c43c
TEMPORARILY force-upgrade webpackbar to v7
mcmire bda8e73
Upgrade auto-changelog
mcmire 26e79fe
Update README and help text to reflect complete intended usage
mcmire da27777
Address lint issues
mcmire cba00c2
Remove top-level package scripts
mcmire f27d25e
Revert "Remove top-level package scripts"
mcmire 05f2902
Fix files in messenger-docs package.json
mcmire 96578b1
Fix eslint.config.mjs
mcmire af38898
Fix test
mcmire 4ffd287
Merge branch 'main' into feat/messenger-docs-site
mcmire 3923f7d
yarn dedupe
mcmire b831c27
Refactor messenger-cli parse-source to use ts-morph
cryptodev-2s fbb0797
Merge branch 'main' into feat/messenger-docs-site
cryptodev-2s 187727a
Revert "Refactor messenger-cli parse-source to use ts-morph"
cryptodev-2s 5a6bf65
Refactor messenger-docs extraction to use ts-morph
cryptodev-2s b6d3b4f
Rename docs:messenger to docs:messenger:build and split generate()
cryptodev-2s 3d02e9f
Rename resolveControllerName to collectStringConstants
cryptodev-2s f3adf53
Anchor messenger-docs extraction on Messenger declarations
cryptodev-2s baffffe
Update Messenger API Docs workflow to use renamed script
cryptodev-2s dea72a3
rename: use platform instead of messenger
cryptodev-2s 2b9ec1d
Merge branch 'main' into feat/messenger-docs-site
cryptodev-2s fbc0aed
Resolve repo default branch instead of hardcoding main
cryptodev-2s b334965
Raise messenger-docs coverage back above original threshold
cryptodev-2s ccdc8dc
Stamp project label and commit SHA on generated docs
cryptodev-2s e5cef32
Merge branch 'main' into feat/messenger-docs-site
cryptodev-2s 89832b1
Rename messenger-docs types and helpers for clarity
cryptodev-2s 36158b5
Simplify the Actions/Events type walker
cryptodev-2s b664468
Return capability-type AST nodes directly from the messenger walk
cryptodev-2s c7cde64
Drop messenger-docs package.json config in favor of CLI flags
cryptodev-2s 66c8d81
Use ts-morph's JSDoc API instead of parsing raw comment text
cryptodev-2s a6585b0
Bring messenger-docs coverage to 100% lines, 93%+ branches
cryptodev-2s 9d2fbf7
Use the glob package for messenger-docs file discovery
cryptodev-2s 40ad9c3
Rename messenger-docs to platform-api-docs
cryptodev-2s 3f115e7
Fix broken npm URL for non-@metamask node_modules sources
cryptodev-2s 1b1b547
Merge remote-tracking branch 'origin/main' into feat/messenger-docs-site
cryptodev-2s 34c820f
Deploy Platform API docs to a /platform-api subdirectory
cryptodev-2s c767ae0
Accept all three indexed-access forms for handler resolution
cryptodev-2s 671e21a
Render documented @param and @returns from action JSDoc
cryptodev-2s a85fa0f
Resolve capability types across files via ts-morph's type checker
cryptodev-2s 13ccf66
Narrow getPropertyMember return type to PropertySignature
cryptodev-2s File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| name: Messenger API Docs | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| pull_request: | ||
| branches: [main] | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| build-docs: | ||
| name: Build Messenger API docs | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout and setup environment | ||
| uses: MetaMask/action-checkout-and-setup@v2 | ||
| with: | ||
| is-high-risk-environment: false | ||
|
|
||
| - name: Generate and build Messenger docs | ||
| run: yarn docs:messenger:build | ||
|
cursor[bot] marked this conversation as resolved.
Outdated
|
||
| env: | ||
| DOCS_URL: https://${{ github.repository_owner }}.github.io | ||
| DOCS_BASE_URL: /${{ github.event.repository.name }}/ | ||
|
|
||
| - name: Upload build artifact (PR) | ||
| if: github.event_name == 'pull_request' | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: messenger-api-docs | ||
| path: .messenger-docs/build/ | ||
| retention-days: 7 | ||
|
|
||
| - name: Upload Pages artifact (main) | ||
| if: github.ref == 'refs/heads/main' && github.event_name == 'push' | ||
| uses: actions/upload-pages-artifact@v3 | ||
| with: | ||
| path: .messenger-docs/build/ | ||
|
|
||
| deploy: | ||
| name: Deploy to GitHub Pages | ||
| if: github.ref == 'refs/heads/main' && github.event_name == 'push' | ||
| needs: build-docs | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| pages: write | ||
| id-token: write | ||
| environment: | ||
| name: github-pages | ||
| url: ${{ steps.deployment.outputs.page_url }} | ||
| steps: | ||
| - name: Deploy to GitHub Pages | ||
| id: deployment | ||
| uses: actions/deploy-pages@v4 | ||
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| # Changelog | ||
|
|
||
| All notable changes to this project will be documented in this file. | ||
|
|
||
| The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), | ||
| and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
|
||
| ## [Unreleased] | ||
|
|
||
| ### Added | ||
|
|
||
| - Initial release of the messenger-docs package | ||
|
|
||
| [Unreleased]: https://github.com/MetaMask/core/ |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| MIT License | ||
|
|
||
| Copyright (c) 2025 MetaMask | ||
|
|
||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| of this software and associated documentation files (the "Software"), to deal | ||
| in the Software without restriction, including without limitation the rights | ||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| copies of the Software, and to permit persons to whom the Software is | ||
| furnished to do so, subject to the following conditions: | ||
|
|
||
| The above copyright notice and this permission notice shall be included in all | ||
| copies or substantial portions of the Software. | ||
|
|
||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| SOFTWARE. |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| # `@metamask/messenger-docs` | ||
|
|
||
| Generate and serve Messenger API documentation for MetaMask controller packages. | ||
|
|
||
| Scans TypeScript source files and declaration files for messenger action/event types, then generates a searchable Docusaurus site with per-namespace documentation. | ||
|
|
||
| ## Installation | ||
|
|
||
| `yarn add @metamask/messenger-docs` | ||
|
|
||
| or | ||
|
|
||
| `npm install @metamask/messenger-docs` | ||
|
|
||
| ## Usage | ||
|
|
||
| ### Core monorepo | ||
|
|
||
| The package includes workspace scripts for development: | ||
|
|
||
| ```bash | ||
| # Generate docs from all packages | ||
| yarn workspace @metamask/messenger-docs docs:generate | ||
|
|
||
| # Generate + start dev server with hot reload | ||
| yarn workspace @metamask/messenger-docs docs:dev | ||
|
|
||
| # Generate + build static site | ||
| yarn workspace @metamask/messenger-docs docs:build | ||
|
|
||
| # Generate + build + serve | ||
| yarn workspace @metamask/messenger-docs docs:serve | ||
| ``` | ||
|
|
||
| ### Client projects (Extension, Mobile) | ||
|
|
||
| Add `@metamask/messenger-docs` as a dev dependency, then add a script to your `package.json`: | ||
|
|
||
| ```json | ||
| { | ||
| "scripts": { | ||
| "docs:messenger": "messenger-docs --serve" | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| By default, the tool scans `src/` for `.ts` files and `node_modules/@metamask/` for `.d.cts` declaration files. If your project has source files in other directories, configure `scanDirs` in `package.json`: | ||
|
|
||
| ```json | ||
| { | ||
| "messenger-docs": { | ||
| "scanDirs": ["app", "src"] | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| Or pass `--scan-dir` flags: | ||
|
|
||
| ```bash | ||
| messenger-docs --scan-dir app --scan-dir shared --serve | ||
| ``` | ||
|
|
||
| ### CLI options | ||
|
|
||
| ``` | ||
| messenger-docs [project-path] [options] | ||
|
|
||
| Arguments: | ||
| project-path Path to the project to scan (default: current directory) | ||
|
|
||
| Options: | ||
| --build Generate docs and build static site | ||
| --serve Generate docs, build, and serve static site | ||
| --dev Generate docs and start dev server with hot reload | ||
| --scan-dir <dir> Extra source directory to scan (repeatable) | ||
| --output <dir> Output directory (default: <project-path>/.messenger-docs) | ||
| --help Show this help message | ||
| ``` | ||
|
|
||
| ## Contributing | ||
|
|
||
| This package is part of a monorepo. Instructions for contributing can be found in the [monorepo README](https://github.com/MetaMask/core#readme). |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| /* | ||
| * For a detailed explanation regarding each configuration property and type check, visit: | ||
| * https://jestjs.io/docs/configuration | ||
| */ | ||
|
|
||
| const merge = require('deepmerge'); | ||
| const path = require('path'); | ||
|
|
||
| const baseConfig = require('../../jest.config.packages'); | ||
|
|
||
| const displayName = path.basename(__dirname); | ||
|
|
||
| module.exports = merge(baseConfig, { | ||
| // The display name when running multiple projects | ||
| displayName, | ||
|
|
||
| // Allow running without any test files | ||
| passWithNoTests: true, | ||
|
|
||
| // An object that configures minimum threshold enforcement for coverage results | ||
| coverageThreshold: { | ||
| global: { | ||
| branches: 0, | ||
| functions: 0, | ||
| lines: 0, | ||
| statements: 0, | ||
| }, | ||
| }, | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about calling this "Deploy Platform API Docs" and calling this file
deploy-platform-api-docs.yml? Just want to make sure we stick with this terminology as much as we can.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed in 89832b1. The file is now
.github/workflows/deploy-platform-api-docs.ymland the workflow's display name is "Deploy Platform API Docs". The job names and step labels inside it also got updated from "Messenger API docs" → "Platform API docs" in 40ad9c3 (the package rename).