From 1ec446198d67a4e3912588947f823dd4f01c0afe Mon Sep 17 00:00:00 2001 From: Gerrit Birkeland Date: Fri, 6 Sep 2024 09:30:05 -0600 Subject: [PATCH] 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); + }); });