Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/platform-api-docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- Initial release of the platform-api-docs package ([#8012](https://github.com/MetaMask/core/pull/8012), [#9913](https://github.com/MetaMask/core/pull/9913))
- Initial release of the platform-api-docs package ([#8012](https://github.com/MetaMask/core/pull/8012), [#9913](https://github.com/MetaMask/core/pull/9913), [#9990](https://github.com/MetaMask/core/pull/9990))

[Unreleased]: https://github.com/MetaMask/core/
1 change: 0 additions & 1 deletion packages/platform-api-docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
"@mdx-js/react": "^3.1.1",
"@metamask/utils": "^11.11.0",
"execa": "^5.0.0",
"glob": "^13.0.6",
"npm-which": "^3.0.1",
"prism-react-renderer": "^2.4.1",
"react": "^19.0.0",
Expand Down
200 changes: 0 additions & 200 deletions packages/platform-api-docs/src/discovery.test.ts

This file was deleted.

49 changes: 0 additions & 49 deletions packages/platform-api-docs/src/discovery.ts

This file was deleted.

10 changes: 4 additions & 6 deletions packages/platform-api-docs/src/extraction.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ import { createSandbox } from '@metamask/utils/node';
import * as fs from 'node:fs';
import * as path from 'node:path';

import {
createExtractionProject,
extractFromSourceFile,
} from './extraction.js';
import { extractFromSourceFile } from './extraction.js';
import { createProject } from './ts-project.js';
import { MessengerCapabilityPacket } from './types.js';

const { withinSandbox } = createSandbox('platform-api-docs/extraction');
Expand Down Expand Up @@ -36,7 +34,7 @@ function withMessenger(
* run `extractFromSourceFile` on it.
*
* This mirrors the logic that callers of the library use in production (via
* `createExtractionProject` + `extractFromSourceFile`) without going through
* `createProject` + `extractFromSourceFile`) without going through
* the now-removed `extractFromFile` convenience wrapper.
*
* @param filePath - Absolute path of the file to write and extract from.
Expand All @@ -52,7 +50,7 @@ async function extractFromWrittenFile(
): Promise<MessengerCapabilityPacket[]> {
await fs.promises.writeFile(filePath, content);
const parentDir = path.dirname(filePath);
const project = createExtractionProject();
const project = createProject();
project.addSourceFilesAtPaths([
path.join(parentDir, '**/*.ts'),
path.join(parentDir, '**/*.d.cts'),
Expand Down
28 changes: 1 addition & 27 deletions packages/platform-api-docs/src/extraction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import type {
TypeNode,
TypeReferenceNode,
} from 'ts-morph';
import { Node as NodeGuards, Project, ts } from 'ts-morph';
import { Node as NodeGuards } from 'ts-morph';

import type {
MessengerCapabilityPacket,
Expand Down Expand Up @@ -929,32 +929,6 @@ function tryToExtractFromCapabilityTypeConstructor(
// Public entry points
// ---------------------------------------------------------------------------

/**
* Create a ts-morph Project configured for messenger-docs extraction. The
* caller should add every source file that may be referenced (directly or
* transitively) before calling {@link extractFromSourceFile}, so the type
* checker can resolve cross-file references.
*
* @returns A new ts-morph Project.
*/
export function createExtractionProject(): Project {
return new Project({
compilerOptions: {
allowJs: false,
noEmit: true,
// Match the project's permissive defaults — we just need symbol
// resolution, not full typechecking.
strict: false,
skipLibCheck: true,
// Explicit module options so cross-file symbol resolution works
// regardless of the host process's tsconfig.
target: ts.ScriptTarget.ESNext,
module: ts.ModuleKind.ESNext,
moduleResolution: ts.ModuleResolutionKind.NodeJs,
},
});
}

/**
* Extract information (action/event type string, handler/payload arguments and
* return type, etc.) about every messenger action or event type which is
Expand Down
Loading
Loading