From 37e7aa93e5486933cf7eae41bef5823544d2dcf1 Mon Sep 17 00:00:00 2001 From: waynemwashuma <94756970+waynemwashuma@users.noreply.github.com> Date: Thu, 29 Aug 2024 21:48:07 +0300 Subject: [PATCH 1/2] Added support for `@abstract` tag --- src/lib/utils/options/tsdoc-defaults.ts | 1 + tsdoc.json | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/src/lib/utils/options/tsdoc-defaults.ts b/src/lib/utils/options/tsdoc-defaults.ts index 20e5b6023..e21287fda 100644 --- a/src/lib/utils/options/tsdoc-defaults.ts +++ b/src/lib/utils/options/tsdoc-defaults.ts @@ -64,6 +64,7 @@ export const tsdocModifierTags = [ export const modifierTags = [ ...tsdocModifierTags, + "@abstract", "@class", "@enum", "@event", diff --git a/tsdoc.json b/tsdoc.json index de289180b..d652cd741 100644 --- a/tsdoc.json +++ b/tsdoc.json @@ -67,6 +67,10 @@ "tagName": "@class", "syntaxKind": "modifier" }, + { + "tagName": "@abstract", + "syntaxKind": "modifier" + }, { "tagName": "@document", "syntaxKind": "block" From 1ec446198d67a4e3912588947f823dd4f01c0afe Mon Sep 17 00:00:00 2001 From: Gerrit Birkeland Date: Fri, 6 Sep 2024 09:30:05 -0600 Subject: [PATCH 2/2] Fully support `@abstract` tag --- CHANGELOG.md | 1 + src/lib/converter/plugins/CommentPlugin.ts | 9 +++++++++ src/test/converter2/issues/gh2693.ts | 14 ++++++++++++++ src/test/issues.c2.test.ts | 11 +++++++++++ 4 files changed, 35 insertions(+) create mode 100644 src/test/converter2/issues/gh2693.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index af3ce7a1e..e23474e58 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - Added `markdownLinkExternal` option to treat `http[s]://` links in markdown documents and comments as external to be opened in a new tab, #2679. - Added `navigation.excludeReferences` option to prevent re-exports from appearing in the left hand navigation, #2685. +- Added support for the `@abstract` tag, #2692. ### Bug Fixes diff --git a/src/lib/converter/plugins/CommentPlugin.ts b/src/lib/converter/plugins/CommentPlugin.ts index f75b19f53..c41fc71a2 100644 --- a/src/lib/converter/plugins/CommentPlugin.ts +++ b/src/lib/converter/plugins/CommentPlugin.ts @@ -192,6 +192,15 @@ export class CommentPlugin extends ConverterComponent { comment.removeModifier("@interface"); } + if (comment.hasModifier("@abstract")) { + if (reflection.kindOf(ReflectionKind.SomeSignature)) { + reflection.parent!.setFlag(ReflectionFlag.Abstract); + } else { + reflection.setFlag(ReflectionFlag.Abstract); + } + comment.removeModifier("@abstract"); + } + if (comment.hasModifier("@private")) { reflection.setFlag(ReflectionFlag.Private); if (reflection.kindOf(ReflectionKind.CallSignature)) { diff --git a/src/test/converter2/issues/gh2693.ts b/src/test/converter2/issues/gh2693.ts new file mode 100644 index 000000000..535a92bc4 --- /dev/null +++ b/src/test/converter2/issues/gh2693.ts @@ -0,0 +1,14 @@ +export abstract class Foo { + abstract foo(): void; + + abstract x: number; +} + +/** @abstract */ +export class Bar { + /** @abstract */ + foo() {} + + /** @abstract */ + x!: number; +} diff --git a/src/test/issues.c2.test.ts b/src/test/issues.c2.test.ts index 303cb35c2..fc58cfa63 100644 --- a/src/test/issues.c2.test.ts +++ b/src/test/issues.c2.test.ts @@ -1707,4 +1707,15 @@ describe("Issue Tests", () => { // had a chance to copy the data's @param to the parameter. equal(data2.comment, undefined); }); + + it("#2693 handles the @abstract tag", () => { + const project = convert(); + ok(query(project, "Foo.foo").flags.isAbstract); + ok(!querySig(project, "Foo.foo").flags.isAbstract); + ok(query(project, "Foo.x").flags.isAbstract); + + ok(query(project, "Bar.foo").flags.isAbstract); + ok(!querySig(project, "Bar.foo").flags.isAbstract); + ok(query(project, "Bar.x").flags.isAbstract); + }); });