Skip to content

Commit a97a4ac

Browse files
committed
Add support for the see tag
1 parent 91b05e6 commit a97a4ac

File tree

4 files changed

+53
-0
lines changed

4 files changed

+53
-0
lines changed

tsdoc/src/details/StandardTags.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,37 @@ export class StandardTags {
328328
standardization: Standardization.Extended
329329
});
330330

331+
/**
332+
* (Extended)
333+
*
334+
* Used to document another symbol or resource that may be related to the current item being documented.
335+
*
336+
* @remarks
337+
*
338+
* For example:
339+
*
340+
* ```ts
341+
* /**
342+
* * Both of these will link to the bar function.
343+
* * @see {@link bar}
344+
* * @see bar
345+
* */
346+
* function foo() {}
347+
348+
* // Use the inline {@link} tag to include a link within a free-form description.
349+
* /**
350+
* * @see {@link foo} for further information.
351+
* * @see {@link http://github.com|GitHub}
352+
* */
353+
* function bar() {}
354+
* ```
355+
*/
356+
public static readonly see: TSDocTagDefinition = StandardTags._defineTag({
357+
tagName: '@see',
358+
syntaxKind: TSDocTagSyntaxKind.BlockTag,
359+
standardization: Standardization.Extended
360+
});
361+
331362
/**
332363
* (Extended)
333364
*
@@ -420,6 +451,7 @@ export class StandardTags {
420451
StandardTags.remarks,
421452
StandardTags.returns,
422453
StandardTags.sealed,
454+
StandardTags.see,
423455
StandardTags.throws,
424456
StandardTags.typeParam,
425457
StandardTags.virtual

tsdoc/src/emitters/TSDocEmitter.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ export class TSDocEmitter {
130130
docComment.typeParams,
131131
docComment.returnsBlock,
132132
...docComment.customBlocks,
133+
...docComment.seeBlocks,
133134
docComment.inheritDocTag
134135
]);
135136
if (docComment.modifierTagSet.nodes.length > 0) {

tsdoc/src/nodes/DocComment.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ export class DocComment extends DocNode {
8787
*/
8888
public readonly modifierTagSet: StandardModifierTagSet;
8989

90+
private _seeBlocks: DocBlock[];
9091
private _customBlocks: DocBlock[];
9192

9293
/**
@@ -106,6 +107,7 @@ export class DocComment extends DocNode {
106107

107108
this.modifierTagSet = new StandardModifierTagSet();
108109

110+
this._seeBlocks = []
109111
this._customBlocks = [];
110112
}
111113

@@ -114,13 +116,27 @@ export class DocComment extends DocNode {
114116
return DocNodeKind.Comment;
115117
}
116118

119+
/**
120+
* The collection of all `@see` DockBlockTag nodes belonging to this doc comment.
121+
*/
122+
public get seeBlocks(): ReadonlyArray<DocBlock> {
123+
return this._seeBlocks;
124+
}
125+
117126
/**
118127
* The collection of all DocBlock nodes belonging to this doc comment.
119128
*/
120129
public get customBlocks(): ReadonlyArray<DocBlock> {
121130
return this._customBlocks;
122131
}
123132

133+
/**
134+
* Append an item to the seeBlocks collection.
135+
*/
136+
public appendSeeBlock(block: DocBlock): void {
137+
this._seeBlocks.push(block);
138+
}
139+
124140
/**
125141
* Append an item to the customBlocks collection.
126142
*/
@@ -139,6 +155,7 @@ export class DocComment extends DocNode {
139155
this.typeParams.count > 0 ? this.typeParams : undefined,
140156
this.returnsBlock,
141157
...this.customBlocks,
158+
...this.seeBlocks,
142159
this.inheritDocTag,
143160
...this.modifierTagSet.nodes
144161
];

tsdoc/src/parser/NodeParser.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,9 @@ export class NodeParser {
329329
case StandardTags.returns.tagNameWithUpperCase:
330330
docComment.returnsBlock = block;
331331
break;
332+
case StandardTags.see.tagNameWithUpperCase:
333+
docComment.appendSeeBlock(block);
334+
break;
332335
default:
333336
docComment.appendCustomBlock(block);
334337
}

0 commit comments

Comments
 (0)