Skip to content

Commit 9671ec3

Browse files
committed
Add new API TSDocConfiguration.allTsdocMessageIds
1 parent 4f8bd5e commit 9671ec3

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

tsdoc/src/configuration/TSDocConfiguration.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { TSDocTagDefinition } from './TSDocTagDefinition';
33
import { TSDocValidationConfiguration } from './TSDocValidationConfiguration';
44
import { DocNodeManager } from './DocNodeManager';
55
import { BuiltInDocNodes } from '../nodes/BuiltInDocNodes';
6-
import { TSDocMessageId, allTsdocMessageIds } from '../parser/TSDocMessageId';
6+
import { TSDocMessageId, allTsdocMessageIds, allTsdocMessageIdsSet } from '../parser/TSDocMessageId';
77

88
/**
99
* Configuration for the TSDocParser.
@@ -170,7 +170,19 @@ export class TSDocConfiguration {
170170
* of the TSDoc parser, we may provide a way to register custom message identifiers.
171171
*/
172172
public isKnownMessageId(messageId: TSDocMessageId | string): boolean {
173-
return allTsdocMessageIds.has(messageId);
173+
return allTsdocMessageIdsSet.has(messageId);
174+
}
175+
176+
/**
177+
* Returns the list of {@link TSDocMessageId} strings that are implemented by this release of the TSDoc parser.
178+
*
179+
* @privateRemarks
180+
*
181+
* Why this API is associated with TSDocConfiguration: In the future, if we enable support for custom extensions
182+
* of the TSDoc parser, we may provide a way to register custom message identifiers.
183+
*/
184+
public get allTsdocMessageIds(): ReadonlyArray<TSDocMessageId> {
185+
return allTsdocMessageIds as ReadonlyArray<TSDocMessageId>;
174186
}
175187

176188
private _requireTagToBeDefined(tagDefinition: TSDocTagDefinition): void {

tsdoc/src/parser/TSDocMessageId.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -336,8 +336,8 @@ export const enum TSDocMessageId {
336336
CodeSpanMissingDelimiter = 'tsdoc-code-span-missing-delimiter'
337337
}
338338

339-
// Exposed via ParserMessage.isValidMessageId()
340-
export const allTsdocMessageIds: Set<string> = new Set<string>([
339+
// Exposed via TSDocConfiguration.allTsdocMessageIds()
340+
export const allTsdocMessageIds: string[] = [
341341
'tsdoc-comment-not-found',
342342
'tsdoc-comment-missing-opening-delimiter',
343343
'tsdoc-comment-missing-closing-delimiter',
@@ -398,4 +398,7 @@ export const allTsdocMessageIds: Set<string> = new Set<string>([
398398
'tsdoc-code-fence-closing-syntax',
399399
'tsdoc-code-span-empty',
400400
'tsdoc-code-span-missing-delimiter'
401-
]);
401+
];
402+
allTsdocMessageIds.sort();
403+
404+
export const allTsdocMessageIdsSet: ReadonlySet<string> = new Set<string>(allTsdocMessageIds);

0 commit comments

Comments
 (0)