Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for @since and @version tags #375

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@microsoft/tsdoc-config",
"comment": "Adding support for `@since` and `@version` tags",
"type": "minor"
}
],
"packageName": "@microsoft/tsdoc-config"
}
10 changes: 10 additions & 0 deletions common/changes/@microsoft/tsdoc/main_2024-04-10-09-34.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@microsoft/tsdoc",
"comment": "Adding support for `@since` and `@version` tags",
"type": "minor"
}
],
"packageName": "@microsoft/tsdoc"
}
16 changes: 16 additions & 0 deletions tsdoc-config/src/__tests__/TSDocConfigFile.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,10 @@ test('Re-serialize p3 with defaults', () => {
"syntaxKind": "block",
"tagName": "@see",
},
Object {
"syntaxKind": "block",
"tagName": "@since",
},
Object {
"allowMultiple": true,
"syntaxKind": "block",
Expand All @@ -409,6 +413,10 @@ test('Re-serialize p3 with defaults', () => {
"syntaxKind": "block",
"tagName": "@typeParam",
},
Object {
"syntaxKind": "block",
"tagName": "@version",
},
Object {
"syntaxKind": "modifier",
"tagName": "@virtual",
Expand Down Expand Up @@ -527,6 +535,10 @@ test('Re-serialize p3 with defaults', () => {
"syntaxKind": "block",
"tagName": "@see",
},
Object {
"syntaxKind": "block",
"tagName": "@since",
},
Object {
"allowMultiple": true,
"syntaxKind": "block",
Expand All @@ -537,6 +549,10 @@ test('Re-serialize p3 with defaults', () => {
"syntaxKind": "block",
"tagName": "@typeParam",
},
Object {
"syntaxKind": "block",
"tagName": "@version",
},
Object {
"syntaxKind": "modifier",
"tagName": "@virtual",
Expand Down
2 changes: 2 additions & 0 deletions tsdoc/etc/tsdoc.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1150,8 +1150,10 @@ export class StandardTags {
static readonly returns: TSDocTagDefinition;
static readonly sealed: TSDocTagDefinition;
static readonly see: TSDocTagDefinition;
static readonly since: TSDocTagDefinition;
static readonly throws: TSDocTagDefinition;
static readonly typeParam: TSDocTagDefinition;
static readonly version: TSDocTagDefinition;
static readonly virtual: TSDocTagDefinition;
}

Expand Down
56 changes: 56 additions & 0 deletions tsdoc/src/details/StandardTags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,33 @@ export class StandardTags {
standardization: Standardization.Extended
});

/**
* (Extended)
*
* Used to document the version number of the API on which the item was created.
*
* @remarks
*
* Even if this tag is a block, it can contain as much text as you want, however it is recommended to use only the version number.
*
* For example:
* ```ts
* /**
* * Fetches a book by its ISBN code.
* * @since 1.0.0
* */
* function fetchBookByIsbn(isbnCode: string): Book;
* ```
*
* This function has been created on version 1.0.0. This tag must not be changed in the future, even if the function is updated.
* In this case the `@version` tag should be used/updated instead.
*/
public static readonly since: TSDocTagDefinition = StandardTags._defineTag({
tagName: '@since',
syntaxKind: TSDocTagSyntaxKind.BlockTag,
standardization: Standardization.Extended
});

/**
* (Extended)
*
Expand Down Expand Up @@ -467,6 +494,33 @@ export class StandardTags {
standardization: Standardization.Core
});

/**
* (Extended)
*
* Used to document the version number of the API item.
*
* @remarks
*
* Even if this tag is a block, it can contain as much text as you want, however it is recommended to use only the version number.
*
* For example:
* ```ts
* /**
* * Fetches a book by its ISBN code.
* * @version 1.0.0
* */
* function fetchBookByIsbn(isbnCode: string): Book;
* ```
*
* This function version is currently 1.0.0. This tag must be updated every time the function is updated.
* If you want to document the version of the API on which the item was created, the `@since` tag should be used instead.
*/
public static readonly version: TSDocTagDefinition = StandardTags._defineTag({
tagName: '@version',
syntaxKind: TSDocTagSyntaxKind.BlockTag,
standardization: Standardization.Extended
});

/**
* (Extended)
*
Expand Down Expand Up @@ -510,8 +564,10 @@ export class StandardTags {
StandardTags.returns,
StandardTags.sealed,
StandardTags.see,
StandardTags.since,
StandardTags.throws,
StandardTags.typeParam,
StandardTags.version,
StandardTags.virtual
];

Expand Down