@metamask-previews/platform-api-docs 0.1.0-preview-abca9bcea → 0.2.0-preview-0a30e47

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/CHANGELOG.md +9 -1
  2. package/dist/cli.d.ts +3 -0
  3. package/dist/cli.d.ts.map +1 -0
  4. package/dist/{cli.mjs → cli.js} +10 -40
  5. package/dist/cli.js.map +1 -0
  6. package/dist/{extraction.d.cts → extraction.d.ts} +3 -3
  7. package/dist/extraction.d.ts.map +1 -0
  8. package/dist/{extraction.mjs → extraction.js} +3 -3
  9. package/dist/extraction.js.map +1 -0
  10. package/dist/{generate.d.cts → generate.d.ts} +2 -2
  11. package/dist/generate.d.ts.map +1 -0
  12. package/dist/{generate.mjs → generate.js} +10 -10
  13. package/dist/generate.js.map +1 -0
  14. package/dist/{markdown.d.cts → markdown.d.ts} +2 -2
  15. package/dist/markdown.d.ts.map +1 -0
  16. package/dist/{markdown.mjs → markdown.js} +1 -1
  17. package/dist/markdown.js.map +1 -0
  18. package/dist/{root-messenger-discovery.d.cts → root-messenger-discovery.d.ts} +2 -2
  19. package/dist/root-messenger-discovery.d.ts.map +1 -0
  20. package/dist/{root-messenger-discovery.mjs → root-messenger-discovery.js} +5 -5
  21. package/dist/root-messenger-discovery.js.map +1 -0
  22. package/dist/{ts-project.d.cts → ts-project.d.ts} +2 -2
  23. package/dist/ts-project.d.ts.map +1 -0
  24. package/dist/{ts-project.mjs → ts-project.js} +2 -2
  25. package/dist/ts-project.js.map +1 -0
  26. package/dist/{types.d.cts → types.d.ts} +1 -1
  27. package/dist/types.d.ts.map +1 -0
  28. package/dist/types.js +2 -0
  29. package/dist/types.js.map +1 -0
  30. package/package.json +12 -8
  31. package/dist/cli.cjs +0 -328
  32. package/dist/cli.cjs.map +0 -1
  33. package/dist/cli.d.cts +0 -3
  34. package/dist/cli.d.cts.map +0 -1
  35. package/dist/cli.d.mts +0 -3
  36. package/dist/cli.d.mts.map +0 -1
  37. package/dist/cli.mjs.map +0 -1
  38. package/dist/extraction.cjs +0 -754
  39. package/dist/extraction.cjs.map +0 -1
  40. package/dist/extraction.d.cts.map +0 -1
  41. package/dist/extraction.d.mts +0 -73
  42. package/dist/extraction.d.mts.map +0 -1
  43. package/dist/extraction.mjs.map +0 -1
  44. package/dist/generate.cjs +0 -505
  45. package/dist/generate.cjs.map +0 -1
  46. package/dist/generate.d.cts.map +0 -1
  47. package/dist/generate.d.mts +0 -70
  48. package/dist/generate.d.mts.map +0 -1
  49. package/dist/generate.mjs.map +0 -1
  50. package/dist/markdown.cjs +0 -239
  51. package/dist/markdown.cjs.map +0 -1
  52. package/dist/markdown.d.cts.map +0 -1
  53. package/dist/markdown.d.mts +0 -52
  54. package/dist/markdown.d.mts.map +0 -1
  55. package/dist/markdown.mjs.map +0 -1
  56. package/dist/root-messenger-discovery.cjs +0 -359
  57. package/dist/root-messenger-discovery.cjs.map +0 -1
  58. package/dist/root-messenger-discovery.d.cts.map +0 -1
  59. package/dist/root-messenger-discovery.d.mts +0 -61
  60. package/dist/root-messenger-discovery.d.mts.map +0 -1
  61. package/dist/root-messenger-discovery.mjs.map +0 -1
  62. package/dist/ts-project.cjs +0 -33
  63. package/dist/ts-project.cjs.map +0 -1
  64. package/dist/ts-project.d.cts.map +0 -1
  65. package/dist/ts-project.d.mts +0 -12
  66. package/dist/ts-project.d.mts.map +0 -1
  67. package/dist/ts-project.mjs.map +0 -1
  68. package/dist/types.cjs +0 -3
  69. package/dist/types.cjs.map +0 -1
  70. package/dist/types.d.cts.map +0 -1
  71. package/dist/types.d.mts +0 -47
  72. package/dist/types.d.mts.map +0 -1
  73. package/dist/types.mjs +0 -2
  74. package/dist/types.mjs.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"generate.mjs","sourceRoot":"","sources":["../src/generate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,6BAA6B;AACvD,OAAO,EAAE,QAAQ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M,EACpC,CAAC,CACF,CAAC;IACF,MAAM,WAAW,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,EAAE,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IAE9E,OAAO,CAAC,GAAG,CACT,sBAAsB,UAAU,CAAC,MAAM,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,YAAY,GAAG,CACnG,CAAC;IACF,OAAO,CAAC,GAAG,CAAC,cAAc,YAAY,EAAE,CAAC,CAAC;IAC1C,OAAO,CAAC,GAAG,CAAC,aAAa,WAAW,EAAE,CAAC,CAAC;IACxC,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;IAExD,OAAO;QACL,UAAU,EAAE,UAAU,CAAC,MAAM;QAC7B,OAAO,EAAE,YAAY;QACrB,MAAM,EAAE,WAAW;KACpB,CAAC;AACJ,CAAC","sourcesContent":["import { directoryExists } from '@metamask/utils/node';\nimport { execFile } from 'node:child_process';\nimport * as fs from 'node:fs/promises';\nimport * as path from 'node:path';\nimport { promisify } from 'node:util';\nimport type { Project } from 'ts-morph';\n\nimport { extractFromSourceFile } from './extraction.js';\nimport {\n generateIndexPage,\n generateNamespacePage,\n generateSidebars,\n} from './markdown.js';\nimport type { RootCapabilitiesTypeReference } from './root-messenger-discovery.js';\nimport { discoverFromRootMessengerCapabilitiesTypes } from './root-messenger-discovery.js';\nimport { createProject } from './ts-project.js';\nimport type { MessengerCapabilityPacket, NamespaceGroup } from './types.js';\n\n/** How many skipped capability types to name before summarizing the rest. */\nconst MAX_SKIPPED_SHOWN = 10;\n\n/**\n * Options for the `scan` strategy, which reads every `*Messenger` type alias\n * in every file it can find. Used when no single messenger aggregates every\n * capability.\n */\ntype ScanStrategyOptions = {\n /** The selected strategy. */\n strategy: 'scan';\n /** Directories, relative to the project root, to scan. */\n scanDirs: string[];\n};\n\n/**\n * Options for the `root-messenger` strategy, which walks the types a\n * project declares for its root messenger capabilities instead of scanning the\n * entire repo. Used when one messenger carries every action and event.\n */\ntype RootMessengerStrategyOptions = {\n /** The selected strategy. */\n strategy: 'root-messenger';\n /** The root messenger actions type reference. */\n rootActions: RootCapabilitiesTypeReference;\n /** The root messenger events type reference. */\n rootEvents: RootCapabilitiesTypeReference;\n};\n\n/**\n * Options for the generate function.\n */\nexport type GenerateOptions = {\n /** Absolute path to the project to scan. */\n projectPath: string;\n /** Absolute path to the output directory for generated docs. */\n outputDir: string;\n /**\n * Short label identifying the project the docs were generated from (e.g.\n * \"Core\", \"Extension\"). Stamped in the index page title.\n */\n projectLabel?: string | null;\n /**\n * Git commit SHA the docs were generated from. Stamped in the index page\n * intro so engineers know how current the site is.\n */\n commitSha?: string | null;\n} & (ScanStrategyOptions | RootMessengerStrategyOptions);\n\n/**\n * Result returned by the generate function.\n */\nexport type GenerateResult = {\n namespaces: number;\n actions: number;\n events: number;\n};\n\n/**\n * The set of directories available to scan for messenger types, resolved from\n * the project's filesystem layout.\n */\ntype ScanSources = {\n /** User-configured scan dirs that exist on disk (relative to projectPath). */\n scanDirs: string[];\n /** Absolute path to `packages/` if it exists, otherwise null. */\n packagesDir: string | null;\n /** Absolute path to `node_modules/@metamask/` if it exists, otherwise null. */\n nodeModulesDir: string | null;\n};\n\n/**\n * Compute a deduplication score for a messenger item, preferring items with\n * JSDoc and from the \"home\" package whose name matches the namespace.\n *\n * @param item - The messenger item to score.\n * @returns A numeric score (higher is better).\n */\nfunction deduplicationScore(item: MessengerCapabilityPacket): number {\n const jsDocScore = item.jsDoc ? 2 : 0;\n const namespacePrefix = item.typeString\n .split(':')[0]\n .replace(/(?:Controller|Service)$/u, '')\n .toLowerCase();\n const homeScore =\n namespacePrefix.length > 0 &&\n item.sourceFile.toLowerCase().includes(namespacePrefix)\n ? 1\n : 0;\n return jsDocScore + homeScore;\n}\n\nconst execFileAsync = promisify(execFile);\n\n/**\n * Resolve the default branch of a project's `origin` remote by reading the\n * symbolic ref `refs/remotes/origin/HEAD`. Falls back to `main` if the\n * symbolic ref isn't set (e.g. in shallow CI clones).\n *\n * @param projectPath - Absolute path to the project root.\n * @returns The default branch name (e.g. \"main\", \"master\", \"develop\").\n */\nasync function resolveDefaultBranch(projectPath: string): Promise<string> {\n try {\n const { stdout } = await execFileAsync(\n 'git',\n ['symbolic-ref', '--short', 'refs/remotes/origin/HEAD'],\n { cwd: projectPath },\n );\n // stdout looks like \"origin/main\"; strip the leading \"origin/\".\n const trimmed = stdout.trim();\n const slash = trimmed.indexOf('/');\n return slash === -1\n ? // istanbul ignore next: defensive — `symbolic-ref --short` always\n // returns `origin/<branch>` when the symbolic ref is set; this\n // fallback only matters if git's output format ever changes.\n trimmed || 'main'\n : trimmed.slice(slash + 1);\n } catch {\n return 'main';\n }\n}\n\n/**\n * Resolve the bare GitHub repository URL for a project by reading its\n * `origin` remote.\n *\n * @param projectPath - Absolute path to the project root.\n * @returns A URL like \"https://github.com/Owner/Repo\" or null when the remote\n * isn't a GitHub URL or can't be read.\n */\nexport async function resolveRepoUrl(\n projectPath: string,\n): Promise<string | null> {\n try {\n const { stdout: remoteRaw } = await execFileAsync(\n 'git',\n ['remote', 'get-url', 'origin'],\n { cwd: projectPath },\n );\n\n const remote = remoteRaw.trim();\n\n // Parse owner/repo from SSH or HTTPS remote URLs\n // Handles aliases like github.com-Org used in SSH configs\n const match = remote.match(\n /github\\.com[^:/]*[:/]([^/]+\\/[^/]+?)(?:\\.git)?$/u,\n );\n if (!match) {\n return null;\n }\n\n return `https://github.com/${match[1]}`;\n } catch {\n return null;\n }\n}\n\n/**\n * Resolve the GitHub blob base URL used for per-line source links.\n *\n * Prefers the documented commit SHA when one is available so the links point\n * at the exact revision the docs were generated from; falls back to the\n * default branch otherwise.\n *\n * @param projectPath - Absolute path to the project root.\n * @param commitSha - Optional commit SHA to use as the ref. When null, the\n * default branch is used instead.\n * @returns A base URL like \"https://github.com/Owner/Repo/blob/<ref>/\" or null.\n */\nasync function resolveRepoBaseUrl(\n projectPath: string,\n commitSha: string | null,\n): Promise<string | null> {\n const repoUrl = await resolveRepoUrl(projectPath);\n if (!repoUrl) {\n return null;\n }\n const ref = commitSha ?? (await resolveDefaultBranch(projectPath));\n return `${repoUrl}/blob/${ref}/`;\n}\n\n/**\n * Discover which configured source locations actually exist on disk.\n *\n * @param projectPath - The project root path.\n * @param scanDirs - User-configured scan directories relative to projectPath.\n * @returns A ScanSources object describing the locations to scan.\n */\nasync function discoverScanSources(\n projectPath: string,\n scanDirs: string[],\n): Promise<ScanSources> {\n const existingScanDirs: string[] = [];\n for (const dir of scanDirs) {\n if (await directoryExists(path.join(projectPath, dir))) {\n existingScanDirs.push(dir);\n }\n }\n\n const packagesDir = path.join(projectPath, 'packages');\n const nodeModulesDir = path.join(projectPath, 'node_modules', '@metamask');\n\n return {\n scanDirs: existingScanDirs,\n packagesDir: (await directoryExists(packagesDir)) ? packagesDir : null,\n nodeModulesDir: (await directoryExists(nodeModulesDir))\n ? nodeModulesDir\n : null,\n };\n}\n\n/**\n * Log a human-readable description of which source locations will be scanned.\n *\n * @param sources - The resolved scan sources.\n */\nfunction logScanPlan(sources: ScanSources): void {\n const summary: string[] = [];\n for (const dir of sources.scanDirs) {\n summary.push(`${dir}/ (.ts)`);\n }\n if (sources.packagesDir) {\n summary.push('packages/*/src (.ts)');\n }\n if (sources.nodeModulesDir) {\n summary.push('node_modules/@metamask/*/dist (.d.cts)');\n }\n console.log(\n `Scanning ${summary.join(', ')} for Messenger action/event types...`,\n );\n}\n\n/**\n * Patterns excluded when scanning TypeScript sources: build output, tests, and\n * declaration files (which are only read under `node_modules/@metamask`, via\n * the separate set below).\n *\n * Every pattern is anchored to `root` rather than written as a bare\n * `!**‍/*.test.ts`. A matcher resolves an unanchored negation against the\n * process's working directory, not against the pattern it accompanies, so an\n * unanchored exclusion silently stops excluding anything the moment the scanned\n * path falls outside the working directory — which is the normal case, since\n * this runs from wherever the consumer invoked it.\n *\n * `contentRoot` must be the directory the matched *files* live under, not an\n * ancestor of it. Anchoring at `packages/` rather than `packages/*‍/src` would\n * make the first path segment a package name, so a workspace package called\n * `test` or `dist` would match `test/**` and be dropped whole.\n *\n * @param contentRoot - Resolved directory, or directory glob, that the matched\n * files live directly under.\n * @returns The exclusion patterns.\n */\nfunction buildTsSourceExclusions(contentRoot: string): string[] {\n return [\n 'node_modules/**',\n 'dist/**',\n '__tests__/**',\n 'tests/**',\n 'test/**',\n '__mocks__/**',\n '*.test.ts',\n '*.test-d.ts',\n '*.spec.ts',\n '*.d.ts',\n ].map((pattern) => `!${contentRoot}/**/${pattern}`);\n}\n\n/**\n * Add every file matching a set of glob patterns to the project, in a stable\n * order.\n *\n * ts-morph promises nothing about the order it returns matches in, and\n * deduplication downstream keeps the first of two equally-scored items, so an\n * unsorted list would let the filesystem decide which source link a capability\n * gets.\n *\n * Ordering is by code unit rather than `localeCompare`, which collates\n * differently depending on the locale the process happens to run under.\n *\n * @param project - The shared ts-morph project.\n * @param patterns - Glob patterns to match, including `!` exclusions.\n * @returns The added source files, sorted by path.\n */\nfunction addSourceFiles(\n project: Project,\n patterns: string[],\n): ReturnType<Project['addSourceFilesAtPaths']> {\n return project.addSourceFilesAtPaths(patterns).sort(\n (fileA, fileB) =>\n // Subtracting the two comparisons keeps this branchless, so it reads\n // the same whichever order the matcher happened to return.\n Number(fileA.getFilePath() > fileB.getFilePath()) -\n Number(fileA.getFilePath() < fileB.getFilePath()),\n );\n}\n\n/**\n * Build a glob pattern from a directory path.\n *\n * Two things have to be true of the result. Glob syntax is always\n * forward-slashed, including on Windows, where `path.join` would produce\n * backslashes that a matcher reads as escapes. And the path must be fully\n * resolved: the matcher does not follow a symlinked *ancestor* of the pattern,\n * so a project under `/tmp` or `/var` on macOS (both symlinks) would match\n * nothing at all.\n *\n * @param segments - Path segments to join.\n * @returns The joined, resolved path with forward slashes.\n */\nasync function toGlobPath(...segments: string[]): Promise<string> {\n // Safe to resolve without a fallback: `discoverScanSources` has already\n // confirmed every directory reaching this point exists.\n const resolved = await fs.realpath(path.join(...segments));\n return resolved.replace(/\\\\/gu, '/');\n}\n\n/**\n * Scan every source location described by `sources` (scan directories first,\n * then workspace packages, then published declaration files) and return all\n * extracted messenger items.\n *\n * A single ts-morph Project is shared across every file so the type checker can\n * resolve cross-file references (e.g. a `*Messenger` declaration in one file\n * walking through an imported umbrella union into an auto-generated\n * `*-method-action-types.ts` sibling).\n *\n * @param projectPath - The project root path.\n * @param sources - The set of source locations to scan.\n * @returns A flat list of all extracted messenger items.\n */\nasync function scanSources(\n projectPath: string,\n sources: ScanSources,\n): Promise<MessengerCapabilityPacket[]> {\n const project = createProject();\n const sourceFiles = [];\n\n for (const dir of sources.scanDirs) {\n const root = await toGlobPath(projectPath, dir);\n sourceFiles.push(\n ...addSourceFiles(project, [\n `${root}/**/*.ts`,\n ...buildTsSourceExclusions(root),\n ]),\n );\n }\n\n if (sources.packagesDir) {\n const root = await toGlobPath(sources.packagesDir);\n // Anchored at each package's `src`, not at `packages` itself, so a package\n // whose name collides with an exclusion (`test`, `dist`) isn't dropped.\n const contentRoot = `${root}/*/src`;\n sourceFiles.push(\n ...addSourceFiles(project, [\n `${contentRoot}/**/*.ts`,\n ...buildTsSourceExclusions(contentRoot),\n ]),\n );\n }\n\n if (sources.nodeModulesDir) {\n const root = await toGlobPath(sources.nodeModulesDir);\n sourceFiles.push(...addSourceFiles(project, [`${root}/*/dist/**/*.d.cts`]));\n }\n\n // Matched paths are fully resolved, so the root they are made relative to\n // has to be resolved the same way or every source link becomes a `../..`\n // walk out of the project.\n const resolvedProjectPath = await fs.realpath(projectPath);\n\n const allItems: MessengerCapabilityPacket[] = [];\n for (const sourceFile of sourceFiles) {\n allItems.push(...extractFromSourceFile(sourceFile, resolvedProjectPath));\n }\n return allItems;\n}\n\n/**\n * Replace a previously-seen item in its existing namespace group with a\n * higher-scoring duplicate. Handles the case where the duplicate is a\n * different kind (action vs event) by moving it between lists.\n *\n * @param byNamespace - Map of namespace to its group.\n * @param previous - The previously stored item.\n * @param replacement - The new item to replace it with.\n */\nfunction replaceDuplicateInGroup(\n byNamespace: Map<string, NamespaceGroup>,\n previous: MessengerCapabilityPacket,\n replacement: MessengerCapabilityPacket,\n): void {\n const namespace = replacement.typeString.split(':')[0];\n const group = byNamespace.get(namespace);\n // istanbul ignore next: `previous` and `replacement` have the same\n // typeString, so they share a namespace, and we always insert the\n // namespace into `byNamespace` before recording the original entry.\n if (!group) {\n return;\n }\n const previousList =\n previous.kind === 'action' ? group.actions : group.events;\n const index = previousList.indexOf(previous);\n // istanbul ignore next: `previous` was added to its kind's list by\n // `groupByNamespace` before being recorded in `seen`, so it is always\n // present when we look it up here.\n if (index === -1) {\n return;\n }\n if (previous.kind === replacement.kind) {\n previousList[index] = replacement;\n } else {\n previousList.splice(index, 1);\n const newList =\n replacement.kind === 'action' ? group.actions : group.events;\n newList.push(replacement);\n }\n}\n\n/**\n * Group items by namespace, deduplicating duplicate typeStrings using\n * `deduplicationScore`. Returns groups sorted alphabetically by namespace,\n * with each group's items sorted alphabetically by typeString.\n *\n * @param items - The full list of extracted items.\n * @returns The deduplicated and sorted namespace groups.\n */\nfunction groupByNamespace(\n items: MessengerCapabilityPacket[],\n): NamespaceGroup[] {\n const byNamespace = new Map<string, NamespaceGroup>();\n const seen = new Map<string, MessengerCapabilityPacket>();\n\n for (const item of items) {\n const existing = seen.get(item.typeString);\n if (existing) {\n if (deduplicationScore(item) <= deduplicationScore(existing)) {\n continue;\n }\n replaceDuplicateInGroup(byNamespace, existing, item);\n seen.set(item.typeString, item);\n continue;\n }\n\n seen.set(item.typeString, item);\n const namespace = item.typeString.split(':')[0];\n let group = byNamespace.get(namespace);\n if (!group) {\n group = { namespace, actions: [], events: [] };\n byNamespace.set(namespace, group);\n }\n if (item.kind === 'action') {\n group.actions.push(item);\n } else {\n group.events.push(item);\n }\n }\n\n const namespaces = Array.from(byNamespace.values()).sort((a, b) =>\n a.namespace.localeCompare(b.namespace),\n );\n\n for (const ns of namespaces) {\n ns.actions.sort((a, b) => a.typeString.localeCompare(b.typeString));\n ns.events.sort((a, b) => a.typeString.localeCompare(b.typeString));\n }\n\n return namespaces;\n}\n\n/**\n * Write generated docs (namespace pages, index page, sidebars) to disk,\n * replacing any existing `docs/` directory.\n *\n * @param namespaces - The grouped namespaces to render.\n * @param outputDir - The root output directory.\n * @param repoBaseUrl - GitHub blob base URL for source links, or null.\n * @param indexOptions - Options stamped on the index page header.\n * @param indexOptions.projectLabel - Short label identifying the project.\n * @param indexOptions.commitSha - Git commit SHA the docs were generated from.\n * @returns Promise that resolves once all files are written.\n */\nasync function writeOutput(\n namespaces: NamespaceGroup[],\n outputDir: string,\n repoBaseUrl: string | null,\n indexOptions: {\n projectLabel?: string | null;\n commitSha?: string | null;\n },\n): Promise<void> {\n const docsDir = path.join(outputDir, 'docs');\n\n if (await directoryExists(docsDir)) {\n await fs.rm(docsDir, { recursive: true });\n }\n await fs.mkdir(docsDir, { recursive: true });\n\n for (const ns of namespaces) {\n const nsDir = path.join(docsDir, ns.namespace);\n await fs.mkdir(nsDir, { recursive: true });\n\n if (ns.actions.length > 0) {\n await fs.writeFile(\n path.join(nsDir, 'actions.md'),\n generateNamespacePage(ns, 'action', repoBaseUrl),\n );\n }\n\n if (ns.events.length > 0) {\n await fs.writeFile(\n path.join(nsDir, 'events.md'),\n generateNamespacePage(ns, 'event', repoBaseUrl),\n );\n }\n }\n\n await fs.writeFile(\n path.join(docsDir, 'index.md'),\n generateIndexPage(namespaces, indexOptions),\n );\n\n await fs.writeFile(\n path.join(outputDir, 'sidebars.ts'),\n generateSidebars(namespaces),\n );\n}\n\n/**\n * Collect capabilities by scanning the project's files.\n *\n * @param projectPath - The project root path.\n * @param scanDirs - Directories (relative to projectPath) to scan.\n * @returns The extracted capabilities.\n * @throws If the project has no scannable directories at all.\n */\nasync function collectByScanning(\n projectPath: string,\n scanDirs: string[],\n): Promise<MessengerCapabilityPacket[]> {\n const sources = await discoverScanSources(projectPath, scanDirs);\n\n if (\n sources.scanDirs.length === 0 &&\n !sources.packagesDir &&\n !sources.nodeModulesDir\n ) {\n throw new Error(\n `No scannable directories found in ${projectPath}. ` +\n `Looked for: ${scanDirs.join(', ')}, packages/, node_modules/@metamask/`,\n );\n }\n\n logScanPlan(sources);\n\n return await scanSources(projectPath, sources);\n}\n\n/**\n * Using the project's root messenger capability collection types as\n * entrypoints, collect the constituent individual capability types and package\n * them so that they can be displayed within the documentation site.\n *\n * @param projectPath - The project root path.\n * @param options - The root-messenger strategy options.\n * @returns The extracted capabilities.\n */\nfunction collectFromRootMessengerCapabilities(\n projectPath: string,\n options: RootMessengerStrategyOptions,\n): MessengerCapabilityPacket[] {\n const { rootActions, rootEvents } = options;\n\n console.log(\n `Resolving actions from ${rootActions.filePath}#${rootActions.typeName} ` +\n `and events from ${rootEvents.filePath}#${rootEvents.typeName}...`,\n );\n\n const { capabilityPackets, skippedCapabilities } =\n discoverFromRootMessengerCapabilitiesTypes({\n projectPath,\n rootActionsTypeReference: rootActions,\n rootEventsTypeReference: rootEvents,\n });\n\n // Report rather than drop silently: a jump in any of these usually means the\n // project changed how it declares its capabilities.\n warnSkipped(\n 'declared inline, with no name to document',\n skippedCapabilities.unnamedCapabilities,\n );\n warnSkipped(\n 'whose shape could not be read',\n skippedCapabilities.unextractableCapabilities,\n );\n\n // If both capability collection types resolve to nothing, it's always a\n // misconfiguration (a wrong type name, or imports that didn't resolve).\n // Failing here matters because generation would otherwise replace an existing\n // docs directory with an empty one and exit successfully.\n if (capabilityPackets.length === 0) {\n throw new Error(\n `No messenger actions or events found in ` +\n `${rootActions.filePath}#${rootActions.typeName} or ` +\n `${rootEvents.filePath}#${rootEvents.typeName}. ` +\n `Check that these types name the collections carrying every ` +\n `capability, and that their imports resolve.`,\n );\n }\n\n return capabilityPackets;\n}\n\n/**\n * Warn about capability types that couldn't be documented, naming them so the\n * warning is actionable.\n *\n * @param description - Why they were skipped, as a noun phrase.\n * @param labels - Labels identifying each skipped type.\n */\nfunction warnSkipped(description: string, labels: string[]): void {\n if (labels.length === 0) {\n return;\n }\n\n const shown = labels.slice(0, MAX_SKIPPED_SHOWN);\n const remaining = labels.length - shown.length;\n console.warn(\n `Warning: skipped ${labels.length} capability ` +\n `${labels.length === 1 ? 'type' : 'types'} ${description}: ` +\n `${shown.join(', ')}${remaining > 0 ? `, and ${remaining} more` : ''}`,\n );\n}\n\n/**\n * Scan a project for messenger action/event types and generate documentation.\n *\n * @param options - Generation options.\n * @returns A promise resolving to counts of generated namespaces, actions, and events.\n */\nexport async function generate(\n options: GenerateOptions,\n): Promise<GenerateResult> {\n const { projectPath, outputDir, projectLabel, commitSha } = options;\n\n const allItems =\n options.strategy === 'root-messenger'\n ? collectFromRootMessengerCapabilities(projectPath, options)\n : await collectByScanning(projectPath, options.scanDirs);\n\n console.log(\n `Found ${allItems.length} messenger ${allItems.length === 1 ? 'item' : 'items'} total.`,\n );\n\n const namespaces = groupByNamespace(allItems);\n const repoBaseUrl = await resolveRepoBaseUrl(projectPath, commitSha ?? null);\n\n await writeOutput(namespaces, outputDir, repoBaseUrl, {\n projectLabel,\n commitSha,\n });\n\n const totalActions = namespaces.reduce(\n (sum, ns) => sum + ns.actions.length,\n 0,\n );\n const totalEvents = namespaces.reduce((sum, ns) => sum + ns.events.length, 0);\n\n console.log(\n `Generated docs for ${namespaces.length} ${namespaces.length === 1 ? 'namespace' : 'namespaces'}.`,\n );\n console.log(` Actions: ${totalActions}`);\n console.log(` Events: ${totalEvents}`);\n console.log(`Output: ${path.join(outputDir, 'docs')}/`);\n\n return {\n namespaces: namespaces.length,\n actions: totalActions,\n events: totalEvents,\n };\n}\n"]}
package/dist/markdown.cjs DELETED
@@ -1,239 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generateSidebars = exports.generateIndexPage = exports.generateNamespacePage = exports.generateItemMarkdown = void 0;
4
- /**
5
- * Convert backtick-quoted action/event names in text into links when they
6
- * match a known item in the same namespace. For example, `` `setActiveNetwork` ``
7
- * becomes a link to `#networkcontrollersetactivenetwork` on the actions page.
8
- *
9
- * @param text - The markdown text to process.
10
- * @param namespace - The current namespace (e.g. "NetworkController").
11
- * @param knownNames - Map from short name (e.g. "setActiveNetwork") to the page-relative path and anchor.
12
- * @returns The text with backtick references replaced by links.
13
- */
14
- function linkifyReferences(text, namespace, knownNames) {
15
- return text.replace(/`([a-zA-Z]\w*)`/gu, (match, name) => {
16
- const link = knownNames.get(name);
17
- if (link) {
18
- return `[\`${name}\`](${link})`;
19
- }
20
- // Also try with namespace prefix (e.g. "NetworkController:setActiveNetwork")
21
- const fullName = `${namespace}:${name}`;
22
- const anchor = fullName.toLowerCase().replace(/[^a-z0-9]/gu, '');
23
- const linkFull = knownNames.get(fullName);
24
- if (linkFull) {
25
- return `[\`${name}\`](${linkFull})`;
26
- }
27
- // Check if the anchor matches exactly in known names values
28
- for (const [, href] of knownNames) {
29
- if (href.endsWith(`#${anchor}`)) {
30
- return `[\`${name}\`](${href})`;
31
- }
32
- }
33
- return match;
34
- });
35
- }
36
- /**
37
- * Generate markdown documentation for a single messenger item.
38
- *
39
- * @param item - The messenger item to document.
40
- * @param namespace - The current namespace.
41
- * @param knownNames - Map from short/full names to their link paths.
42
- * @param repoBaseUrl - Optional GitHub blob base URL (e.g. "https://github.com/Owner/Repo/blob/sha/").
43
- * @returns The generated markdown string.
44
- */
45
- function generateItemMarkdown(item, namespace, knownNames, repoBaseUrl) {
46
- const parts = [];
47
- parts.push(`### \`${item.typeString}\``);
48
- parts.push('');
49
- if (item.deprecated) {
50
- parts.push('> **Deprecated**');
51
- parts.push('');
52
- }
53
- // For sources scanned out of an @metamask/*/dist directory we render an
54
- // npm link, since the original .ts paths are not part of the repo we're
55
- // documenting. Other `node_modules/` paths fall through to the normal
56
- // source-link branches.
57
- const metamaskPkgMatch = item.sourceFile.match(/node_modules\/(@metamask\/[^/]+)/u);
58
- if (metamaskPkgMatch) {
59
- const pkgName = metamaskPkgMatch[1];
60
- const npmUrl = `https://www.npmjs.com/package/${pkgName}`;
61
- parts.push(`**Package**: [\`${pkgName}\`](${npmUrl})`);
62
- }
63
- else if (repoBaseUrl) {
64
- const ghUrl = `${repoBaseUrl}${item.sourceFile}#L${item.line}`;
65
- parts.push(`**Source**: [${item.sourceFile}:${item.line}](${ghUrl})`);
66
- }
67
- else {
68
- parts.push(`**Source**: \`${item.sourceFile}:${item.line}\``);
69
- }
70
- parts.push('');
71
- if (item.jsDoc) {
72
- parts.push(linkifyReferences(item.jsDoc, namespace, knownNames));
73
- parts.push('');
74
- }
75
- // Only actions get a parameters table — events carry a positional tuple
76
- // payload, not named arguments, so a `@param` table doesn't fit.
77
- if (item.kind === 'action' && item.params.length > 0) {
78
- parts.push('**Parameters**:');
79
- parts.push('');
80
- parts.push('| Name | Description |');
81
- parts.push('|------|-------------|');
82
- for (const param of item.params) {
83
- const description = linkifyReferences(param.description, namespace, knownNames);
84
- parts.push(`| \`${param.name}\` | ${description} |`);
85
- }
86
- parts.push('');
87
- }
88
- if (item.kind === 'action' && item.returns) {
89
- parts.push(`**Returns**: ${linkifyReferences(item.returns, namespace, knownNames)}`);
90
- parts.push('');
91
- }
92
- const signatureLabel = item.kind === 'action' ? 'Handler' : 'Payload';
93
- parts.push(`**${signatureLabel} signature**:`);
94
- parts.push('');
95
- parts.push('```typescript');
96
- parts.push(item.handlerOrPayload);
97
- parts.push('```');
98
- parts.push('');
99
- return parts.join('\n');
100
- }
101
- exports.generateItemMarkdown = generateItemMarkdown;
102
- /**
103
- * Generate a full markdown page for a namespace's actions or events.
104
- *
105
- * @param ns - The namespace group to generate a page for.
106
- * @param kind - Whether to generate the actions or events page.
107
- * @param repoBaseUrl - Optional GitHub blob base URL for source links.
108
- * @returns The generated markdown string.
109
- */
110
- function generateNamespacePage(ns, kind, repoBaseUrl = null) {
111
- const items = kind === 'action' ? ns.actions : ns.events;
112
- const title = kind === 'action' ? 'Actions' : 'Events';
113
- const parts = [];
114
- parts.push('---');
115
- parts.push(`title: "${ns.namespace} ${title}"`);
116
- parts.push(`sidebar_label: "${title}"`);
117
- parts.push('---');
118
- parts.push('');
119
- parts.push(`# ${ns.namespace} ${title}`);
120
- parts.push('');
121
- if (items.length === 0) {
122
- parts.push(`_No ${kind}s found for this namespace._`);
123
- parts.push('');
124
- return parts.join('\n');
125
- }
126
- parts.push(`${items.length} ${kind}${items.length === 1 ? '' : 's'} registered.`);
127
- parts.push('');
128
- // Build a map of known names → link paths for cross-referencing.
129
- // Actions on same page get #anchor, actions/events on sibling page get relative path.
130
- const knownNames = new Map();
131
- for (const action of ns.actions) {
132
- const shortName = action.typeString.split(':')[1];
133
- const anchor = action.typeString.toLowerCase().replace(/[^a-z0-9]/gu, '');
134
- const href = kind === 'action' ? `#${anchor}` : `./actions#${anchor}`;
135
- knownNames.set(shortName, href);
136
- knownNames.set(action.typeString, href);
137
- }
138
- for (const event of ns.events) {
139
- const shortName = event.typeString.split(':')[1];
140
- const anchor = event.typeString.toLowerCase().replace(/[^a-z0-9]/gu, '');
141
- const href = kind === 'event' ? `#${anchor}` : `./events#${anchor}`;
142
- knownNames.set(shortName, href);
143
- knownNames.set(event.typeString, href);
144
- }
145
- // Table of contents
146
- parts.push('| Name | Deprecated |');
147
- parts.push('|------|-----------|');
148
- for (const item of items) {
149
- const name = item.typeString.split(':')[1];
150
- // Docusaurus uses github-slugger: strips non-alphanumeric, lowercases, no dashes for special chars in code spans
151
- const anchor = item.typeString.toLowerCase().replace(/[^a-z0-9]/gu, '');
152
- const dep = item.deprecated ? 'Yes' : '';
153
- parts.push(`| [\`${name}\`](#${anchor}) | ${dep} |`);
154
- }
155
- parts.push('');
156
- parts.push('---');
157
- parts.push('');
158
- for (const item of items) {
159
- parts.push(generateItemMarkdown(item, ns.namespace, knownNames, repoBaseUrl));
160
- parts.push('---');
161
- parts.push('');
162
- }
163
- return parts.join('\n');
164
- }
165
- exports.generateNamespacePage = generateNamespacePage;
166
- /**
167
- * Generate the index/overview page listing all namespaces.
168
- *
169
- * @param namespaces - All namespace groups sorted alphabetically.
170
- * @param options - Optional project label and commit SHA to stamp in the header.
171
- * @returns The generated markdown string.
172
- */
173
- function generateIndexPage(namespaces, options = {}) {
174
- const totalActions = namespaces.reduce((sum, ns) => sum + ns.actions.length, 0);
175
- const totalEvents = namespaces.reduce((sum, ns) => sum + ns.events.length, 0);
176
- const projectSuffix = options.projectLabel
177
- ? ` (${options.projectLabel})`
178
- : '';
179
- const parts = [];
180
- parts.push('---');
181
- parts.push(`title: "Platform API${projectSuffix} Reference"`);
182
- parts.push('slug: "/"');
183
- parts.push('---');
184
- parts.push('');
185
- parts.push(`# Platform API${projectSuffix}`);
186
- parts.push('');
187
- parts.push('This site documents every action and event registered on the Messenger — the type-safe message bus used across all controllers.');
188
- parts.push('');
189
- if (options.commitSha) {
190
- parts.push(`Generated from commit \`${options.commitSha}\`.`);
191
- parts.push('');
192
- }
193
- parts.push(`- **${namespaces.length}** namespaces`);
194
- parts.push(`- **${totalActions}** actions`);
195
- parts.push(`- **${totalEvents}** events`);
196
- parts.push('');
197
- parts.push('## Namespaces');
198
- parts.push('');
199
- parts.push('| Namespace | Actions | Events |');
200
- parts.push('|-----------|---------|--------|');
201
- for (const ns of namespaces) {
202
- const firstLink = ns.actions.length > 0
203
- ? `${ns.namespace}/actions`
204
- : `${ns.namespace}/events`;
205
- parts.push(`| [${ns.namespace}](${firstLink}) | ${ns.actions.length} | ${ns.events.length} |`);
206
- }
207
- parts.push('');
208
- return parts.join('\n');
209
- }
210
- exports.generateIndexPage = generateIndexPage;
211
- /**
212
- * Generate the sidebars.ts file content for Docusaurus.
213
- *
214
- * @param namespaces - All namespace groups sorted alphabetically.
215
- * @returns The generated TypeScript source string.
216
- */
217
- function generateSidebars(namespaces) {
218
- const items = namespaces.map((ns) => ({
219
- type: 'category',
220
- label: ns.namespace,
221
- items: [
222
- ...(ns.actions.length > 0 ? [`${ns.namespace}/actions`] : []),
223
- ...(ns.events.length > 0 ? [`${ns.namespace}/events`] : []),
224
- ],
225
- }));
226
- const sidebar = {
227
- messengerSidebar: [
228
- {
229
- type: 'doc',
230
- id: 'index',
231
- label: 'Overview',
232
- },
233
- ...items,
234
- ],
235
- };
236
- return `// This file is auto-generated by @metamask/platform-api-docs\n// Do not edit manually.\nconst sidebars = ${JSON.stringify(sidebar, null, 2)};\nexport default sidebars;\n`;
237
- }
238
- exports.generateSidebars = generateSidebars;
239
- //# sourceMappingURL=markdown.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"markdown.cjs","sourceRoot":"","sources":["../src/markdown.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;GASG;AACH,SAAS,iBAAiB,CACxB,IAAY,EACZ,SAAiB,EACjB,UAA+B;IAE/B,OAAO,IAAI,CAAC,OAAO,CAAC,mBAAmB,EAAE,CAAC,KAAK,EAAE,IAAY,EAAE,EAAE;QAC/D,MAAM,IAAI,GAAG,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAClC,IAAI,IAAI,EAAE,CAAC;YACT,OAAO,MAAM,IAAI,OAAO,IAAI,GAAG,CAAC;QAClC,CAAC;QACD,6EAA6E;QAC7E,MAAM,QAAQ,GAAG,GAAG,SAAS,IAAI,IAAI,EAAE,CAAC;QACxC,MAAM,MAAM,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC;QACjE,MAAM,QAAQ,GAAG,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC1C,IAAI,QAAQ,EAAE,CAAC;YACb,OAAO,MAAM,IAAI,OAAO,QAAQ,GAAG,CAAC;QACtC,CAAC;QACD,4DAA4D;QAC5D,KAAK,MAAM,CAAC,EAAE,IAAI,CAAC,IAAI,UAAU,EAAE,CAAC;YAClC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,MAAM,EAA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E,EAAE,CAAC,CAAC;QACpC,IAAI,EAAE,UAAU;QAChB,KAAK,EAAE,EAAE,CAAC,SAAS;QACnB,KAAK,EAAE;YACL,GAAG,CAAC,EAAE,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,SAAS,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAC7D,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,SAAS,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;SAC5D;KACF,CAAC,CAAC,CAAC;IAEJ,MAAM,OAAO,GAAG;QACd,gBAAgB,EAAE;YAChB;gBACE,IAAI,EAAE,KAAK;gBACX,EAAE,EAAE,OAAO;gBACX,KAAK,EAAE,UAAU;aAClB;YACD,GAAG,KAAK;SACT;KACF,CAAC;IAEF,OAAO,6GAA6G,IAAI,CAAC,SAAS,CAChI,OAAO,EACP,IAAI,EACJ,CAAC,CACF,+BAA+B,CAAC;AACnC,CAAC;AA1BD,4CA0BC","sourcesContent":["import type { MessengerCapabilityPacket, NamespaceGroup } from './types.js';\n\n/**\n * Convert backtick-quoted action/event names in text into links when they\n * match a known item in the same namespace. For example, `` `setActiveNetwork` ``\n * becomes a link to `#networkcontrollersetactivenetwork` on the actions page.\n *\n * @param text - The markdown text to process.\n * @param namespace - The current namespace (e.g. \"NetworkController\").\n * @param knownNames - Map from short name (e.g. \"setActiveNetwork\") to the page-relative path and anchor.\n * @returns The text with backtick references replaced by links.\n */\nfunction linkifyReferences(\n text: string,\n namespace: string,\n knownNames: Map<string, string>,\n): string {\n return text.replace(/`([a-zA-Z]\\w*)`/gu, (match, name: string) => {\n const link = knownNames.get(name);\n if (link) {\n return `[\\`${name}\\`](${link})`;\n }\n // Also try with namespace prefix (e.g. \"NetworkController:setActiveNetwork\")\n const fullName = `${namespace}:${name}`;\n const anchor = fullName.toLowerCase().replace(/[^a-z0-9]/gu, '');\n const linkFull = knownNames.get(fullName);\n if (linkFull) {\n return `[\\`${name}\\`](${linkFull})`;\n }\n // Check if the anchor matches exactly in known names values\n for (const [, href] of knownNames) {\n if (href.endsWith(`#${anchor}`)) {\n return `[\\`${name}\\`](${href})`;\n }\n }\n return match;\n });\n}\n\n/**\n * Generate markdown documentation for a single messenger item.\n *\n * @param item - The messenger item to document.\n * @param namespace - The current namespace.\n * @param knownNames - Map from short/full names to their link paths.\n * @param repoBaseUrl - Optional GitHub blob base URL (e.g. \"https://github.com/Owner/Repo/blob/sha/\").\n * @returns The generated markdown string.\n */\nexport function generateItemMarkdown(\n item: MessengerCapabilityPacket,\n namespace: string,\n knownNames: Map<string, string>,\n repoBaseUrl: string | null,\n): string {\n const parts: string[] = [];\n\n parts.push(`### \\`${item.typeString}\\``);\n parts.push('');\n\n if (item.deprecated) {\n parts.push('> **Deprecated**');\n parts.push('');\n }\n\n // For sources scanned out of an @metamask/*/dist directory we render an\n // npm link, since the original .ts paths are not part of the repo we're\n // documenting. Other `node_modules/` paths fall through to the normal\n // source-link branches.\n const metamaskPkgMatch = item.sourceFile.match(\n /node_modules\\/(@metamask\\/[^/]+)/u,\n );\n if (metamaskPkgMatch) {\n const pkgName = metamaskPkgMatch[1];\n const npmUrl = `https://www.npmjs.com/package/${pkgName}`;\n parts.push(`**Package**: [\\`${pkgName}\\`](${npmUrl})`);\n } else if (repoBaseUrl) {\n const ghUrl = `${repoBaseUrl}${item.sourceFile}#L${item.line}`;\n parts.push(`**Source**: [${item.sourceFile}:${item.line}](${ghUrl})`);\n } else {\n parts.push(`**Source**: \\`${item.sourceFile}:${item.line}\\``);\n }\n parts.push('');\n\n if (item.jsDoc) {\n parts.push(linkifyReferences(item.jsDoc, namespace, knownNames));\n parts.push('');\n }\n\n // Only actions get a parameters table — events carry a positional tuple\n // payload, not named arguments, so a `@param` table doesn't fit.\n if (item.kind === 'action' && item.params.length > 0) {\n parts.push('**Parameters**:');\n parts.push('');\n parts.push('| Name | Description |');\n parts.push('|------|-------------|');\n for (const param of item.params) {\n const description = linkifyReferences(\n param.description,\n namespace,\n knownNames,\n );\n parts.push(`| \\`${param.name}\\` | ${description} |`);\n }\n parts.push('');\n }\n\n if (item.kind === 'action' && item.returns) {\n parts.push(\n `**Returns**: ${linkifyReferences(item.returns, namespace, knownNames)}`,\n );\n parts.push('');\n }\n\n const signatureLabel = item.kind === 'action' ? 'Handler' : 'Payload';\n parts.push(`**${signatureLabel} signature**:`);\n parts.push('');\n parts.push('```typescript');\n parts.push(item.handlerOrPayload);\n parts.push('```');\n parts.push('');\n\n return parts.join('\\n');\n}\n\n/**\n * Generate a full markdown page for a namespace's actions or events.\n *\n * @param ns - The namespace group to generate a page for.\n * @param kind - Whether to generate the actions or events page.\n * @param repoBaseUrl - Optional GitHub blob base URL for source links.\n * @returns The generated markdown string.\n */\nexport function generateNamespacePage(\n ns: NamespaceGroup,\n kind: 'action' | 'event',\n repoBaseUrl: string | null = null,\n): string {\n const items = kind === 'action' ? ns.actions : ns.events;\n const title = kind === 'action' ? 'Actions' : 'Events';\n const parts: string[] = [];\n\n parts.push('---');\n parts.push(`title: \"${ns.namespace} ${title}\"`);\n parts.push(`sidebar_label: \"${title}\"`);\n parts.push('---');\n parts.push('');\n parts.push(`# ${ns.namespace} ${title}`);\n parts.push('');\n\n if (items.length === 0) {\n parts.push(`_No ${kind}s found for this namespace._`);\n parts.push('');\n return parts.join('\\n');\n }\n\n parts.push(\n `${items.length} ${kind}${items.length === 1 ? '' : 's'} registered.`,\n );\n parts.push('');\n\n // Build a map of known names → link paths for cross-referencing.\n // Actions on same page get #anchor, actions/events on sibling page get relative path.\n const knownNames = new Map<string, string>();\n for (const action of ns.actions) {\n const shortName = action.typeString.split(':')[1];\n const anchor = action.typeString.toLowerCase().replace(/[^a-z0-9]/gu, '');\n const href = kind === 'action' ? `#${anchor}` : `./actions#${anchor}`;\n knownNames.set(shortName, href);\n knownNames.set(action.typeString, href);\n }\n for (const event of ns.events) {\n const shortName = event.typeString.split(':')[1];\n const anchor = event.typeString.toLowerCase().replace(/[^a-z0-9]/gu, '');\n const href = kind === 'event' ? `#${anchor}` : `./events#${anchor}`;\n knownNames.set(shortName, href);\n knownNames.set(event.typeString, href);\n }\n\n // Table of contents\n parts.push('| Name | Deprecated |');\n parts.push('|------|-----------|');\n for (const item of items) {\n const name = item.typeString.split(':')[1];\n // Docusaurus uses github-slugger: strips non-alphanumeric, lowercases, no dashes for special chars in code spans\n const anchor = item.typeString.toLowerCase().replace(/[^a-z0-9]/gu, '');\n const dep = item.deprecated ? 'Yes' : '';\n parts.push(`| [\\`${name}\\`](#${anchor}) | ${dep} |`);\n }\n parts.push('');\n parts.push('---');\n parts.push('');\n\n for (const item of items) {\n parts.push(\n generateItemMarkdown(item, ns.namespace, knownNames, repoBaseUrl),\n );\n parts.push('---');\n parts.push('');\n }\n\n return parts.join('\\n');\n}\n\n/**\n * Options controlling how {@link generateIndexPage} renders the index header.\n */\nexport type IndexPageOptions = {\n /**\n * Short label identifying the project the docs were generated from (e.g.\n * \"Core\", \"Extension\"). When provided, the title is rendered as\n * `Platform API (Core)`.\n */\n projectLabel?: string | null;\n /**\n * Git commit SHA the docs were generated from. When provided, it's shown\n * in the intro so engineers know how current the site is.\n */\n commitSha?: string | null;\n};\n\n/**\n * Generate the index/overview page listing all namespaces.\n *\n * @param namespaces - All namespace groups sorted alphabetically.\n * @param options - Optional project label and commit SHA to stamp in the header.\n * @returns The generated markdown string.\n */\nexport function generateIndexPage(\n namespaces: NamespaceGroup[],\n options: IndexPageOptions = {},\n): string {\n const totalActions = namespaces.reduce(\n (sum, ns) => sum + ns.actions.length,\n 0,\n );\n const totalEvents = namespaces.reduce((sum, ns) => sum + ns.events.length, 0);\n const projectSuffix = options.projectLabel\n ? ` (${options.projectLabel})`\n : '';\n\n const parts: string[] = [];\n parts.push('---');\n parts.push(`title: \"Platform API${projectSuffix} Reference\"`);\n parts.push('slug: \"/\"');\n parts.push('---');\n parts.push('');\n parts.push(`# Platform API${projectSuffix}`);\n parts.push('');\n parts.push(\n 'This site documents every action and event registered on the Messenger — the type-safe message bus used across all controllers.',\n );\n parts.push('');\n if (options.commitSha) {\n parts.push(`Generated from commit \\`${options.commitSha}\\`.`);\n parts.push('');\n }\n parts.push(`- **${namespaces.length}** namespaces`);\n parts.push(`- **${totalActions}** actions`);\n parts.push(`- **${totalEvents}** events`);\n parts.push('');\n parts.push('## Namespaces');\n parts.push('');\n parts.push('| Namespace | Actions | Events |');\n parts.push('|-----------|---------|--------|');\n\n for (const ns of namespaces) {\n const firstLink =\n ns.actions.length > 0\n ? `${ns.namespace}/actions`\n : `${ns.namespace}/events`;\n parts.push(\n `| [${ns.namespace}](${firstLink}) | ${ns.actions.length} | ${ns.events.length} |`,\n );\n }\n\n parts.push('');\n return parts.join('\\n');\n}\n\n/**\n * Generate the sidebars.ts file content for Docusaurus.\n *\n * @param namespaces - All namespace groups sorted alphabetically.\n * @returns The generated TypeScript source string.\n */\nexport function generateSidebars(namespaces: NamespaceGroup[]): string {\n const items = namespaces.map((ns) => ({\n type: 'category',\n label: ns.namespace,\n items: [\n ...(ns.actions.length > 0 ? [`${ns.namespace}/actions`] : []),\n ...(ns.events.length > 0 ? [`${ns.namespace}/events`] : []),\n ],\n }));\n\n const sidebar = {\n messengerSidebar: [\n {\n type: 'doc',\n id: 'index',\n label: 'Overview',\n },\n ...items,\n ],\n };\n\n return `// This file is auto-generated by @metamask/platform-api-docs\\n// Do not edit manually.\\nconst sidebars = ${JSON.stringify(\n sidebar,\n null,\n 2,\n )};\\nexport default sidebars;\\n`;\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"markdown.d.cts","sourceRoot":"","sources":["../src/markdown.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,cAAc,EAAE,oBAAmB;AAuC5E;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,yBAAyB,EAC/B,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAC/B,WAAW,EAAE,MAAM,GAAG,IAAI,GACzB,MAAM,CAqER;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACnC,EAAE,EAAE,cAAc,EAClB,IAAI,EAAE,QAAQ,GAAG,OAAO,EACxB,WAAW,GAAE,MAAM,GAAG,IAAW,GAChC,MAAM,CAiER;AAED;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,cAAc,EAAE,EAC5B,OAAO,GAAE,gBAAqB,GAC7B,MAAM,CA+CR;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,cAAc,EAAE,GAAG,MAAM,CA0BrE"}
@@ -1,52 +0,0 @@
1
- import type { MessengerCapabilityPacket, NamespaceGroup } from "./types.mjs";
2
- /**
3
- * Generate markdown documentation for a single messenger item.
4
- *
5
- * @param item - The messenger item to document.
6
- * @param namespace - The current namespace.
7
- * @param knownNames - Map from short/full names to their link paths.
8
- * @param repoBaseUrl - Optional GitHub blob base URL (e.g. "https://github.com/Owner/Repo/blob/sha/").
9
- * @returns The generated markdown string.
10
- */
11
- export declare function generateItemMarkdown(item: MessengerCapabilityPacket, namespace: string, knownNames: Map<string, string>, repoBaseUrl: string | null): string;
12
- /**
13
- * Generate a full markdown page for a namespace's actions or events.
14
- *
15
- * @param ns - The namespace group to generate a page for.
16
- * @param kind - Whether to generate the actions or events page.
17
- * @param repoBaseUrl - Optional GitHub blob base URL for source links.
18
- * @returns The generated markdown string.
19
- */
20
- export declare function generateNamespacePage(ns: NamespaceGroup, kind: 'action' | 'event', repoBaseUrl?: string | null): string;
21
- /**
22
- * Options controlling how {@link generateIndexPage} renders the index header.
23
- */
24
- export type IndexPageOptions = {
25
- /**
26
- * Short label identifying the project the docs were generated from (e.g.
27
- * "Core", "Extension"). When provided, the title is rendered as
28
- * `Platform API (Core)`.
29
- */
30
- projectLabel?: string | null;
31
- /**
32
- * Git commit SHA the docs were generated from. When provided, it's shown
33
- * in the intro so engineers know how current the site is.
34
- */
35
- commitSha?: string | null;
36
- };
37
- /**
38
- * Generate the index/overview page listing all namespaces.
39
- *
40
- * @param namespaces - All namespace groups sorted alphabetically.
41
- * @param options - Optional project label and commit SHA to stamp in the header.
42
- * @returns The generated markdown string.
43
- */
44
- export declare function generateIndexPage(namespaces: NamespaceGroup[], options?: IndexPageOptions): string;
45
- /**
46
- * Generate the sidebars.ts file content for Docusaurus.
47
- *
48
- * @param namespaces - All namespace groups sorted alphabetically.
49
- * @returns The generated TypeScript source string.
50
- */
51
- export declare function generateSidebars(namespaces: NamespaceGroup[]): string;
52
- //# sourceMappingURL=markdown.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"markdown.d.mts","sourceRoot":"","sources":["../src/markdown.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,cAAc,EAAE,oBAAmB;AAuC5E;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,yBAAyB,EAC/B,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAC/B,WAAW,EAAE,MAAM,GAAG,IAAI,GACzB,MAAM,CAqER;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACnC,EAAE,EAAE,cAAc,EAClB,IAAI,EAAE,QAAQ,GAAG,OAAO,EACxB,WAAW,GAAE,MAAM,GAAG,IAAW,GAChC,MAAM,CAiER;AAED;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B;;;;OAIG;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KAAK,EAAE,EAAE,CAAC,SAAS;QACnB,KAAK,EAAE;YACL,GAAG,CAAC,EAAE,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,SAAS,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAC7D,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,SAAS,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;SAC5D;KACF,CAAC,CAAC,CAAC;IAEJ,MAAM,OAAO,GAAG;QACd,gBAAgB,EAAE;YAChB;gBACE,IAAI,EAAE,KAAK;gBACX,EAAE,EAAE,OAAO;gBACX,KAAK,EAAE,UAAU;aAClB;YACD,GAAG,KAAK;SACT;KACF,CAAC;IAEF,OAAO,6GAA6G,IAAI,CAAC,SAAS,CAChI,OAAO,EACP,IAAI,EACJ,CAAC,CACF,+BAA+B,CAAC;AACnC,CAAC","sourcesContent":["import type { MessengerCapabilityPacket, NamespaceGroup } from './types.js';\n\n/**\n * Convert backtick-quoted action/event names in text into links when they\n * match a known item in the same namespace. For example, `` `setActiveNetwork` ``\n * becomes a link to `#networkcontrollersetactivenetwork` on the actions page.\n *\n * @param text - The markdown text to process.\n * @param namespace - The current namespace (e.g. \"NetworkController\").\n * @param knownNames - Map from short name (e.g. \"setActiveNetwork\") to the page-relative path and anchor.\n * @returns The text with backtick references replaced by links.\n */\nfunction linkifyReferences(\n text: string,\n namespace: string,\n knownNames: Map<string, string>,\n): string {\n return text.replace(/`([a-zA-Z]\\w*)`/gu, (match, name: string) => {\n const link = knownNames.get(name);\n if (link) {\n return `[\\`${name}\\`](${link})`;\n }\n // Also try with namespace prefix (e.g. \"NetworkController:setActiveNetwork\")\n const fullName = `${namespace}:${name}`;\n const anchor = fullName.toLowerCase().replace(/[^a-z0-9]/gu, '');\n const linkFull = knownNames.get(fullName);\n if (linkFull) {\n return `[\\`${name}\\`](${linkFull})`;\n }\n // Check if the anchor matches exactly in known names values\n for (const [, href] of knownNames) {\n if (href.endsWith(`#${anchor}`)) {\n return `[\\`${name}\\`](${href})`;\n }\n }\n return match;\n });\n}\n\n/**\n * Generate markdown documentation for a single messenger item.\n *\n * @param item - The messenger item to document.\n * @param namespace - The current namespace.\n * @param knownNames - Map from short/full names to their link paths.\n * @param repoBaseUrl - Optional GitHub blob base URL (e.g. \"https://github.com/Owner/Repo/blob/sha/\").\n * @returns The generated markdown string.\n */\nexport function generateItemMarkdown(\n item: MessengerCapabilityPacket,\n namespace: string,\n knownNames: Map<string, string>,\n repoBaseUrl: string | null,\n): string {\n const parts: string[] = [];\n\n parts.push(`### \\`${item.typeString}\\``);\n parts.push('');\n\n if (item.deprecated) {\n parts.push('> **Deprecated**');\n parts.push('');\n }\n\n // For sources scanned out of an @metamask/*/dist directory we render an\n // npm link, since the original .ts paths are not part of the repo we're\n // documenting. Other `node_modules/` paths fall through to the normal\n // source-link branches.\n const metamaskPkgMatch = item.sourceFile.match(\n /node_modules\\/(@metamask\\/[^/]+)/u,\n );\n if (metamaskPkgMatch) {\n const pkgName = metamaskPkgMatch[1];\n const npmUrl = `https://www.npmjs.com/package/${pkgName}`;\n parts.push(`**Package**: [\\`${pkgName}\\`](${npmUrl})`);\n } else if (repoBaseUrl) {\n const ghUrl = `${repoBaseUrl}${item.sourceFile}#L${item.line}`;\n parts.push(`**Source**: [${item.sourceFile}:${item.line}](${ghUrl})`);\n } else {\n parts.push(`**Source**: \\`${item.sourceFile}:${item.line}\\``);\n }\n parts.push('');\n\n if (item.jsDoc) {\n parts.push(linkifyReferences(item.jsDoc, namespace, knownNames));\n parts.push('');\n }\n\n // Only actions get a parameters table — events carry a positional tuple\n // payload, not named arguments, so a `@param` table doesn't fit.\n if (item.kind === 'action' && item.params.length > 0) {\n parts.push('**Parameters**:');\n parts.push('');\n parts.push('| Name | Description |');\n parts.push('|------|-------------|');\n for (const param of item.params) {\n const description = linkifyReferences(\n param.description,\n namespace,\n knownNames,\n );\n parts.push(`| \\`${param.name}\\` | ${description} |`);\n }\n parts.push('');\n }\n\n if (item.kind === 'action' && item.returns) {\n parts.push(\n `**Returns**: ${linkifyReferences(item.returns, namespace, knownNames)}`,\n );\n parts.push('');\n }\n\n const signatureLabel = item.kind === 'action' ? 'Handler' : 'Payload';\n parts.push(`**${signatureLabel} signature**:`);\n parts.push('');\n parts.push('```typescript');\n parts.push(item.handlerOrPayload);\n parts.push('```');\n parts.push('');\n\n return parts.join('\\n');\n}\n\n/**\n * Generate a full markdown page for a namespace's actions or events.\n *\n * @param ns - The namespace group to generate a page for.\n * @param kind - Whether to generate the actions or events page.\n * @param repoBaseUrl - Optional GitHub blob base URL for source links.\n * @returns The generated markdown string.\n */\nexport function generateNamespacePage(\n ns: NamespaceGroup,\n kind: 'action' | 'event',\n repoBaseUrl: string | null = null,\n): string {\n const items = kind === 'action' ? ns.actions : ns.events;\n const title = kind === 'action' ? 'Actions' : 'Events';\n const parts: string[] = [];\n\n parts.push('---');\n parts.push(`title: \"${ns.namespace} ${title}\"`);\n parts.push(`sidebar_label: \"${title}\"`);\n parts.push('---');\n parts.push('');\n parts.push(`# ${ns.namespace} ${title}`);\n parts.push('');\n\n if (items.length === 0) {\n parts.push(`_No ${kind}s found for this namespace._`);\n parts.push('');\n return parts.join('\\n');\n }\n\n parts.push(\n `${items.length} ${kind}${items.length === 1 ? '' : 's'} registered.`,\n );\n parts.push('');\n\n // Build a map of known names → link paths for cross-referencing.\n // Actions on same page get #anchor, actions/events on sibling page get relative path.\n const knownNames = new Map<string, string>();\n for (const action of ns.actions) {\n const shortName = action.typeString.split(':')[1];\n const anchor = action.typeString.toLowerCase().replace(/[^a-z0-9]/gu, '');\n const href = kind === 'action' ? `#${anchor}` : `./actions#${anchor}`;\n knownNames.set(shortName, href);\n knownNames.set(action.typeString, href);\n }\n for (const event of ns.events) {\n const shortName = event.typeString.split(':')[1];\n const anchor = event.typeString.toLowerCase().replace(/[^a-z0-9]/gu, '');\n const href = kind === 'event' ? `#${anchor}` : `./events#${anchor}`;\n knownNames.set(shortName, href);\n knownNames.set(event.typeString, href);\n }\n\n // Table of contents\n parts.push('| Name | Deprecated |');\n parts.push('|------|-----------|');\n for (const item of items) {\n const name = item.typeString.split(':')[1];\n // Docusaurus uses github-slugger: strips non-alphanumeric, lowercases, no dashes for special chars in code spans\n const anchor = item.typeString.toLowerCase().replace(/[^a-z0-9]/gu, '');\n const dep = item.deprecated ? 'Yes' : '';\n parts.push(`| [\\`${name}\\`](#${anchor}) | ${dep} |`);\n }\n parts.push('');\n parts.push('---');\n parts.push('');\n\n for (const item of items) {\n parts.push(\n generateItemMarkdown(item, ns.namespace, knownNames, repoBaseUrl),\n );\n parts.push('---');\n parts.push('');\n }\n\n return parts.join('\\n');\n}\n\n/**\n * Options controlling how {@link generateIndexPage} renders the index header.\n */\nexport type IndexPageOptions = {\n /**\n * Short label identifying the project the docs were generated from (e.g.\n * \"Core\", \"Extension\"). When provided, the title is rendered as\n * `Platform API (Core)`.\n */\n projectLabel?: string | null;\n /**\n * Git commit SHA the docs were generated from. When provided, it's shown\n * in the intro so engineers know how current the site is.\n */\n commitSha?: string | null;\n};\n\n/**\n * Generate the index/overview page listing all namespaces.\n *\n * @param namespaces - All namespace groups sorted alphabetically.\n * @param options - Optional project label and commit SHA to stamp in the header.\n * @returns The generated markdown string.\n */\nexport function generateIndexPage(\n namespaces: NamespaceGroup[],\n options: IndexPageOptions = {},\n): string {\n const totalActions = namespaces.reduce(\n (sum, ns) => sum + ns.actions.length,\n 0,\n );\n const totalEvents = namespaces.reduce((sum, ns) => sum + ns.events.length, 0);\n const projectSuffix = options.projectLabel\n ? ` (${options.projectLabel})`\n : '';\n\n const parts: string[] = [];\n parts.push('---');\n parts.push(`title: \"Platform API${projectSuffix} Reference\"`);\n parts.push('slug: \"/\"');\n parts.push('---');\n parts.push('');\n parts.push(`# Platform API${projectSuffix}`);\n parts.push('');\n parts.push(\n 'This site documents every action and event registered on the Messenger — the type-safe message bus used across all controllers.',\n );\n parts.push('');\n if (options.commitSha) {\n parts.push(`Generated from commit \\`${options.commitSha}\\`.`);\n parts.push('');\n }\n parts.push(`- **${namespaces.length}** namespaces`);\n parts.push(`- **${totalActions}** actions`);\n parts.push(`- **${totalEvents}** events`);\n parts.push('');\n parts.push('## Namespaces');\n parts.push('');\n parts.push('| Namespace | Actions | Events |');\n parts.push('|-----------|---------|--------|');\n\n for (const ns of namespaces) {\n const firstLink =\n ns.actions.length > 0\n ? `${ns.namespace}/actions`\n : `${ns.namespace}/events`;\n parts.push(\n `| [${ns.namespace}](${firstLink}) | ${ns.actions.length} | ${ns.events.length} |`,\n );\n }\n\n parts.push('');\n return parts.join('\\n');\n}\n\n/**\n * Generate the sidebars.ts file content for Docusaurus.\n *\n * @param namespaces - All namespace groups sorted alphabetically.\n * @returns The generated TypeScript source string.\n */\nexport function generateSidebars(namespaces: NamespaceGroup[]): string {\n const items = namespaces.map((ns) => ({\n type: 'category',\n label: ns.namespace,\n items: [\n ...(ns.actions.length > 0 ? [`${ns.namespace}/actions`] : []),\n ...(ns.events.length > 0 ? [`${ns.namespace}/events`] : []),\n ],\n }));\n\n const sidebar = {\n messengerSidebar: [\n {\n type: 'doc',\n id: 'index',\n label: 'Overview',\n },\n ...items,\n ],\n };\n\n return `// This file is auto-generated by @metamask/platform-api-docs\\n// Do not edit manually.\\nconst sidebars = ${JSON.stringify(\n sidebar,\n null,\n 2,\n )};\\nexport default sidebars;\\n`;\n}\n"]}