diff --git a/src/api-gen/to-proxy-source.ts b/src/api-gen/to-proxy-source.ts index 2f44c88..166d673 100644 --- a/src/api-gen/to-proxy-source.ts +++ b/src/api-gen/to-proxy-source.ts @@ -8,7 +8,7 @@ const LICENSE_HEADER = /^\/\/ Copyright Amazon\.com[^\n]*\r?\n\/\/ SPDX-License- export function toProxySource(project: ts.Project, emittedPath: string, sourceStr: string): ts.SourceFile { const source = project.createSourceFile(`out/${emittedPath}`, stripLicenseHeader(sourceStr)); exportAmbientNamespaces(source); - stripAwsuiSystemTags(source); + stripUpstreamTags(source); return source; } @@ -47,11 +47,13 @@ function exportAmbientNamespaces(source: ts.SourceFile): void { } } -/** Removes `@awsuiSystem` annotations, whatever system they name, keeping any api-docs they sit beside. */ -function stripAwsuiSystemTags(source: ts.SourceFile): void { +const TAGS_TO_REMOVE = ['awsuiSystem', 'visualrefresh', 'displayname']; + +/** Removes the annotations above, keeping any api-docs they sit beside. */ +function stripUpstreamTags(source: ts.SourceFile): void { for (const jsDoc of source.getDescendantsOfKind(ts.SyntaxKind.JSDoc)) { for (const tag of jsDoc.getTags()) { - if (tag.getTagName() === 'awsuiSystem') { + if (TAGS_TO_REMOVE.includes(tag.getTagName())) { tag.remove(); } } diff --git a/test/api-gen/to-proxy-source.test.ts b/test/api-gen/to-proxy-source.test.ts index d57db28..1cc6894 100644 --- a/test/api-gen/to-proxy-source.test.ts +++ b/test/api-gen/to-proxy-source.test.ts @@ -36,7 +36,7 @@ describe('strips license header', () => { }); }); -describe('strips system tags', () => { +describe('strips upstream tags', () => { const inline = (input: string) => input.replace(/[ \t\n]+/g, ' '); test('leaves a comment without annotations untouched', () => { @@ -56,10 +56,34 @@ describe('strips system tags', () => { }); }); + test('drops every upstream annotation, keeping the ones a consumer documents from', () => { + expect( + inline( + transform(`/** + * API docs + * @awsuiSystem core + * @visualrefresh \`awsui-h1-sticky\` variant + * @displayname title + * @deprecated Use something else. + * @default 'h2' + * @i18n + * @analytics + */ + export type X = Y;`), + ).trim(), + ).toBe( + "/** * API docs * @deprecated Use something else. * @default 'h2' * @i18n * @analytics */ export type X = Y;", + ); + }); + test('drops a comment that holds nothing but the annotation', () => { [ `/** @awsuiSystem core */ export type X = Y; `, + `/** @visualrefresh \`awsui-h1-sticky\` variant */ + export type X = Y; `, + `/** @displayname title */ + export type X = Y; `, `/** * @awsuiSystem experimental */