Skip to content
Draft
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 .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ updates:
- 'hast-*'
- 'mdast-*'
- 'hastscript'
- 'acorn'
- 'oxc-parser'
recma:
patterns:
- 'recma-*'
Expand Down
295 changes: 294 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
"@orama/orama": "^3.1.11",
"@orama/react-components": "^0.8.1",
"@rollup/plugin-virtual": "^3.0.2",
"acorn": "^8.15.0",
"commander": "^14.0.0",
"dedent": "^1.6.0",
"eslint-plugin-react-x": "^1.52.3",
Expand All @@ -60,6 +59,7 @@
"hastscript": "^9.0.1",
"lightningcss": "^1.30.1",
"mdast-util-slice-markdown": "^2.0.1",
"oxc-parser": "^0.82.2",
"preact": "^10.27.0",
"preact-render-to-string": "^6.5.13",
"reading-time": "^1.5.0",
Expand Down
4 changes: 2 additions & 2 deletions src/generators/api-links/__tests__/fixtures.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

describe('api links', () => {
describe('should work correctly for all fixtures', () => {
sourceFiles.forEach(sourceFile => {
for (const sourceFile of sourceFiles) {
it(`${basename(sourceFile)}`, async t => {
const astJsResult = await astJs.generate(undefined, {
input: [sourceFile],
Expand All @@ -28,8 +28,8 @@
actualOutput[k] = v.replace(/.*(?=lib\/)/, '');
}

t.assert.snapshot(actualOutput);

Check failure on line 31 in src/generators/api-links/__tests__/fixtures.test.mjs

View workflow job for this annotation

GitHub Actions / Test & Coverage

reverse.js

[Error [ERR_TEST_FAILURE]: Expected values to be strictly equal: + actual - expected + '\n{}\n' - '\n' + - '{\n' + - ' "asserts": "lib/reverse.js#L8",\n' + - ' "asserts.ok": "lib/reverse.js#L5",\n' + - ' "asserts.strictEqual": "lib/reverse.js#L12"\n' + - '}\n' ] { code: 'ERR_TEST_FAILURE', failureType: 'testCodeFailure', cause: AssertionError [ERR_ASSERTION]: Expected values to be strictly equal: + actual - expected + '\n{}\n' - '\n' + - '{\n' + - ' "asserts": "lib/reverse.js#L8",\n' + - ' "asserts.ok": "lib/reverse.js#L5",\n' + - ' "asserts.strictEqual": "lib/reverse.js#L12"\n' + - '}\n' at TestContext.snapshotAssertion (node:internal/test_runner/snapshot:206:9) at assert.<computed> [as snapshot] (node:internal/test_runner/test:320:18) at TestContext.<anonymous> (file:///home/runner/work/doc-kit/doc-kit/src/generators/api-links/__tests__/fixtures.test.mjs:31:18) at async Test.run (node:internal/test_runner/test:1054:7) at async Suite.processPendingSubtests (node:internal/test_runner/test:744:7) { generatedMessage: true, code: 'ERR_ASSERTION', actual: '\n{}\n', expected: '\n{\n "asserts": "lib/reverse.js#L8",\n "asserts.ok": "lib/reverse.js#L5",\n "asserts.strictEqual": "lib/reverse.js#L12"\n}\n', operator: 'strictEqual' } }

Check failure on line 31 in src/generators/api-links/__tests__/fixtures.test.mjs

View workflow job for this annotation

GitHub Actions / Test & Coverage

prototype.js

[Error [ERR_TEST_FAILURE]: Expected values to be strictly equal: + actual - expected + '\n{}\n' - '\n' + - '{\n' + - ' "prototype.Class": "lib/prototype.js#L5",\n' + - ' "Class.classMethod": "lib/prototype.js#L8",\n' + - ' "class.instanceMethod": "lib/prototype.js#L9"\n' + - '}\n' ] { code: 'ERR_TEST_FAILURE', failureType: 'testCodeFailure', cause: AssertionError [ERR_ASSERTION]: Expected values to be strictly equal: + actual - expected + '\n{}\n' - '\n' + - '{\n' + - ' "prototype.Class": "lib/prototype.js#L5",\n' + - ' "Class.classMethod": "lib/prototype.js#L8",\n' + - ' "class.instanceMethod": "lib/prototype.js#L9"\n' + - '}\n' at TestContext.snapshotAssertion (node:internal/test_runner/snapshot:206:9) at assert.<computed> [as snapshot] (node:internal/test_runner/test:320:18) at TestContext.<anonymous> (file:///home/runner/work/doc-kit/doc-kit/src/generators/api-links/__tests__/fixtures.test.mjs:31:18) at async Test.run (node:internal/test_runner/test:1054:7) at async Suite.processPendingSubtests (node:internal/test_runner/test:744:7) { generatedMessage: true, code: 'ERR_ASSERTION', actual: '\n{}\n', expected: '\n{\n "prototype.Class": "lib/prototype.js#L5",\n "Class.classMethod": "lib/prototype.js#L8",\n "class.instanceMethod": "lib/prototype.js#L9"\n}\n', operator: 'strictEqual' } }

Check failure on line 31 in src/generators/api-links/__tests__/fixtures.test.mjs

View workflow job for this annotation

GitHub Actions / Test & Coverage

mod.js

[Error [ERR_TEST_FAILURE]: Expected values to be strictly equal: actual expected '\n{\n "mod.foo": "lib/mod.js#L5"\n}\n' ] { code: 'ERR_TEST_FAILURE', failureType: 'testCodeFailure', cause: AssertionError [ERR_ASSERTION]: Expected values to be strictly equal: actual expected '\n{\n "mod.foo": "lib/mod.js#L5"\n}\n' at TestContext.snapshotAssertion (node:internal/test_runner/snapshot:206:9) at assert.<computed> [as snapshot] (node:internal/test_runner/test:320:18) at TestContext.<anonymous> (file:///home/runner/work/doc-kit/doc-kit/src/generators/api-links/__tests__/fixtures.test.mjs:31:18) at async Test.run (node:internal/test_runner/test:1054:7) at async Suite.processPendingSubtests (node:internal/test_runner/test:744:7) { generatedMessage: true, code: 'ERR_ASSERTION', actual: '\n{}\n', expected: '\n{\n "mod.foo": "lib/mod.js#L5"\n}\n', operator: 'strictEqual' } }

Check failure on line 31 in src/generators/api-links/__tests__/fixtures.test.mjs

View workflow job for this annotation

GitHub Actions / Test & Coverage

exports.js

[Error [ERR_TEST_FAILURE]: Expected values to be strictly equal: + actual - expected + '\n{}\n' - '\n' + - '{\n' + - ' "exports.fn1": "lib/exports.js#L8",\n' + - ' "exports.fn2": "lib/exports.js#L10",\n' + - ' "exports.Buffer": "lib/exports.js#L5",\n' + - ' "exports.fn3": "lib/exports.js#L12"\n' + - '}\n' ] { code: 'ERR_TEST_FAILURE', failureType: 'testCodeFailure', cause: AssertionError [ERR_ASSERTION]: Expected values to be strictly equal: + actual - expected + '\n{}\n' - '\n' + - '{\n' + - ' "exports.fn1": "lib/exports.js#L8",\n' + - ' "exports.fn2": "lib/exports.js#L10",\n' + - ' "exports.Buffer": "lib/exports.js#L5",\n' + - ' "exports.fn3": "lib/exports.js#L12"\n' + - '}\n' at TestContext.snapshotAssertion (node:internal/test_runner/snapshot:206:9) at assert.<computed> [as snapshot] (node:internal/test_runner/test:320:18) at TestContext.<anonymous> (file:///home/runner/work/doc-kit/doc-kit/src/generators/api-links/__tests__/fixtures.test.mjs:31:18) at async Test.run (node:internal/test_runner/test:1054:7) at async Suite.processPendingSubtests (node:internal/test_runner/test:744:7) { generatedMessage: true, code: 'ERR_ASSERTION', actual: '\n{}\n', expected: '\n{\n "exports.fn1": "lib/exports.js#L8",\n "exports.fn2": "lib/exports.js#L10",\n "exports.Buffer": "lib/exports.js#L5",\n "exports.fn3": "lib/exports.js#L12"\n}\n', operator: 'strictEqual' } }

Check failure on line 31 in src/generators/api-links/__tests__/fixtures.test.mjs

View workflow job for this annotation

GitHub Actions / Test & Coverage

class.js

[Error [ERR_TEST_FAILURE]: Expected values to be strictly equal: + actual - expected + '\n{}\n' - '\n' + - '{\n' + - ' "Class": "lib/class.js#L5",\n' + - ' "new Class": "lib/class.js#L6",\n' + - ' "class.method": "lib/class.js#L7"\n' + - '}\n' ] { code: 'ERR_TEST_FAILURE', failureType: 'testCodeFailure', cause: AssertionError [ERR_ASSERTION]: Expected values to be strictly equal: + actual - expected + '\n{}\n' - '\n' + - '{\n' + - ' "Class": "lib/class.js#L5",\n' + - ' "new Class": "lib/class.js#L6",\n' + - ' "class.method": "lib/class.js#L7"\n' + - '}\n' at TestContext.snapshotAssertion (node:internal/test_runner/snapshot:206:9) at assert.<computed> [as snapshot] (node:internal/test_runner/test:320:18) at TestContext.<anonymous> (file:///home/runner/work/doc-kit/doc-kit/src/generators/api-links/__tests__/fixtures.test.mjs:31:18) at async Test.run (node:internal/test_runner/test:1054:7) at async Suite.processPendingSubtests (node:internal/test_runner/test:744:7) { generatedMessage: true, code: 'ERR_ASSERTION', actual: '\n{}\n', expected: '\n{\n "Class": "lib/class.js#L5",\n "new Class": "lib/class.js#L6",\n "class.method": "lib/class.js#L7"\n}\n', operator: 'strictEqual' } }

Check failure on line 31 in src/generators/api-links/__tests__/fixtures.test.mjs

View workflow job for this annotation

GitHub Actions / Test & Coverage

buffer.js

Error [ERR_TEST_FAILURE]: Expected values to be strictly equal: + actual - expected + '\n{}\n' - '\n' + - '{\n' + - ' "buffer.Buffer": "lib/buffer.js#L5",\n' + - ' "buf.instanceMethod": "lib/buffer.js#L8"\n' + - '}\n' at async Promise.all (index 0) at async Promise.all (index 0) { code: 'ERR_TEST_FAILURE', failureType: 'testCodeFailure', cause: AssertionError [ERR_ASSERTION]: Expected values to be strictly equal: + actual - expected + '\n{}\n' - '\n' + - '{\n' + - ' "buffer.Buffer": "lib/buffer.js#L5",\n' + - ' "buf.instanceMethod": "lib/buffer.js#L8"\n' + - '}\n' at TestContext.snapshotAssertion (node:internal/test_runner/snapshot:206:9) at assert.<computed> [as snapshot] (node:internal/test_runner/test:320:18) at TestContext.<anonymous> (file:///home/runner/work/doc-kit/doc-kit/src/generators/api-links/__tests__/fixtures.test.mjs:31:18) at async Test.run (node:internal/test_runner/test:1054:7) at async Promise.all (index 0) at async Suite.run (node:internal/test_runner/test:1442:7) at async Promise.all (index 0) at async Suite.run (node:internal/test_runner/test:1442:7) at async startSubtestAfterBootstrap (node:internal/test_runner/harness:296:3) { generatedMessage: true, code: 'ERR_ASSERTION', actual: '\n{}\n', expected: '\n{\n "buffer.Buffer": "lib/buffer.js#L5",\n "buf.instanceMethod": "lib/buffer.js#L8"\n}\n', operator: 'strictEqual' } }
});
});
}
});
});
4 changes: 4 additions & 0 deletions src/generators/api-links/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,12 @@ export default {
// `http.js` -> `http`
const baseName = basename(program.path, '.js');

console.log(`Processing ${baseName}.js`);

const exports = extractExports(program, baseName, nameToLineNumberMap);

console.log('Exports:', exports);

findDefinitions(program, baseName, nameToLineNumberMap, exports);

checkIndirectReferences(program, exports, nameToLineNumberMap);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { visit } from 'estree-util-visit';

/**
* @param {import('acorn').Program} program
* @param {import('oxc-parser').Program} program
* @param {import('../types.d.ts').ProgramExports} exports
* @param {Record<string, number>} nameToLineNumberMap
*/
Expand Down
Loading
Loading