From 1803f5f0f9c5b5b1067e53ed13206e0aa20d2bc4 Mon Sep 17 00:00:00 2001 From: Praven Kuttappan <55455725+praveenkuttappan@users.noreply.github.com> Date: Wed, 1 Feb 2023 09:36:23 -0500 Subject: [PATCH] Create API review for JS packages with namespace in api extractor model (#5292) --- tools/apiview/parsers/js-api-parser/export.ts | 7 ++++++- tools/apiview/parsers/js-api-parser/package.json | 2 +- tools/apiview/parsers/js-api-parser/tokensBuilder.ts | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/tools/apiview/parsers/js-api-parser/export.ts b/tools/apiview/parsers/js-api-parser/export.ts index c4d5c161614..fc41f9c290e 100644 --- a/tools/apiview/parsers/js-api-parser/export.ts +++ b/tools/apiview/parsers/js-api-parser/export.ts @@ -16,6 +16,9 @@ function appendMembers(builder: TokensBuilder, navigation: IApiViewNavItem[], it builder.lineId(item.canonicalReference.toString()); builder.indent(); if (item instanceof ApiDeclaredItem) { + if ( item.kind === ApiItemKind.Namespace) { + builder.splitAppend(`declare namespace ${item.displayName} `, item.canonicalReference.toString(), item.displayName); + } for (const token of item.excerptTokens) { if (token.kind === ExcerptTokenKind.Reference) { @@ -35,6 +38,7 @@ function appendMembers(builder: TokensBuilder, navigation: IApiViewNavItem[], it { case ApiItemKind.Interface: case ApiItemKind.Class: + case ApiItemKind.Namespace: typeKind = item.kind.toLowerCase(); break case ApiItemKind.TypeAlias: @@ -56,7 +60,8 @@ function appendMembers(builder: TokensBuilder, navigation: IApiViewNavItem[], it } if (item.kind === ApiItemKind.Interface || - item.kind === ApiItemKind.Class) + item.kind === ApiItemKind.Class || + item.kind === ApiItemKind.Namespace) { if (item.members.length > 0) { diff --git a/tools/apiview/parsers/js-api-parser/package.json b/tools/apiview/parsers/js-api-parser/package.json index ac224a723e3..6b21bf4748d 100644 --- a/tools/apiview/parsers/js-api-parser/package.json +++ b/tools/apiview/parsers/js-api-parser/package.json @@ -1,6 +1,6 @@ { "name": "@azure-tools/ts-genapi", - "version": "1.0.3", + "version": "1.0.4", "description": "", "main": "index.js", "publishConfig": { diff --git a/tools/apiview/parsers/js-api-parser/tokensBuilder.ts b/tools/apiview/parsers/js-api-parser/tokensBuilder.ts index 79cde402f63..16de467e4a7 100644 --- a/tools/apiview/parsers/js-api-parser/tokensBuilder.ts +++ b/tools/apiview/parsers/js-api-parser/tokensBuilder.ts @@ -30,6 +30,7 @@ export class TokensBuilder "import", "in", "instanceof", + "namespace", "new", "null", "return",