From 6f7b8a0a75245fe70031adf034fb397cff93fe75 Mon Sep 17 00:00:00 2001 From: Brandon Chan Date: Mon, 6 Jul 2026 16:13:22 -0700 Subject: [PATCH 1/7] Adjust Common Filters --- tools/api-docs-generator/src/filters/CommonFilters.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/api-docs-generator/src/filters/CommonFilters.ts b/tools/api-docs-generator/src/filters/CommonFilters.ts index 6d11092..37505b7 100644 --- a/tools/api-docs-generator/src/filters/CommonFilters.ts +++ b/tools/api-docs-generator/src/filters/CommonFilters.ts @@ -302,6 +302,12 @@ function linkSymbols( } result.push(str); + + if (linkMatches.length > 0) { + log.error( + `Link(s) not found. Please check spelling or if the modules or members are defined: ${JSON.stringify(linkMatches)}` + ); + } } return result; From 332ce4465178afde1e3f92a8221f297432692dbd Mon Sep 17 00:00:00 2001 From: Brandon Chan Date: Mon, 6 Jul 2026 17:40:37 -0700 Subject: [PATCH 2/7] Update test and add error check --- .../test/runGeneratorForTest.ts | 34 ++++++++++++++++-- .../__snapshots__/typeLinking.spec.ts.snap | 36 +++++++++++++++++++ .../@minecraft/example-module-2/info.json | 3 ++ .../docs/@minecraft/example-module/info.json | 1 + .../test/type_linking/typeLinking.spec.ts | 12 +++++++ 5 files changed, 83 insertions(+), 3 deletions(-) diff --git a/tools/api-docs-generator-test-snapshots/test/runGeneratorForTest.ts b/tools/api-docs-generator-test-snapshots/test/runGeneratorForTest.ts index 2c77210..0e5dd69 100644 --- a/tools/api-docs-generator-test-snapshots/test/runGeneratorForTest.ts +++ b/tools/api-docs-generator-test-snapshots/test/runGeneratorForTest.ts @@ -17,6 +17,7 @@ export type RunGeneratorForTestOptions = { additionalArgs?: string; excludedFiles?: string[]; skipMerging?: boolean; + expectedLoggedErrorMessages?: string[]; }; function getAllFiles(dirPath: string): string[] { @@ -34,6 +35,20 @@ function getAllFiles(dirPath: string): string[] { return arrayOfFiles; } +function getErrorsFromOutput(output: string): string[] { + const errorPrefix = '[ERROR]'; + const retList = []; + + const logs = output.split('\n'); + for (const line of logs) { + if (line.indexOf(errorPrefix) === 0) { + retList.push(line); + } + } + + return retList; +} + export function runGeneratorForTest(options: RunGeneratorForTestOptions): void { const { additionalArgs, configPath, generators, minecraftVersion, testDir } = options; let { inDir, outDir, docsDir } = options; @@ -64,12 +79,25 @@ export function runGeneratorForTest(options: RunGeneratorForTestOptions): void { encoding: 'utf-8', }); } catch (e) { - console.error(`Errors detected in test '${path.basename(testDir)}', see log for details: ${testOutputPath}`); - // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access testOutput = `${e.stdout ? `${e.stdout.toString()}\n` : ''}${e.stderr ? `ERROR:\n${e.stderr.toString()}` : ''}`; - throw e; + if (!options.expectedLoggedErrorMessages) { + console.error( + `Errors detected in test '${path.basename(testDir)}', see log for details: ${testOutputPath}` + ); + throw e; + } else { + const errorOutputs = getErrorsFromOutput(testOutput); + for (const errorLine of errorOutputs) { + if (!options.expectedLoggedErrorMessages.includes(errorLine)) { + console.error( + `Unexpected errors detected in test '${path.basename(testDir)}', see log for details: ${testOutputPath}` + ); + throw e; + } + } + } } finally { if (testOutput) { fs.writeFileSync(testOutputPath, testOutput); diff --git a/tools/api-docs-generator-test-snapshots/test/type_linking/__snapshots__/typeLinking.spec.ts.snap b/tools/api-docs-generator-test-snapshots/test/type_linking/__snapshots__/typeLinking.spec.ts.snap index 4df7b12..0c3d4f6 100644 --- a/tools/api-docs-generator-test-snapshots/test/type_linking/__snapshots__/typeLinking.spec.ts.snap +++ b/tools/api-docs-generator-test-snapshots/test/type_linking/__snapshots__/typeLinking.spec.ts.snap @@ -326,6 +326,8 @@ Example enum: [*@minecraft/example-module.ExampleEnum*](../../../scriptapi/minec Example enum value: [*@minecraft/example-module.ExampleEnum.ExampleValue*](../../../scriptapi/minecraft/example-module/ExampleEnum.md#examplevalue) +Example link problem: {@link @minecraft/example-module.ExampleProblem4} + This line has multiple links! [*@minecraft/example-module*](../../../scriptapi/minecraft/example-module/minecraft-example-module.md) [*@minecraft/example-module.ExampleFunction*](../../../scriptapi/minecraft/example-module/minecraft-example-module.md#examplefunction) [*@minecraft/example-module.ExampleConstant*](../../../scriptapi/minecraft/example-module/minecraft-example-module.md#exampleconstant) [*@minecraft/example-module.ExampleObject*](../../../scriptapi/minecraft/example-module/minecraft-example-module.md#exampleobject) ## [Changelog](changelog.md) @@ -468,6 +470,12 @@ Example enum: [*@minecraft/example-module.ExampleEnum*](../../../scriptapi/minec Example enum value: [*@minecraft/example-module.ExampleEnum.ExampleValue*](../../../scriptapi/minecraft/example-module/ExampleEnum.md#examplevalue) +Example link problem: {@link @minecraft/example-module.ExampleProblem} + +Example link problem: {@link @minecraft/example-module.ExampleProblem2} + +Example link problem: {@link @minecraft/example-module.ExampleProblem3} + This line has multiple links and lots of text! This is the first link [*@minecraft/example-module*](../../../scriptapi/minecraft/example-module/minecraft-example-module.md), and this is the second. [*@minecraft/example-module.ExampleFunction*](../../../scriptapi/minecraft/example-module/minecraft-example-module.md#examplefunction) Here's a third link [*@minecraft/example-module.ExampleConstant*](../../../scriptapi/minecraft/example-module/minecraft-example-module.md#exampleconstant) and this one here is the final link [*@minecraft/example-module.ExampleObject*](../../../scriptapi/minecraft/example-module/minecraft-example-module.md#exampleobject) ## [Changelog](changelog.md) @@ -832,6 +840,8 @@ exports[`Type Linking > Properly generates documentation for types that are link * {@link ExampleInterface.ExampleProperty} * Example enum: {@link ExampleEnum} * Example enum value: {@link ExampleEnum.ExampleValue} + * Example link problem: + * {@link @minecraft/example-module.ExampleProblem4} * This line has multiple links! * {@link @minecraft/example-module} {@link ExampleFunction} * {@link ExampleConstant} {@link ExampleObject} @@ -924,6 +934,8 @@ exports[`Type Linking > Properly generates documentation for types that are link * {@link ExampleInterface.ExampleProperty} * Example enum: {@link ExampleEnum} * Example enum value: {@link ExampleEnum.ExampleValue} + * Example link problem: + * {@link @minecraft/example-module.ExampleProblem4} * This line has multiple links! * {@link @minecraft/example-module} {@link ExampleFunction} * {@link ExampleConstant} {@link ExampleObject} @@ -1024,6 +1036,12 @@ exports[`Type Linking > Properly generates documentation for types that are link * Example enum: {@link minecraftexamplemodule.ExampleEnum} * Example enum value: * {@link minecraftexamplemodule.ExampleEnum.ExampleValue} + * Example link problem: + * {@link @minecraft/example-module.ExampleProblem} + * Example link problem: + * {@link @minecraft/example-module.ExampleProblem2} + * Example link problem: + * {@link @minecraft/example-module.ExampleProblem3} * This line has multiple links and lots of text! This is the * first link {@link minecraftexamplemodule}, and this is the * second. {@link minecraftexamplemodule#ExampleFunction} @@ -1525,6 +1543,8 @@ Example enum: [*@minecraft/example-module.ExampleEnum*](../../../scriptapi/minec Example enum value: [*@minecraft/example-module.ExampleEnum.ExampleValue*](../../../scriptapi/minecraft/example-module/ExampleEnum.md#examplevalue) +Example link problem: {@link @minecraft/example-module.ExampleProblem4} + This line has multiple links! [*@minecraft/example-module*](../../../scriptapi/minecraft/example-module/minecraft-example-module.md) [*@minecraft/example-module.ExampleFunction*](../../../scriptapi/minecraft/example-module/minecraft-example-module.md#examplefunction) [*@minecraft/example-module.ExampleConstant*](../../../scriptapi/minecraft/example-module/minecraft-example-module.md#exampleconstant) [*@minecraft/example-module.ExampleObject*](../../../scriptapi/minecraft/example-module/minecraft-example-module.md#exampleobject) ## [Changelog](changelog.md) @@ -1667,6 +1687,12 @@ Example enum: [*@minecraft/example-module.ExampleEnum*](../../../scriptapi/minec Example enum value: [*@minecraft/example-module.ExampleEnum.ExampleValue*](../../../scriptapi/minecraft/example-module/ExampleEnum.md#examplevalue) +Example link problem: {@link @minecraft/example-module.ExampleProblem} + +Example link problem: {@link @minecraft/example-module.ExampleProblem2} + +Example link problem: {@link @minecraft/example-module.ExampleProblem3} + This line has multiple links and lots of text! This is the first link [*@minecraft/example-module*](../../../scriptapi/minecraft/example-module/minecraft-example-module.md), and this is the second. [*@minecraft/example-module.ExampleFunction*](../../../scriptapi/minecraft/example-module/minecraft-example-module.md#examplefunction) Here's a third link [*@minecraft/example-module.ExampleConstant*](../../../scriptapi/minecraft/example-module/minecraft-example-module.md#exampleconstant) and this one here is the final link [*@minecraft/example-module.ExampleObject*](../../../scriptapi/minecraft/example-module/minecraft-example-module.md#exampleobject) ## [Changelog](changelog.md) @@ -2277,6 +2303,8 @@ exports[`Type Linking > Properly generates documentation for types that are link * {@link ExampleInterface.ExampleProperty} * Example enum: {@link ExampleEnum} * Example enum value: {@link ExampleEnum.ExampleValue} + * Example link problem: + * {@link @minecraft/example-module.ExampleProblem4} * This line has multiple links! * {@link @minecraft/example-module} {@link ExampleFunction} * {@link ExampleConstant} {@link ExampleObject} @@ -2369,6 +2397,8 @@ exports[`Type Linking > Properly generates documentation for types that are link * {@link ExampleInterface.ExampleProperty} * Example enum: {@link ExampleEnum} * Example enum value: {@link ExampleEnum.ExampleValue} + * Example link problem: + * {@link @minecraft/example-module.ExampleProblem4} * This line has multiple links! * {@link @minecraft/example-module} {@link ExampleFunction} * {@link ExampleConstant} {@link ExampleObject} @@ -2469,6 +2499,12 @@ exports[`Type Linking > Properly generates documentation for types that are link * Example enum: {@link minecraftexamplemodule.ExampleEnum} * Example enum value: * {@link minecraftexamplemodule.ExampleEnum.ExampleValue} + * Example link problem: + * {@link @minecraft/example-module.ExampleProblem} + * Example link problem: + * {@link @minecraft/example-module.ExampleProblem2} + * Example link problem: + * {@link @minecraft/example-module.ExampleProblem3} * This line has multiple links and lots of text! This is the * first link {@link minecraftexamplemodule}, and this is the * second. {@link minecraftexamplemodule#ExampleFunction} diff --git a/tools/api-docs-generator-test-snapshots/test/type_linking/docs/@minecraft/example-module-2/info.json b/tools/api-docs-generator-test-snapshots/test/type_linking/docs/@minecraft/example-module-2/info.json index c7ec8fe..8dee807 100644 --- a/tools/api-docs-generator-test-snapshots/test/type_linking/docs/@minecraft/example-module-2/info.json +++ b/tools/api-docs-generator-test-snapshots/test/type_linking/docs/@minecraft/example-module-2/info.json @@ -12,6 +12,9 @@ "Example interface property: {@link @minecraft/example-module.ExampleInterface.ExampleProperty}", "Example enum: {@link @minecraft/example-module.ExampleEnum}", "Example enum value: {@link @minecraft/example-module.ExampleEnum.ExampleValue}", + "Example link problem: {@link @minecraft/example-module.ExampleProblem}", + "Example link problem: {@link @minecraft/example-module.ExampleProblem2}", + "Example link problem: {@link @minecraft/example-module.ExampleProblem3}", "This line has multiple links and lots of text! This is the first link {@link @minecraft/example-module}, and this is the second. {@link @minecraft/example-module.ExampleFunction} Here's a third link {@link @minecraft/example-module.ExampleConstant} and this one here is the final link {@link @minecraft/example-module.ExampleObject}" ] } \ No newline at end of file diff --git a/tools/api-docs-generator-test-snapshots/test/type_linking/docs/@minecraft/example-module/info.json b/tools/api-docs-generator-test-snapshots/test/type_linking/docs/@minecraft/example-module/info.json index ada93f7..3b2431a 100644 --- a/tools/api-docs-generator-test-snapshots/test/type_linking/docs/@minecraft/example-module/info.json +++ b/tools/api-docs-generator-test-snapshots/test/type_linking/docs/@minecraft/example-module/info.json @@ -12,6 +12,7 @@ "Example interface property: {@link @minecraft/example-module.ExampleInterface.ExampleProperty}", "Example enum: {@link @minecraft/example-module.ExampleEnum}", "Example enum value: {@link @minecraft/example-module.ExampleEnum.ExampleValue}", + "Example link problem: {@link @minecraft/example-module.ExampleProblem4}", "This line has multiple links! {@link @minecraft/example-module} {@link @minecraft/example-module.ExampleFunction} {@link @minecraft/example-module.ExampleConstant} {@link @minecraft/example-module.ExampleObject}" ] } \ No newline at end of file diff --git a/tools/api-docs-generator-test-snapshots/test/type_linking/typeLinking.spec.ts b/tools/api-docs-generator-test-snapshots/test/type_linking/typeLinking.spec.ts index e15a894..004fa62 100644 --- a/tools/api-docs-generator-test-snapshots/test/type_linking/typeLinking.spec.ts +++ b/tools/api-docs-generator-test-snapshots/test/type_linking/typeLinking.spec.ts @@ -10,6 +10,12 @@ describe('Type Linking', () => { runGeneratorForTest({ testDir: __dirname, generators: ['ts', 'msdocs'], + expectedLoggedErrorMessages: [ + '[ERROR] Link(s) not found. Please check spelling or if the modules or members are defined: [["{@link @minecraft/example-module.ExampleProblem}","@minecraft/example-module.ExampleProblem"]]', + '[ERROR] Link(s) not found. Please check spelling or if the modules or members are defined: [["{@link @minecraft/example-module.ExampleProblem2}","@minecraft/example-module.ExampleProblem2"]]', + '[ERROR] Link(s) not found. Please check spelling or if the modules or members are defined: [["{@link @minecraft/example-module.ExampleProblem3}","@minecraft/example-module.ExampleProblem3"]]', + '[ERROR] Link(s) not found. Please check spelling or if the modules or members are defined: [["{@link @minecraft/example-module.ExampleProblem4}","@minecraft/example-module.ExampleProblem4"]]', + ], }); }); @@ -19,6 +25,12 @@ describe('Type Linking', () => { generators: ['ts', 'msdocs'], additionalArgs: '--include-base', outDir: join(__dirname, 'include_base_output'), + expectedLoggedErrorMessages: [ + '[ERROR] Link(s) not found. Please check spelling or if the modules or members are defined: [["{@link @minecraft/example-module.ExampleProblem}","@minecraft/example-module.ExampleProblem"]]', + '[ERROR] Link(s) not found. Please check spelling or if the modules or members are defined: [["{@link @minecraft/example-module.ExampleProblem2}","@minecraft/example-module.ExampleProblem2"]]', + '[ERROR] Link(s) not found. Please check spelling or if the modules or members are defined: [["{@link @minecraft/example-module.ExampleProblem3}","@minecraft/example-module.ExampleProblem3"]]', + '[ERROR] Link(s) not found. Please check spelling or if the modules or members are defined: [["{@link @minecraft/example-module.ExampleProblem4}","@minecraft/example-module.ExampleProblem4"]]', + ], }); }); }); From 580d0251ae88b6abfa60089e36eec5ded143e1fc Mon Sep 17 00:00:00 2001 From: Brandon Chan Date: Tue, 7 Jul 2026 14:16:44 -0700 Subject: [PATCH 3/7] Change files --- ...ocs-generator-58498d8d-0f93-4bb1-989c-d69950d7afdc.json | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 change/@minecraft-api-docs-generator-58498d8d-0f93-4bb1-989c-d69950d7afdc.json diff --git a/change/@minecraft-api-docs-generator-58498d8d-0f93-4bb1-989c-d69950d7afdc.json b/change/@minecraft-api-docs-generator-58498d8d-0f93-4bb1-989c-d69950d7afdc.json new file mode 100644 index 0000000..1a91d10 --- /dev/null +++ b/change/@minecraft-api-docs-generator-58498d8d-0f93-4bb1-989c-d69950d7afdc.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "Asserts if linking is missed", + "packageName": "@minecraft/api-docs-generator", + "email": "brandon.chan@skyboxlabs.com", + "dependentChangeType": "patch" +} From 73debfd7dac5de71226eb720cf461821c1fd32bf Mon Sep 17 00:00:00 2001 From: Brandon Chan Date: Wed, 8 Jul 2026 15:09:10 -0700 Subject: [PATCH 4/7] Update snap based on merge --- .../__snapshots__/typeLinking.spec.ts.snap | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/tools/api-docs-generator-test-snapshots/test/type_linking/__snapshots__/typeLinking.spec.ts.snap b/tools/api-docs-generator-test-snapshots/test/type_linking/__snapshots__/typeLinking.spec.ts.snap index f88643c..25c1c9a 100644 --- a/tools/api-docs-generator-test-snapshots/test/type_linking/__snapshots__/typeLinking.spec.ts.snap +++ b/tools/api-docs-generator-test-snapshots/test/type_linking/__snapshots__/typeLinking.spec.ts.snap @@ -345,6 +345,8 @@ Example enum value: [*@minecraft/example-module.ExampleEnum.ExampleValue*](../.. Example error: [*@minecraft/example-module.ExampleError*](../../../scriptapi/minecraft/example-module/minecraft-example-module.md#exampleerror) +Example link problem: {@link @minecraft/example-module.ExampleProblem4} + This line has multiple links! [*@minecraft/example-module*](../../../scriptapi/minecraft/example-module/minecraft-example-module.md) [*@minecraft/example-module.ExampleFunction*](../../../scriptapi/minecraft/example-module/minecraft-example-module.md#examplefunction) [*@minecraft/example-module.ExampleConstant*](../../../scriptapi/minecraft/example-module/minecraft-example-module.md#exampleconstant) [*@minecraft/example-module.ExampleObject*](../../../scriptapi/minecraft/example-module/minecraft-example-module.md#exampleobject) ## [Changelog](changelog.md) @@ -492,6 +494,12 @@ Example enum value: [*@minecraft/example-module.ExampleEnum.ExampleValue*](../.. Example error: [*@minecraft/example-module.ExampleError*](../../../scriptapi/minecraft/example-module/minecraft-example-module.md#exampleerror) +Example link problem: {@link @minecraft/example-module.ExampleProblem} + +Example link problem: {@link @minecraft/example-module.ExampleProblem2} + +Example link problem: {@link @minecraft/example-module.ExampleProblem3} + This line has multiple links and lots of text! This is the first link [*@minecraft/example-module*](../../../scriptapi/minecraft/example-module/minecraft-example-module.md), and this is the second. [*@minecraft/example-module.ExampleFunction*](../../../scriptapi/minecraft/example-module/minecraft-example-module.md#examplefunction) Here's a third link [*@minecraft/example-module.ExampleConstant*](../../../scriptapi/minecraft/example-module/minecraft-example-module.md#exampleconstant) and this one here is the final link [*@minecraft/example-module.ExampleObject*](../../../scriptapi/minecraft/example-module/minecraft-example-module.md#exampleobject) ## [Changelog](changelog.md) @@ -877,6 +885,8 @@ exports[`Type Linking > Properly generates documentation for types that are link * Example enum: {@link ExampleEnum} * Example enum value: {@link ExampleEnum.ExampleValue} * Example error: {@link ExampleError} + * Example link problem: + * {@link @minecraft/example-module.ExampleProblem4} * This line has multiple links! * {@link @minecraft/example-module} {@link ExampleFunction} * {@link ExampleConstant} {@link ExampleObject} @@ -975,6 +985,8 @@ exports[`Type Linking > Properly generates documentation for types that are link * Example enum: {@link ExampleEnum} * Example enum value: {@link ExampleEnum.ExampleValue} * Example error: {@link ExampleError} + * Example link problem: + * {@link @minecraft/example-module.ExampleProblem4} * This line has multiple links! * {@link @minecraft/example-module} {@link ExampleFunction} * {@link ExampleConstant} {@link ExampleObject} @@ -1081,6 +1093,12 @@ exports[`Type Linking > Properly generates documentation for types that are link * Example enum value: * {@link minecraftexamplemodule.ExampleEnum.ExampleValue} * Example error: {@link minecraftexamplemodule#ExampleError} + * Example link problem: + * {@link @minecraft/example-module.ExampleProblem} + * Example link problem: + * {@link @minecraft/example-module.ExampleProblem2} + * Example link problem: + * {@link @minecraft/example-module.ExampleProblem3} * This line has multiple links and lots of text! This is the * first link {@link minecraftexamplemodule}, and this is the * second. {@link minecraftexamplemodule#ExampleFunction} @@ -1606,6 +1624,8 @@ Example enum value: [*@minecraft/example-module.ExampleEnum.ExampleValue*](../.. Example error: [*@minecraft/example-module.ExampleError*](../../../scriptapi/minecraft/example-module/minecraft-example-module.md#exampleerror) +Example link problem: {@link @minecraft/example-module.ExampleProblem4} + This line has multiple links! [*@minecraft/example-module*](../../../scriptapi/minecraft/example-module/minecraft-example-module.md) [*@minecraft/example-module.ExampleFunction*](../../../scriptapi/minecraft/example-module/minecraft-example-module.md#examplefunction) [*@minecraft/example-module.ExampleConstant*](../../../scriptapi/minecraft/example-module/minecraft-example-module.md#exampleconstant) [*@minecraft/example-module.ExampleObject*](../../../scriptapi/minecraft/example-module/minecraft-example-module.md#exampleobject) ## [Changelog](changelog.md) @@ -1753,6 +1773,12 @@ Example enum value: [*@minecraft/example-module.ExampleEnum.ExampleValue*](../.. Example error: [*@minecraft/example-module.ExampleError*](../../../scriptapi/minecraft/example-module/minecraft-example-module.md#exampleerror) +Example link problem: {@link @minecraft/example-module.ExampleProblem} + +Example link problem: {@link @minecraft/example-module.ExampleProblem2} + +Example link problem: {@link @minecraft/example-module.ExampleProblem3} + This line has multiple links and lots of text! This is the first link [*@minecraft/example-module*](../../../scriptapi/minecraft/example-module/minecraft-example-module.md), and this is the second. [*@minecraft/example-module.ExampleFunction*](../../../scriptapi/minecraft/example-module/minecraft-example-module.md#examplefunction) Here's a third link [*@minecraft/example-module.ExampleConstant*](../../../scriptapi/minecraft/example-module/minecraft-example-module.md#exampleconstant) and this one here is the final link [*@minecraft/example-module.ExampleObject*](../../../scriptapi/minecraft/example-module/minecraft-example-module.md#exampleobject) ## [Changelog](changelog.md) @@ -2404,6 +2430,8 @@ exports[`Type Linking > Properly generates documentation for types that are link * Example enum: {@link ExampleEnum} * Example enum value: {@link ExampleEnum.ExampleValue} * Example error: {@link ExampleError} + * Example link problem: + * {@link @minecraft/example-module.ExampleProblem4} * This line has multiple links! * {@link @minecraft/example-module} {@link ExampleFunction} * {@link ExampleConstant} {@link ExampleObject} @@ -2502,6 +2530,8 @@ exports[`Type Linking > Properly generates documentation for types that are link * Example enum: {@link ExampleEnum} * Example enum value: {@link ExampleEnum.ExampleValue} * Example error: {@link ExampleError} + * Example link problem: + * {@link @minecraft/example-module.ExampleProblem4} * This line has multiple links! * {@link @minecraft/example-module} {@link ExampleFunction} * {@link ExampleConstant} {@link ExampleObject} @@ -2608,6 +2638,12 @@ exports[`Type Linking > Properly generates documentation for types that are link * Example enum value: * {@link minecraftexamplemodule.ExampleEnum.ExampleValue} * Example error: {@link minecraftexamplemodule#ExampleError} + * Example link problem: + * {@link @minecraft/example-module.ExampleProblem} + * Example link problem: + * {@link @minecraft/example-module.ExampleProblem2} + * Example link problem: + * {@link @minecraft/example-module.ExampleProblem3} * This line has multiple links and lots of text! This is the * first link {@link minecraftexamplemodule}, and this is the * second. {@link minecraftexamplemodule#ExampleFunction} From ec18abf9ae0862d04c65ffb7b70e8929215e43a2 Mon Sep 17 00:00:00 2001 From: Brandon Chan Date: Thu, 9 Jul 2026 19:23:14 -0700 Subject: [PATCH 5/7] make error logs more detailed --- .../docs/@minecraft/example-module/info.json | 21 +++++++++++++++++++ .../test/type_linking/typeLinking.spec.ts | 18 +++++++++------- .../src/filters/CommonFilters.ts | 5 +++-- 3 files changed, 34 insertions(+), 10 deletions(-) diff --git a/tools/api-docs-generator-test-snapshots/test/type_linking/docs/@minecraft/example-module/info.json b/tools/api-docs-generator-test-snapshots/test/type_linking/docs/@minecraft/example-module/info.json index 15e4a7f..2c0b33d 100644 --- a/tools/api-docs-generator-test-snapshots/test/type_linking/docs/@minecraft/example-module/info.json +++ b/tools/api-docs-generator-test-snapshots/test/type_linking/docs/@minecraft/example-module/info.json @@ -1,4 +1,5 @@ { + "default": { "description": [ "This is a description with a ton of links:", "Example module: {@link @minecraft/example-module}", @@ -16,4 +17,24 @@ "Example link problem: {@link @minecraft/example-module.ExampleProblem4}", "This line has multiple links! {@link @minecraft/example-module} {@link @minecraft/example-module.ExampleFunction} {@link @minecraft/example-module.ExampleConstant} {@link @minecraft/example-module.ExampleObject}" ] +}, +"2": { + "description": [ + "This is a description with a ton of links:", + "Example module: {@link @minecraft/example-module}", + "Example module function: {@link @minecraft/example-module.ExampleFunction}", + "Example module constant: {@link @minecraft/example-module.ExampleConstant}", + "Example module object: {@link @minecraft/example-module.ExampleObject}", + "Example class: {@link @minecraft/example-module.ExampleClass}", + "Example class property: {@link @minecraft/example-module.ExampleClass.ExampleProperty}", + "Example class method: {@link @minecraft/example-module.ExampleClass.ExampleMethod}", + "Example interface: {@link @minecraft/example-module.ExampleInterface}", + "Example interface property: {@link @minecraft/example-module.ExampleInterface.ExampleProperty}", + "Example enum: {@link @minecraft/example-module.ExampleEnum}", + "Example enum value: {@link @minecraft/example-module.ExampleEnum.ExampleValue}", + "Example error: {@link @minecraft/example-module.ExampleError}", + "Example link problem: {@link @minecraft/example-module.ExampleProblem5}", + "This line has multiple links! {@link @minecraft/example-module} {@link @minecraft/example-module.ExampleFunction} {@link @minecraft/example-module.ExampleConstant} {@link @minecraft/example-module.ExampleObject}" + ] +} } \ No newline at end of file diff --git a/tools/api-docs-generator-test-snapshots/test/type_linking/typeLinking.spec.ts b/tools/api-docs-generator-test-snapshots/test/type_linking/typeLinking.spec.ts index 004fa62..15d778f 100644 --- a/tools/api-docs-generator-test-snapshots/test/type_linking/typeLinking.spec.ts +++ b/tools/api-docs-generator-test-snapshots/test/type_linking/typeLinking.spec.ts @@ -11,10 +11,11 @@ describe('Type Linking', () => { testDir: __dirname, generators: ['ts', 'msdocs'], expectedLoggedErrorMessages: [ - '[ERROR] Link(s) not found. Please check spelling or if the modules or members are defined: [["{@link @minecraft/example-module.ExampleProblem}","@minecraft/example-module.ExampleProblem"]]', - '[ERROR] Link(s) not found. Please check spelling or if the modules or members are defined: [["{@link @minecraft/example-module.ExampleProblem2}","@minecraft/example-module.ExampleProblem2"]]', - '[ERROR] Link(s) not found. Please check spelling or if the modules or members are defined: [["{@link @minecraft/example-module.ExampleProblem3}","@minecraft/example-module.ExampleProblem3"]]', - '[ERROR] Link(s) not found. Please check spelling or if the modules or members are defined: [["{@link @minecraft/example-module.ExampleProblem4}","@minecraft/example-module.ExampleProblem4"]]', + '[ERROR] Link(s) not found in @minecraft/example-module-2 version 1.0.0. Please check spelling or if the modules or members are defined: [["{@link @minecraft/example-module.ExampleProblem}","@minecraft/example-module.ExampleProblem"]]', + '[ERROR] Link(s) not found in @minecraft/example-module-2 version 1.0.0. Please check spelling or if the modules or members are defined: [["{@link @minecraft/example-module.ExampleProblem2}","@minecraft/example-module.ExampleProblem2"]]', + '[ERROR] Link(s) not found in @minecraft/example-module-2 version 1.0.0. Please check spelling or if the modules or members are defined: [["{@link @minecraft/example-module.ExampleProblem3}","@minecraft/example-module.ExampleProblem3"]]', + '[ERROR] Link(s) not found in @minecraft/example-module version 1.0.0. Please check spelling or if the modules or members are defined: [["{@link @minecraft/example-module.ExampleProblem4}","@minecraft/example-module.ExampleProblem4"]]', + '[ERROR] Link(s) not found in @minecraft/example-module version 1.1.0. Please check spelling or if the modules or members are defined: [["{@link @minecraft/example-module.ExampleProblem4}","@minecraft/example-module.ExampleProblem4"]]', ], }); }); @@ -26,10 +27,11 @@ describe('Type Linking', () => { additionalArgs: '--include-base', outDir: join(__dirname, 'include_base_output'), expectedLoggedErrorMessages: [ - '[ERROR] Link(s) not found. Please check spelling or if the modules or members are defined: [["{@link @minecraft/example-module.ExampleProblem}","@minecraft/example-module.ExampleProblem"]]', - '[ERROR] Link(s) not found. Please check spelling or if the modules or members are defined: [["{@link @minecraft/example-module.ExampleProblem2}","@minecraft/example-module.ExampleProblem2"]]', - '[ERROR] Link(s) not found. Please check spelling or if the modules or members are defined: [["{@link @minecraft/example-module.ExampleProblem3}","@minecraft/example-module.ExampleProblem3"]]', - '[ERROR] Link(s) not found. Please check spelling or if the modules or members are defined: [["{@link @minecraft/example-module.ExampleProblem4}","@minecraft/example-module.ExampleProblem4"]]', + '[ERROR] Link(s) not found in @minecraft/example-module-2 version 1.0.0. Please check spelling or if the modules or members are defined: [["{@link @minecraft/example-module.ExampleProblem}","@minecraft/example-module.ExampleProblem"]]', + '[ERROR] Link(s) not found in @minecraft/example-module-2 version 1.0.0. Please check spelling or if the modules or members are defined: [["{@link @minecraft/example-module.ExampleProblem2}","@minecraft/example-module.ExampleProblem2"]]', + '[ERROR] Link(s) not found in @minecraft/example-module-2 version 1.0.0. Please check spelling or if the modules or members are defined: [["{@link @minecraft/example-module.ExampleProblem3}","@minecraft/example-module.ExampleProblem3"]]', + '[ERROR] Link(s) not found in @minecraft/example-module version 1.0.0. Please check spelling or if the modules or members are defined: [["{@link @minecraft/example-module.ExampleProblem4}","@minecraft/example-module.ExampleProblem4"]]', + '[ERROR] Link(s) not found in @minecraft/example-module version 1.1.0. Please check spelling or if the modules or members are defined: [["{@link @minecraft/example-module.ExampleProblem4}","@minecraft/example-module.ExampleProblem4"]]', ], }); }); diff --git a/tools/api-docs-generator/src/filters/CommonFilters.ts b/tools/api-docs-generator/src/filters/CommonFilters.ts index c9ccc28..45347bb 100644 --- a/tools/api-docs-generator/src/filters/CommonFilters.ts +++ b/tools/api-docs-generator/src/filters/CommonFilters.ts @@ -311,9 +311,10 @@ function linkSymbols( result.push(str); - if (linkMatches.length > 0) { + const hasLinksRemaining = str.includes('@link'); + if (hasLinksRemaining && linkMatches.length > 0) { log.error( - `Link(s) not found. Please check spelling or if the modules or members are defined: ${JSON.stringify(linkMatches)}` + `Link(s) not found in ${fromModule.name} version ${fromModule.version}. Please check spelling or if the modules or members are defined: ${JSON.stringify(linkMatches)}` ); } } From 6529b1f7ebe9bceb61f36a9bcaec8dee777378be Mon Sep 17 00:00:00 2001 From: Brandon Chan Date: Mon, 13 Jul 2026 13:38:12 -0700 Subject: [PATCH 6/7] Adjust to use only latest --- .../deprecationWarning.spec.ts.snap | 4 - .../hybrid_script_native_module.spec.ts.snap | 136 ------------------ ...minecraftVersionShippedStable.spec.ts.snap | 120 ---------------- .../onlyGenerateLatestVersions.spec.ts.snap | 16 --- .../__snapshots__/typeLinking.spec.ts.snap | 38 ----- .../src/filters/CommonFilters.ts | 2 +- 6 files changed, 1 insertion(+), 315 deletions(-) diff --git a/tools/api-docs-generator-test-snapshots/test/deprecation_warning/__snapshots__/deprecationWarning.spec.ts.snap b/tools/api-docs-generator-test-snapshots/test/deprecation_warning/__snapshots__/deprecationWarning.spec.ts.snap index 586986f..b26f2e6 100644 --- a/tools/api-docs-generator-test-snapshots/test/deprecation_warning/__snapshots__/deprecationWarning.spec.ts.snap +++ b/tools/api-docs-generator-test-snapshots/test/deprecation_warning/__snapshots__/deprecationWarning.spec.ts.snap @@ -666,10 +666,6 @@ export enum StableEnumWithDeprecatedConstant { /** * @deprecated This class is deprecated and will be removed in 2.0.0. - * - * Custom deprecation message! - * - * This class is deprecated. */ export class DeprecatedClass { private constructor(); diff --git a/tools/api-docs-generator-test-snapshots/test/hybrid_script_native_module/__snapshots__/hybrid_script_native_module.spec.ts.snap b/tools/api-docs-generator-test-snapshots/test/hybrid_script_native_module/__snapshots__/hybrid_script_native_module.spec.ts.snap index fb6c60d..a997567 100644 --- a/tools/api-docs-generator-test-snapshots/test/hybrid_script_native_module/__snapshots__/hybrid_script_native_module.spec.ts.snap +++ b/tools/api-docs-generator-test-snapshots/test/hybrid_script_native_module/__snapshots__/hybrid_script_native_module.spec.ts.snap @@ -535,66 +535,32 @@ exports[`Hybrid Script and Native Module > Generates documentation for both the * \`\`\` * */ -/** - * A script generated enum - */ export declare enum ScriptGeneratedEnum { First = 'first', Second = 'second', } -/** - * This overwrites the TSDoc from TypeAliasWithInfoJsonComments - * with an info.json file's description - */ export type TypeAliasWithInfoJsonComments = { id: string; }; -/** - * This doc text is extracted from TSDoc comments - */ export type TypeAliasWithTSDocComments = boolean | string; -/** - * A script generated class - */ export declare class ScriptGeneratedClass { /** * @remarks - * A script generated property - * * This property can't be used in restricted-execution mode. * */ testProperty: string | undefined; /** * @remarks - * A script generated function with doc text defined in TSDoc - * comments - * * This function can't be called in restricted-execution mode. * - * @param tsdocParam - * Param comment from TSDoc - * @param msdocParam - * This overwrites the TSDoc for msdocParam with an info.json - * file's description - * @returns - * This is a return comment defined in info.json - * @throws - * Throws comment in TSDocs */ testFunctionWithTSDocComments(tsdocParam: number, msdocParam: number): boolean; } -/** - * @remarks - * A native bound function. - * - * @returns - * A boolean value. - */ export function NativeBoundFunction(): boolean; " `; @@ -1025,66 +991,32 @@ exports[`Hybrid Script and Native Module > Generates documentation for both the * \`\`\` * */ -/** - * A script generated enum - */ export declare enum ScriptGeneratedEnum { First = 'first', Second = 'second', } -/** - * This overwrites the TSDoc from TypeAliasWithInfoJsonComments - * with an info.json file's description - */ export type TypeAliasWithInfoJsonComments = { id: string; }; -/** - * This doc text is extracted from TSDoc comments - */ export type TypeAliasWithTSDocComments = boolean | string; -/** - * A script generated class - */ export declare class ScriptGeneratedClass { /** * @remarks - * A script generated property - * * This property can't be used in restricted-execution mode. * */ testProperty: string | undefined; /** * @remarks - * A script generated function with doc text defined in TSDoc - * comments - * * This function can't be called in restricted-execution mode. * - * @param tsdocParam - * Param comment from TSDoc - * @param msdocParam - * This overwrites the TSDoc for msdocParam with an info.json - * file's description - * @returns - * This is a return comment defined in info.json - * @throws - * Throws comment in TSDocs */ testFunctionWithTSDocComments(tsdocParam: number, msdocParam: number): boolean; } -/** - * @remarks - * A native bound function. - * - * @returns - * A boolean value. - */ export function NativeBoundFunction(): boolean; " `; @@ -1773,66 +1705,32 @@ exports[`Hybrid Script and Native Module > Properly generates documentation for * \`\`\` * */ -/** - * A script generated enum - */ export declare enum ScriptGeneratedEnum { First = 'first', Second = 'second', } -/** - * This overwrites the TSDoc from TypeAliasWithInfoJsonComments - * with an info.json file's description - */ export type TypeAliasWithInfoJsonComments = { id: string; }; -/** - * This doc text is extracted from TSDoc comments - */ export type TypeAliasWithTSDocComments = boolean | string; -/** - * A script generated class - */ export declare class ScriptGeneratedClass { /** * @remarks - * A script generated property - * * This property can't be used in restricted-execution mode. * */ testProperty: string | undefined; /** * @remarks - * A script generated function with doc text defined in TSDoc - * comments - * * This function can't be called in restricted-execution mode. * - * @param tsdocParam - * Param comment from TSDoc - * @param msdocParam - * This overwrites the TSDoc for msdocParam with an info.json - * file's description - * @returns - * This is a return comment defined in info.json - * @throws - * Throws comment in TSDocs */ testFunctionWithTSDocComments(tsdocParam: number, msdocParam: number): boolean; } -/** - * @remarks - * A native bound function. - * - * @returns - * A boolean value. - */ export function NativeBoundFunction(): boolean; " `; @@ -2094,66 +1992,32 @@ exports[`Hybrid Script and Native Module > Properly generates documentation for * \`\`\` * */ -/** - * A script generated enum - */ export declare enum ScriptGeneratedEnum { First = 'first', Second = 'second', } -/** - * This overwrites the TSDoc from TypeAliasWithInfoJsonComments - * with an info.json file's description - */ export type TypeAliasWithInfoJsonComments = { id: string; }; -/** - * This doc text is extracted from TSDoc comments - */ export type TypeAliasWithTSDocComments = boolean | string; -/** - * A script generated class - */ export declare class ScriptGeneratedClass { /** * @remarks - * A script generated property - * * This property can't be used in restricted-execution mode. * */ testProperty: string | undefined; /** * @remarks - * A script generated function with doc text defined in TSDoc - * comments - * * This function can't be called in restricted-execution mode. * - * @param tsdocParam - * Param comment from TSDoc - * @param msdocParam - * This overwrites the TSDoc for msdocParam with an info.json - * file's description - * @returns - * This is a return comment defined in info.json - * @throws - * Throws comment in TSDocs */ testFunctionWithTSDocComments(tsdocParam: number, msdocParam: number): boolean; } -/** - * @remarks - * A native bound function. - * - * @returns - * A boolean value. - */ export function NativeBoundFunction(): boolean; " `; diff --git a/tools/api-docs-generator-test-snapshots/test/minecraft_version_shipped_stable/__snapshots__/minecraftVersionShippedStable.spec.ts.snap b/tools/api-docs-generator-test-snapshots/test/minecraft_version_shipped_stable/__snapshots__/minecraftVersionShippedStable.spec.ts.snap index 545ec43..df7f132 100644 --- a/tools/api-docs-generator-test-snapshots/test/minecraft_version_shipped_stable/__snapshots__/minecraftVersionShippedStable.spec.ts.snap +++ b/tools/api-docs-generator-test-snapshots/test/minecraft_version_shipped_stable/__snapshots__/minecraftVersionShippedStable.spec.ts.snap @@ -429,8 +429,6 @@ exports[`Minecraft Version Shipped Stable > Generates correct output for module exports[`Minecraft Version Shipped Stable > Generates correct output for module with stable shipped version and beta in a new version in preview > npm/types/@minecraft/module@2.0.0-rc.1.2.3-preview.5/README.md 1`] = ` "# \`@minecraft/module\` -The description for the module in V2 stable - ## **NOTE: This version of this module is still in pre-release. It may change or it may be removed in future releases.** See full documentation for this module here: @@ -450,7 +448,6 @@ exports[`Minecraft Version Shipped Stable > Generates correct output for module /** * @preview * @packageDocumentation - * The description for the module in V2 stable * * Manifest Details * \`\`\`json @@ -463,20 +460,8 @@ exports[`Minecraft Version Shipped Stable > Generates correct output for module */ /** * @rc - * @remarks - * Test function woot woot! - * - * @param arg - * default arg description!. - * @returns - * Returns default stuff. */ export function TestFunction(arg: string): number; -/** - * @remarks - * The description for GlobalConstantStable in V2 stable - * - */ export const GlobalConstantStable = 8; " `; @@ -503,8 +488,6 @@ exports[`Minecraft Version Shipped Stable > Generates correct output for module exports[`Minecraft Version Shipped Stable > Generates correct output for module with stable shipped version and beta in a new version in preview > npm/types/@minecraft/module@2.1.0-beta.1.2.3-preview.5/README.md 1`] = ` "# \`@minecraft/module\` -The description for the module in beta - ## **NOTE: This version of this module is still in pre-release. It may change or it may be removed in future releases.** See full documentation for this module here: @@ -524,7 +507,6 @@ exports[`Minecraft Version Shipped Stable > Generates correct output for module /** * @beta * @packageDocumentation - * The description for the module in beta * * Manifest Details * \`\`\`json @@ -537,24 +519,12 @@ exports[`Minecraft Version Shipped Stable > Generates correct output for module */ /** * @rc - * @remarks - * Test function woot woot! - * - * @param arg - * default arg description!. - * @returns - * Returns default stuff. */ export function TestFunction(arg: string): number; /** * @beta */ export const GlobalConstantBeta = 8; -/** - * @remarks - * The description for GlobalConstantStable in V2 stable - * - */ export const GlobalConstantStable = 8; " `; @@ -708,7 +678,6 @@ exports[`Minecraft Version Shipped Stable > Generates correct output for module /** * @preview * @packageDocumentation - * The description for the module in V2 stable * * Manifest Details * \`\`\`json @@ -721,20 +690,8 @@ exports[`Minecraft Version Shipped Stable > Generates correct output for module */ /** * @rc - * @remarks - * Test function woot woot! - * - * @param arg - * default arg description!. - * @returns - * Returns default stuff. */ export function TestFunction(arg: string): number; -/** - * @remarks - * The description for GlobalConstantStable in V2 stable - * - */ export const GlobalConstantStable = 8; " `; @@ -751,7 +708,6 @@ exports[`Minecraft Version Shipped Stable > Generates correct output for module /** * @beta * @packageDocumentation - * The description for the module in beta * * Manifest Details * \`\`\`json @@ -764,24 +720,12 @@ exports[`Minecraft Version Shipped Stable > Generates correct output for module */ /** * @rc - * @remarks - * Test function woot woot! - * - * @param arg - * default arg description!. - * @returns - * Returns default stuff. */ export function TestFunction(arg: string): number; /** * @beta */ export const GlobalConstantBeta = 8; -/** - * @remarks - * The description for GlobalConstantStable in V2 stable - * - */ export const GlobalConstantStable = 8; " `; @@ -1250,8 +1194,6 @@ exports[`Minecraft Version Shipped Stable > Generates correct output for module exports[`Minecraft Version Shipped Stable > Generates correct output for module with stable shipped version and beta in a new version in stable > npm/types/@minecraft/module@2.0.0/README.md 1`] = ` "# \`@minecraft/module\` -The description for the module in V2 stable - See full documentation for this module here: https://learn.microsoft.com/en-us/minecraft/creator/scriptapi/minecraft/module/minecraft-module" @@ -1268,7 +1210,6 @@ exports[`Minecraft Version Shipped Stable > Generates correct output for module ***************************************************************************** */ /** * @packageDocumentation - * The description for the module in V2 stable * * Manifest Details * \`\`\`json @@ -1279,21 +1220,7 @@ exports[`Minecraft Version Shipped Stable > Generates correct output for module * \`\`\` * */ -/** - * @remarks - * Test function woot woot! - * - * @param arg - * default arg description!. - * @returns - * Returns default stuff. - */ export function TestFunction(arg: string): number; -/** - * @remarks - * The description for GlobalConstantStable in V2 stable - * - */ export const GlobalConstantStable = 8; " `; @@ -1320,8 +1247,6 @@ exports[`Minecraft Version Shipped Stable > Generates correct output for module exports[`Minecraft Version Shipped Stable > Generates correct output for module with stable shipped version and beta in a new version in stable > npm/types/@minecraft/module@2.1.0-beta.1.2.3-stable/README.md 1`] = ` "# \`@minecraft/module\` -The description for the module in beta - ## **NOTE: This version of this module is still in pre-release. It may change or it may be removed in future releases.** See full documentation for this module here: @@ -1341,7 +1266,6 @@ exports[`Minecraft Version Shipped Stable > Generates correct output for module /** * @beta * @packageDocumentation - * The description for the module in beta * * Manifest Details * \`\`\`json @@ -1352,25 +1276,11 @@ exports[`Minecraft Version Shipped Stable > Generates correct output for module * \`\`\` * */ -/** - * @remarks - * Test function woot woot! - * - * @param arg - * default arg description!. - * @returns - * Returns default stuff. - */ export function TestFunction(arg: string): number; /** * @beta */ export const GlobalConstantBeta = 8; -/** - * @remarks - * The description for GlobalConstantStable in V2 stable - * - */ export const GlobalConstantStable = 8; " `; @@ -1521,7 +1431,6 @@ exports[`Minecraft Version Shipped Stable > Generates correct output for module ***************************************************************************** */ /** * @packageDocumentation - * The description for the module in V2 stable * * Manifest Details * \`\`\`json @@ -1532,21 +1441,7 @@ exports[`Minecraft Version Shipped Stable > Generates correct output for module * \`\`\` * */ -/** - * @remarks - * Test function woot woot! - * - * @param arg - * default arg description!. - * @returns - * Returns default stuff. - */ export function TestFunction(arg: string): number; -/** - * @remarks - * The description for GlobalConstantStable in V2 stable - * - */ export const GlobalConstantStable = 8; " `; @@ -1563,7 +1458,6 @@ exports[`Minecraft Version Shipped Stable > Generates correct output for module /** * @beta * @packageDocumentation - * The description for the module in beta * * Manifest Details * \`\`\`json @@ -1574,25 +1468,11 @@ exports[`Minecraft Version Shipped Stable > Generates correct output for module * \`\`\` * */ -/** - * @remarks - * Test function woot woot! - * - * @param arg - * default arg description!. - * @returns - * Returns default stuff. - */ export function TestFunction(arg: string): number; /** * @beta */ export const GlobalConstantBeta = 8; -/** - * @remarks - * The description for GlobalConstantStable in V2 stable - * - */ export const GlobalConstantStable = 8; " `; diff --git a/tools/api-docs-generator-test-snapshots/test/only_generate_latest_versions/__snapshots__/onlyGenerateLatestVersions.spec.ts.snap b/tools/api-docs-generator-test-snapshots/test/only_generate_latest_versions/__snapshots__/onlyGenerateLatestVersions.spec.ts.snap index 26c936d..b4778a3 100644 --- a/tools/api-docs-generator-test-snapshots/test/only_generate_latest_versions/__snapshots__/onlyGenerateLatestVersions.spec.ts.snap +++ b/tools/api-docs-generator-test-snapshots/test/only_generate_latest_versions/__snapshots__/onlyGenerateLatestVersions.spec.ts.snap @@ -317,7 +317,6 @@ exports[`Only Generate Latest Script Module Versions > Generates correct output ***************************************************************************** */ /** * @packageDocumentation - * This should only be applied in the latest module! * * Manifest Details * \`\`\`json @@ -328,23 +327,8 @@ exports[`Only Generate Latest Script Module Versions > Generates correct output * \`\`\` * */ -/** - * @remarks - * This should only be applied in the latest module! - * - */ export const GlobalConstantV100 = 8; -/** - * @remarks - * This should only be applied in the latest module! - * - */ export const GlobalConstantV110 = 8; -/** - * @remarks - * This should only be applied in the latest module! - * - */ export const GlobalConstantV200 = 8; " `; diff --git a/tools/api-docs-generator-test-snapshots/test/type_linking/__snapshots__/typeLinking.spec.ts.snap b/tools/api-docs-generator-test-snapshots/test/type_linking/__snapshots__/typeLinking.spec.ts.snap index 25c1c9a..2c2eb5c 100644 --- a/tools/api-docs-generator-test-snapshots/test/type_linking/__snapshots__/typeLinking.spec.ts.snap +++ b/tools/api-docs-generator-test-snapshots/test/type_linking/__snapshots__/typeLinking.spec.ts.snap @@ -871,25 +871,6 @@ exports[`Type Linking > Properly generates documentation for types that are link ***************************************************************************** */ /** * @packageDocumentation - * This is a description with a ton of links: - * Example module: {@link @minecraft/example-module} - * Example module function: {@link ExampleFunction} - * Example module constant: {@link ExampleConstant} - * Example module object: {@link ExampleObject} - * Example class: {@link ExampleClass} - * Example class property: {@link ExampleClass.ExampleProperty} - * Example class method: {@link ExampleClass.ExampleMethod} - * Example interface: {@link ExampleInterface} - * Example interface property: - * {@link ExampleInterface.ExampleProperty} - * Example enum: {@link ExampleEnum} - * Example enum value: {@link ExampleEnum.ExampleValue} - * Example error: {@link ExampleError} - * Example link problem: - * {@link @minecraft/example-module.ExampleProblem4} - * This line has multiple links! - * {@link @minecraft/example-module} {@link ExampleFunction} - * {@link ExampleConstant} {@link ExampleObject} * * Manifest Details * \`\`\`json @@ -2416,25 +2397,6 @@ exports[`Type Linking > Properly generates documentation for types that are link ***************************************************************************** */ /** * @packageDocumentation - * This is a description with a ton of links: - * Example module: {@link @minecraft/example-module} - * Example module function: {@link ExampleFunction} - * Example module constant: {@link ExampleConstant} - * Example module object: {@link ExampleObject} - * Example class: {@link ExampleClass} - * Example class property: {@link ExampleClass.ExampleProperty} - * Example class method: {@link ExampleClass.ExampleMethod} - * Example interface: {@link ExampleInterface} - * Example interface property: - * {@link ExampleInterface.ExampleProperty} - * Example enum: {@link ExampleEnum} - * Example enum value: {@link ExampleEnum.ExampleValue} - * Example error: {@link ExampleError} - * Example link problem: - * {@link @minecraft/example-module.ExampleProblem4} - * This line has multiple links! - * {@link @minecraft/example-module} {@link ExampleFunction} - * {@link ExampleConstant} {@link ExampleObject} * * Manifest Details * \`\`\`json diff --git a/tools/api-docs-generator/src/filters/CommonFilters.ts b/tools/api-docs-generator/src/filters/CommonFilters.ts index 45347bb..cee006b 100644 --- a/tools/api-docs-generator/src/filters/CommonFilters.ts +++ b/tools/api-docs-generator/src/filters/CommonFilters.ts @@ -1058,7 +1058,7 @@ function addDescriptionsAndExamples(releases: MinecraftRelease[], fileLoader?: F } for (const release of releases) { - for (const moduleJson of release.script_modules) { + for (const moduleJson of release.getLatestScriptModulesByMajorVersion()) { const dependentModules = getLatestDependentScriptModules(release.script_modules, moduleJson); addModuleDescriptions(fileLoader, moduleJson, dependentModules); From d5f4ca1ab196400d4ce23361e3f423227091a4e8 Mon Sep 17 00:00:00 2001 From: Brandon Chan Date: Tue, 14 Jul 2026 10:53:03 -0700 Subject: [PATCH 7/7] Add flag to module selecting --- .../deprecationWarning.spec.ts.snap | 4 + .../hybrid_script_native_module.spec.ts.snap | 136 ++++++++++++++++++ ...minecraftVersionShippedStable.spec.ts.snap | 120 ++++++++++++++++ .../onlyGenerateLatestVersions.spec.ts.snap | 16 +++ .../src/filters/CommonFilters.ts | 6 +- 5 files changed, 280 insertions(+), 2 deletions(-) diff --git a/tools/api-docs-generator-test-snapshots/test/deprecation_warning/__snapshots__/deprecationWarning.spec.ts.snap b/tools/api-docs-generator-test-snapshots/test/deprecation_warning/__snapshots__/deprecationWarning.spec.ts.snap index b26f2e6..586986f 100644 --- a/tools/api-docs-generator-test-snapshots/test/deprecation_warning/__snapshots__/deprecationWarning.spec.ts.snap +++ b/tools/api-docs-generator-test-snapshots/test/deprecation_warning/__snapshots__/deprecationWarning.spec.ts.snap @@ -666,6 +666,10 @@ export enum StableEnumWithDeprecatedConstant { /** * @deprecated This class is deprecated and will be removed in 2.0.0. + * + * Custom deprecation message! + * + * This class is deprecated. */ export class DeprecatedClass { private constructor(); diff --git a/tools/api-docs-generator-test-snapshots/test/hybrid_script_native_module/__snapshots__/hybrid_script_native_module.spec.ts.snap b/tools/api-docs-generator-test-snapshots/test/hybrid_script_native_module/__snapshots__/hybrid_script_native_module.spec.ts.snap index a997567..fb6c60d 100644 --- a/tools/api-docs-generator-test-snapshots/test/hybrid_script_native_module/__snapshots__/hybrid_script_native_module.spec.ts.snap +++ b/tools/api-docs-generator-test-snapshots/test/hybrid_script_native_module/__snapshots__/hybrid_script_native_module.spec.ts.snap @@ -535,32 +535,66 @@ exports[`Hybrid Script and Native Module > Generates documentation for both the * \`\`\` * */ +/** + * A script generated enum + */ export declare enum ScriptGeneratedEnum { First = 'first', Second = 'second', } +/** + * This overwrites the TSDoc from TypeAliasWithInfoJsonComments + * with an info.json file's description + */ export type TypeAliasWithInfoJsonComments = { id: string; }; +/** + * This doc text is extracted from TSDoc comments + */ export type TypeAliasWithTSDocComments = boolean | string; +/** + * A script generated class + */ export declare class ScriptGeneratedClass { /** * @remarks + * A script generated property + * * This property can't be used in restricted-execution mode. * */ testProperty: string | undefined; /** * @remarks + * A script generated function with doc text defined in TSDoc + * comments + * * This function can't be called in restricted-execution mode. * + * @param tsdocParam + * Param comment from TSDoc + * @param msdocParam + * This overwrites the TSDoc for msdocParam with an info.json + * file's description + * @returns + * This is a return comment defined in info.json + * @throws + * Throws comment in TSDocs */ testFunctionWithTSDocComments(tsdocParam: number, msdocParam: number): boolean; } +/** + * @remarks + * A native bound function. + * + * @returns + * A boolean value. + */ export function NativeBoundFunction(): boolean; " `; @@ -991,32 +1025,66 @@ exports[`Hybrid Script and Native Module > Generates documentation for both the * \`\`\` * */ +/** + * A script generated enum + */ export declare enum ScriptGeneratedEnum { First = 'first', Second = 'second', } +/** + * This overwrites the TSDoc from TypeAliasWithInfoJsonComments + * with an info.json file's description + */ export type TypeAliasWithInfoJsonComments = { id: string; }; +/** + * This doc text is extracted from TSDoc comments + */ export type TypeAliasWithTSDocComments = boolean | string; +/** + * A script generated class + */ export declare class ScriptGeneratedClass { /** * @remarks + * A script generated property + * * This property can't be used in restricted-execution mode. * */ testProperty: string | undefined; /** * @remarks + * A script generated function with doc text defined in TSDoc + * comments + * * This function can't be called in restricted-execution mode. * + * @param tsdocParam + * Param comment from TSDoc + * @param msdocParam + * This overwrites the TSDoc for msdocParam with an info.json + * file's description + * @returns + * This is a return comment defined in info.json + * @throws + * Throws comment in TSDocs */ testFunctionWithTSDocComments(tsdocParam: number, msdocParam: number): boolean; } +/** + * @remarks + * A native bound function. + * + * @returns + * A boolean value. + */ export function NativeBoundFunction(): boolean; " `; @@ -1705,32 +1773,66 @@ exports[`Hybrid Script and Native Module > Properly generates documentation for * \`\`\` * */ +/** + * A script generated enum + */ export declare enum ScriptGeneratedEnum { First = 'first', Second = 'second', } +/** + * This overwrites the TSDoc from TypeAliasWithInfoJsonComments + * with an info.json file's description + */ export type TypeAliasWithInfoJsonComments = { id: string; }; +/** + * This doc text is extracted from TSDoc comments + */ export type TypeAliasWithTSDocComments = boolean | string; +/** + * A script generated class + */ export declare class ScriptGeneratedClass { /** * @remarks + * A script generated property + * * This property can't be used in restricted-execution mode. * */ testProperty: string | undefined; /** * @remarks + * A script generated function with doc text defined in TSDoc + * comments + * * This function can't be called in restricted-execution mode. * + * @param tsdocParam + * Param comment from TSDoc + * @param msdocParam + * This overwrites the TSDoc for msdocParam with an info.json + * file's description + * @returns + * This is a return comment defined in info.json + * @throws + * Throws comment in TSDocs */ testFunctionWithTSDocComments(tsdocParam: number, msdocParam: number): boolean; } +/** + * @remarks + * A native bound function. + * + * @returns + * A boolean value. + */ export function NativeBoundFunction(): boolean; " `; @@ -1992,32 +2094,66 @@ exports[`Hybrid Script and Native Module > Properly generates documentation for * \`\`\` * */ +/** + * A script generated enum + */ export declare enum ScriptGeneratedEnum { First = 'first', Second = 'second', } +/** + * This overwrites the TSDoc from TypeAliasWithInfoJsonComments + * with an info.json file's description + */ export type TypeAliasWithInfoJsonComments = { id: string; }; +/** + * This doc text is extracted from TSDoc comments + */ export type TypeAliasWithTSDocComments = boolean | string; +/** + * A script generated class + */ export declare class ScriptGeneratedClass { /** * @remarks + * A script generated property + * * This property can't be used in restricted-execution mode. * */ testProperty: string | undefined; /** * @remarks + * A script generated function with doc text defined in TSDoc + * comments + * * This function can't be called in restricted-execution mode. * + * @param tsdocParam + * Param comment from TSDoc + * @param msdocParam + * This overwrites the TSDoc for msdocParam with an info.json + * file's description + * @returns + * This is a return comment defined in info.json + * @throws + * Throws comment in TSDocs */ testFunctionWithTSDocComments(tsdocParam: number, msdocParam: number): boolean; } +/** + * @remarks + * A native bound function. + * + * @returns + * A boolean value. + */ export function NativeBoundFunction(): boolean; " `; diff --git a/tools/api-docs-generator-test-snapshots/test/minecraft_version_shipped_stable/__snapshots__/minecraftVersionShippedStable.spec.ts.snap b/tools/api-docs-generator-test-snapshots/test/minecraft_version_shipped_stable/__snapshots__/minecraftVersionShippedStable.spec.ts.snap index df7f132..545ec43 100644 --- a/tools/api-docs-generator-test-snapshots/test/minecraft_version_shipped_stable/__snapshots__/minecraftVersionShippedStable.spec.ts.snap +++ b/tools/api-docs-generator-test-snapshots/test/minecraft_version_shipped_stable/__snapshots__/minecraftVersionShippedStable.spec.ts.snap @@ -429,6 +429,8 @@ exports[`Minecraft Version Shipped Stable > Generates correct output for module exports[`Minecraft Version Shipped Stable > Generates correct output for module with stable shipped version and beta in a new version in preview > npm/types/@minecraft/module@2.0.0-rc.1.2.3-preview.5/README.md 1`] = ` "# \`@minecraft/module\` +The description for the module in V2 stable + ## **NOTE: This version of this module is still in pre-release. It may change or it may be removed in future releases.** See full documentation for this module here: @@ -448,6 +450,7 @@ exports[`Minecraft Version Shipped Stable > Generates correct output for module /** * @preview * @packageDocumentation + * The description for the module in V2 stable * * Manifest Details * \`\`\`json @@ -460,8 +463,20 @@ exports[`Minecraft Version Shipped Stable > Generates correct output for module */ /** * @rc + * @remarks + * Test function woot woot! + * + * @param arg + * default arg description!. + * @returns + * Returns default stuff. */ export function TestFunction(arg: string): number; +/** + * @remarks + * The description for GlobalConstantStable in V2 stable + * + */ export const GlobalConstantStable = 8; " `; @@ -488,6 +503,8 @@ exports[`Minecraft Version Shipped Stable > Generates correct output for module exports[`Minecraft Version Shipped Stable > Generates correct output for module with stable shipped version and beta in a new version in preview > npm/types/@minecraft/module@2.1.0-beta.1.2.3-preview.5/README.md 1`] = ` "# \`@minecraft/module\` +The description for the module in beta + ## **NOTE: This version of this module is still in pre-release. It may change or it may be removed in future releases.** See full documentation for this module here: @@ -507,6 +524,7 @@ exports[`Minecraft Version Shipped Stable > Generates correct output for module /** * @beta * @packageDocumentation + * The description for the module in beta * * Manifest Details * \`\`\`json @@ -519,12 +537,24 @@ exports[`Minecraft Version Shipped Stable > Generates correct output for module */ /** * @rc + * @remarks + * Test function woot woot! + * + * @param arg + * default arg description!. + * @returns + * Returns default stuff. */ export function TestFunction(arg: string): number; /** * @beta */ export const GlobalConstantBeta = 8; +/** + * @remarks + * The description for GlobalConstantStable in V2 stable + * + */ export const GlobalConstantStable = 8; " `; @@ -678,6 +708,7 @@ exports[`Minecraft Version Shipped Stable > Generates correct output for module /** * @preview * @packageDocumentation + * The description for the module in V2 stable * * Manifest Details * \`\`\`json @@ -690,8 +721,20 @@ exports[`Minecraft Version Shipped Stable > Generates correct output for module */ /** * @rc + * @remarks + * Test function woot woot! + * + * @param arg + * default arg description!. + * @returns + * Returns default stuff. */ export function TestFunction(arg: string): number; +/** + * @remarks + * The description for GlobalConstantStable in V2 stable + * + */ export const GlobalConstantStable = 8; " `; @@ -708,6 +751,7 @@ exports[`Minecraft Version Shipped Stable > Generates correct output for module /** * @beta * @packageDocumentation + * The description for the module in beta * * Manifest Details * \`\`\`json @@ -720,12 +764,24 @@ exports[`Minecraft Version Shipped Stable > Generates correct output for module */ /** * @rc + * @remarks + * Test function woot woot! + * + * @param arg + * default arg description!. + * @returns + * Returns default stuff. */ export function TestFunction(arg: string): number; /** * @beta */ export const GlobalConstantBeta = 8; +/** + * @remarks + * The description for GlobalConstantStable in V2 stable + * + */ export const GlobalConstantStable = 8; " `; @@ -1194,6 +1250,8 @@ exports[`Minecraft Version Shipped Stable > Generates correct output for module exports[`Minecraft Version Shipped Stable > Generates correct output for module with stable shipped version and beta in a new version in stable > npm/types/@minecraft/module@2.0.0/README.md 1`] = ` "# \`@minecraft/module\` +The description for the module in V2 stable + See full documentation for this module here: https://learn.microsoft.com/en-us/minecraft/creator/scriptapi/minecraft/module/minecraft-module" @@ -1210,6 +1268,7 @@ exports[`Minecraft Version Shipped Stable > Generates correct output for module ***************************************************************************** */ /** * @packageDocumentation + * The description for the module in V2 stable * * Manifest Details * \`\`\`json @@ -1220,7 +1279,21 @@ exports[`Minecraft Version Shipped Stable > Generates correct output for module * \`\`\` * */ +/** + * @remarks + * Test function woot woot! + * + * @param arg + * default arg description!. + * @returns + * Returns default stuff. + */ export function TestFunction(arg: string): number; +/** + * @remarks + * The description for GlobalConstantStable in V2 stable + * + */ export const GlobalConstantStable = 8; " `; @@ -1247,6 +1320,8 @@ exports[`Minecraft Version Shipped Stable > Generates correct output for module exports[`Minecraft Version Shipped Stable > Generates correct output for module with stable shipped version and beta in a new version in stable > npm/types/@minecraft/module@2.1.0-beta.1.2.3-stable/README.md 1`] = ` "# \`@minecraft/module\` +The description for the module in beta + ## **NOTE: This version of this module is still in pre-release. It may change or it may be removed in future releases.** See full documentation for this module here: @@ -1266,6 +1341,7 @@ exports[`Minecraft Version Shipped Stable > Generates correct output for module /** * @beta * @packageDocumentation + * The description for the module in beta * * Manifest Details * \`\`\`json @@ -1276,11 +1352,25 @@ exports[`Minecraft Version Shipped Stable > Generates correct output for module * \`\`\` * */ +/** + * @remarks + * Test function woot woot! + * + * @param arg + * default arg description!. + * @returns + * Returns default stuff. + */ export function TestFunction(arg: string): number; /** * @beta */ export const GlobalConstantBeta = 8; +/** + * @remarks + * The description for GlobalConstantStable in V2 stable + * + */ export const GlobalConstantStable = 8; " `; @@ -1431,6 +1521,7 @@ exports[`Minecraft Version Shipped Stable > Generates correct output for module ***************************************************************************** */ /** * @packageDocumentation + * The description for the module in V2 stable * * Manifest Details * \`\`\`json @@ -1441,7 +1532,21 @@ exports[`Minecraft Version Shipped Stable > Generates correct output for module * \`\`\` * */ +/** + * @remarks + * Test function woot woot! + * + * @param arg + * default arg description!. + * @returns + * Returns default stuff. + */ export function TestFunction(arg: string): number; +/** + * @remarks + * The description for GlobalConstantStable in V2 stable + * + */ export const GlobalConstantStable = 8; " `; @@ -1458,6 +1563,7 @@ exports[`Minecraft Version Shipped Stable > Generates correct output for module /** * @beta * @packageDocumentation + * The description for the module in beta * * Manifest Details * \`\`\`json @@ -1468,11 +1574,25 @@ exports[`Minecraft Version Shipped Stable > Generates correct output for module * \`\`\` * */ +/** + * @remarks + * Test function woot woot! + * + * @param arg + * default arg description!. + * @returns + * Returns default stuff. + */ export function TestFunction(arg: string): number; /** * @beta */ export const GlobalConstantBeta = 8; +/** + * @remarks + * The description for GlobalConstantStable in V2 stable + * + */ export const GlobalConstantStable = 8; " `; diff --git a/tools/api-docs-generator-test-snapshots/test/only_generate_latest_versions/__snapshots__/onlyGenerateLatestVersions.spec.ts.snap b/tools/api-docs-generator-test-snapshots/test/only_generate_latest_versions/__snapshots__/onlyGenerateLatestVersions.spec.ts.snap index b4778a3..26c936d 100644 --- a/tools/api-docs-generator-test-snapshots/test/only_generate_latest_versions/__snapshots__/onlyGenerateLatestVersions.spec.ts.snap +++ b/tools/api-docs-generator-test-snapshots/test/only_generate_latest_versions/__snapshots__/onlyGenerateLatestVersions.spec.ts.snap @@ -317,6 +317,7 @@ exports[`Only Generate Latest Script Module Versions > Generates correct output ***************************************************************************** */ /** * @packageDocumentation + * This should only be applied in the latest module! * * Manifest Details * \`\`\`json @@ -327,8 +328,23 @@ exports[`Only Generate Latest Script Module Versions > Generates correct output * \`\`\` * */ +/** + * @remarks + * This should only be applied in the latest module! + * + */ export const GlobalConstantV100 = 8; +/** + * @remarks + * This should only be applied in the latest module! + * + */ export const GlobalConstantV110 = 8; +/** + * @remarks + * This should only be applied in the latest module! + * + */ export const GlobalConstantV200 = 8; " `; diff --git a/tools/api-docs-generator/src/filters/CommonFilters.ts b/tools/api-docs-generator/src/filters/CommonFilters.ts index cee006b..150bd1f 100644 --- a/tools/api-docs-generator/src/filters/CommonFilters.ts +++ b/tools/api-docs-generator/src/filters/CommonFilters.ts @@ -8,7 +8,7 @@ import wrap from 'word-wrap'; import { FileLoader } from '../FileLoader'; import * as log from '../Logger'; -import { getLatestScriptModules, MinecraftRelease } from '../MinecraftRelease'; +import { getLatestScriptModules, GetLatestScriptModulesOptions, MinecraftRelease } from '../MinecraftRelease'; import { getAfterEventsOrderingModuleFrom, MinecraftAfterEventsOrderByVersion, @@ -1058,7 +1058,9 @@ function addDescriptionsAndExamples(releases: MinecraftRelease[], fileLoader?: F } for (const release of releases) { - for (const moduleJson of release.getLatestScriptModulesByMajorVersion()) { + for (const moduleJson of release.getLatestScriptModulesByMajorVersion( + GetLatestScriptModulesOptions.StableAndPrerelease + )) { const dependentModules = getLatestDependentScriptModules(release.script_modules, moduleJson); addModuleDescriptions(fileLoader, moduleJson, dependentModules);