From 2dd0490f53cac73f8651bff0ac259fcfc8b980bc Mon Sep 17 00:00:00 2001 From: Mohamed Shams El-Deen Date: Sat, 30 May 2026 15:16:26 +0300 Subject: [PATCH 1/3] fix(queries): allow complex types in type linking regex --- src/utils/queries/index.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils/queries/index.mjs b/src/utils/queries/index.mjs index cd120347..bdf94cfb 100644 --- a/src/utils/queries/index.mjs +++ b/src/utils/queries/index.mjs @@ -8,10 +8,10 @@ export const QUERIES = { // Fixes the references to Markdown pages into the API documentation markdownUrl: /^(?![+a-zA-Z]+:)([^#?]+)\.md(#.+)?$/, // ReGeX to match the {Type} (API type references) - normalizeTypes: /(\{|<)(?! )[^<({})>]+(?! )(\}|>)/g, + normalizeTypes: /(\{|<)(?! )[^{}]+(?! )(\}|>)/g, // ReGex to match the type API type references that got already parsed // so that they can be transformed into HTML links - linksWithTypes: /\[`<[^<({})>]+>`\]\((\S+)\)/g, + linksWithTypes: /\[`<[^{}]+>`\]\((\S+)\)/g, // ReGeX for handling Stability Indexes Metadata stabilityIndex: /^Stability: ([0-5](?:\.[0-3])?)(?:\s*-\s*)?(.*)$/s, // ReGeX for handling the Stability Index Prefix From 503aefec143b90eaec65bf1141b3c70856883eba Mon Sep 17 00:00:00 2001 From: Mohamed Shams El-Deen Date: Sat, 30 May 2026 17:11:19 +0300 Subject: [PATCH 2/3] 1.3.7 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 874289b3..1bbbcc0a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@node-core/doc-kit", - "version": "1.3.6", + "version": "1.3.7", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@node-core/doc-kit", - "version": "1.3.6", + "version": "1.3.7", "dependencies": { "@actions/core": "^3.0.0", "@heroicons/react": "^2.2.0", diff --git a/package.json b/package.json index 031fca48..912416d1 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@node-core/doc-kit", "type": "module", - "version": "1.3.6", + "version": "1.3.7", "repository": { "type": "git", "url": "git+https://github.com/nodejs/doc-kit.git" From 0179459f96a67975fd14ed5bfee93f3425914ccd Mon Sep 17 00:00:00 2001 From: Mohamed Shams El-Deen Date: Sun, 31 May 2026 11:06:33 +0300 Subject: [PATCH 3/3] test(queries): add tests for complex types Added test coverage for normalizeTypes and linksWithTypes to ensure complex JSDoc types (generics, unions) are matched correctly. --- src/utils/queries/__tests__/index.test.mjs | 55 ++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/src/utils/queries/__tests__/index.test.mjs b/src/utils/queries/__tests__/index.test.mjs index 4bf4a840..992c9162 100644 --- a/src/utils/queries/__tests__/index.test.mjs +++ b/src/utils/queries/__tests__/index.test.mjs @@ -33,6 +33,61 @@ describe('QUERIES', () => { strictEqual(QUERIES.standardYamlFrontmatter.test(content), false); }); }); + + describe('normalizeTypes', () => { + it('matches basic types', () => { + const content = '{string}'; + QUERIES.normalizeTypes.lastIndex = 0; + ok(QUERIES.normalizeTypes.test(content)); + }); + + it('matches complex types with generics', () => { + const content1 = '{Readonly}'; + const content2 = '{Map}'; + + QUERIES.normalizeTypes.lastIndex = 0; + ok( + QUERIES.normalizeTypes.test(content1), + 'Should match Readonly' + ); + QUERIES.normalizeTypes.lastIndex = 0; + ok(QUERIES.normalizeTypes.test(content2), 'Should match Map<...>'); + }); + + it('matches complex union types with parentheses', () => { + const content = '{(string|number)}'; + QUERIES.normalizeTypes.lastIndex = 0; + ok( + QUERIES.normalizeTypes.test(content), + 'Should match union with parentheses' + ); + }); + }); + + describe('linksWithTypes', () => { + it('matches basic type links', () => { + const content = '[``](https://mdn...)'; + QUERIES.linksWithTypes.lastIndex = 0; + ok(QUERIES.linksWithTypes.test(content)); + }); + + it('matches complex type links with generics', () => { + const content1 = + '[``](https://mdn...)<[``](https://mdn...)>'; + QUERIES.linksWithTypes.lastIndex = 0; + ok( + QUERIES.linksWithTypes.test(content1), + 'Should match generic type link' + ); + }); + + it('matches complex type links with unions', () => { + const content2 = + '<([``](https://mdn...)|[``](https://mdn...))>'; + QUERIES.linksWithTypes.lastIndex = 0; + ok(QUERIES.linksWithTypes.test(content2), 'Should match union type link'); + }); + }); }); describe('UNIST', () => {