Skip to content

Commit

Permalink
Fully support @abstract tag
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerrit0 committed Sep 6, 2024
1 parent 37e7aa9 commit 1ec4461
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 9 additions & 0 deletions src/lib/converter/plugins/CommentPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
14 changes: 14 additions & 0 deletions src/test/converter2/issues/gh2693.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export abstract class Foo {
abstract foo(): void;

abstract x: number;
}

/** @abstract */
export class Bar {
/** @abstract */
foo() {}

/** @abstract */
x!: number;
}
11 changes: 11 additions & 0 deletions src/test/issues.c2.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});

0 comments on commit 1ec4461

Please sign in to comment.