Skip to content

Commit

Permalink
Add @author to the default list of supported tags
Browse files Browse the repository at this point in the history
Resolves #2603
  • Loading branch information
Gerrit0 committed Jun 22, 2024
1 parent 9ef5030 commit 0804330
Show file tree
Hide file tree
Showing 6 changed files with 108 additions and 13 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Unreleased

### Features

- Improved Korean translation coverage, #2602

### Bug Fixes

- Added `@author` to the default list of recognized tags, #2603.

### Thanks!

- @KNU-K

# v0.26.0 (2024-06-22)

### Breaking Changes
Expand Down
23 changes: 11 additions & 12 deletions src/lib/utils/options/tsdoc-defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,26 @@ export const tsdocBlockTags = [

export const blockTags = [
...tsdocBlockTags,
"@author",
"@callback",
"@category",
"@categoryDescription",
"@default",
"@document",
"@group",
"@groupDescription",
"@import",
"@inheritDoc",
"@jsx",
"@license",
"@module",
"@return",
// Alias for @typeParam
"@template",
// Because TypeScript is important!
"@type",
"@typedef",
"@callback",
"@prop",
"@property",
"@return",
"@satisfies",
"@import",
"@jsx",
"@template", // Alias for @typeParam
"@type", // Because TypeScript is important!
"@typedef",
] as const;

export const tsdocInlineTags = ["@link", "@inheritDoc", "@label"] as const;
Expand All @@ -53,8 +52,6 @@ export const tsdocModifierTags = [
"@internal",
"@override",
"@packageDocumentation",
"@private",
"@protected",
"@public",
"@readonly",
"@sealed",
Expand All @@ -68,12 +65,14 @@ export const modifierTags = [
"@event",
"@hidden",
"@hideCategories",
"@hideconstructor",
"@hideGroups",
"@ignore",
"@interface",
"@namespace",
"@overload",
"@private",
"@protected",
"@showCategories",
"@showGroups",
"@hideconstructor",
] as const;
4 changes: 4 additions & 0 deletions src/test/converter2/issues/gh2603.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/**
* @author Ian Awesome
*/
export const x = 1;
11 changes: 11 additions & 0 deletions src/test/issues.c2.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1578,4 +1578,15 @@ describe("Issue Tests", () => {
"Shorthand comment",
);
});

it("#2603 handles @author tag", () => {
const project = convert();
const x = query(project, "x");
equal(
x.comment?.getTag("@author"),
new CommentTag("@author", [{ kind: "text", text: "Ian Awesome" }]),
);

logger.expectNoOtherMessages();
});
});
61 changes: 61 additions & 0 deletions src/test/utils/options/tsdoc-defaults.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { deepEqual as equal } from "assert/strict";
import { join } from "path";
import ts from "typescript";
import * as defaults from "../../../lib/utils/options/tsdoc-defaults";

describe("tsdoc-defaults.ts", () => {
const tsdoc = ts.readConfigFile(
join(__dirname, "../../../../tsdoc.json"),
ts.sys.readFile,
);
const tagDefinitions = tsdoc.config?.tagDefinitions as Array<{
tagName: string;
syntaxKind: "block" | "modifier" | "inline";
}>;

function tagsByKind(kind: "block" | "modifier" | "inline") {
return tagDefinitions
.filter((t) => t.syntaxKind === kind)
.map((t) => t.tagName)
.sort((a, b) => a.localeCompare(b));
}

before(() => {
equal(tsdoc.error, undefined);
});

it("Should expose the same block tags as the tsdoc.json file", () => {
const tsdocTags = tagsByKind("block");

const typedocTags = defaults.blockTags
.filter((t) => !defaults.tsdocBlockTags.includes(t as never))
.sort((a, b) => a.localeCompare(b));

// @inheritDoc is a special case. We can't specify it in the tsdoc.json
// or the official parser blows up, because it thinks that it is only
// an inline tag.
typedocTags.splice(typedocTags.indexOf("@inheritDoc"), 1);

equal(tsdocTags, typedocTags);
});

it("Should expose the same modifier tags as the tsdoc.json file", () => {
const tsdocTags = tagsByKind("modifier");

const typedocTags = defaults.modifierTags
.filter((t) => !defaults.tsdocModifierTags.includes(t as never))
.sort((a, b) => a.localeCompare(b));

equal(tsdocTags, typedocTags);
});

it("Should expose the same inline tags as the tsdoc.json file", () => {
const tsdocTags = tagsByKind("inline");

const typedocTags = defaults.inlineTags
.filter((t) => !defaults.tsdocInlineTags.includes(t as never))
.sort((a, b) => a.localeCompare(b));

equal(tsdocTags, typedocTags);
});
});
10 changes: 9 additions & 1 deletion tsdoc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,18 @@
// If updating this, also update tsdoc-defaults.ts
"noStandardTags": false,
"tagDefinitions": [
{
"tagName": "@author",
"syntaxKind": "block"
},
{
"tagName": "@module",
"syntaxKind": "block"
},
{
"tagName": "@type",
"syntaxKind": "block"
},
{
"tagName": "@typedef",
"syntaxKind": "block"
Expand Down Expand Up @@ -92,7 +100,7 @@
},
{
"tagName": "@linkplain",
"syntaxKind": "block",
"syntaxKind": "inline",
"allowMultiple": true
},
{
Expand Down

0 comments on commit 0804330

Please sign in to comment.