Skip to content

Commit 3e8d95a

Browse files
committed
Promote ExtractorMessage and ExtractorMessageId to be public API and add docs
1 parent b03d49b commit 3e8d95a

7 files changed

Lines changed: 102 additions & 9 deletions

File tree

‎apps/api-extractor/src/aedoc/PackageDocComment.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import * as ts from 'typescript';
55
import { Collector } from '../collector/Collector';
6-
import { ExtractorMessageId } from '../collector/ExtractorMessageId';
6+
import { ExtractorMessageId } from '../api/ExtractorMessageId';
77

88
export class PackageDocComment {
99
/**

‎apps/api-extractor/src/api/ExtractorMessage.ts‎

Lines changed: 58 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,42 @@
44
import * as tsdoc from '@microsoft/tsdoc';
55
import { ExtractorMessageId } from './ExtractorMessageId';
66

7+
/**
8+
* Specifies a category of messages for use with {@link ExtractorMessage}.
9+
* @public
10+
*/
711
export const enum ExtractorMessageCategory {
8-
Compiler,
9-
TSDoc,
10-
Extractor
12+
/**
13+
* Messages originating from the TypeScript compiler.
14+
*
15+
* @remarks
16+
* These strings begin with the prefix "TS" and have a numeric error code.
17+
* Example: `TS2551`
18+
*/
19+
Compiler = 'Compiler',
20+
21+
/**
22+
* Messages related to parsing of TSDoc comments.
23+
*
24+
* @remarks
25+
* These strings begin with the prefix "tsdoc-".
26+
* Example: `tsdoc-link-tag-unescaped-text`
27+
*/
28+
TSDoc = 'TSDoc',
29+
30+
/**
31+
* Messages related to API Extractor's analysis.
32+
*
33+
* @remarks
34+
* These strings begin with the prefix "ae-".
35+
* Example: `ae-extra-release-tag`
36+
*/
37+
Extractor = 'Extractor'
1138
}
1239

40+
/**
41+
* Constructor options for `ExtractorMessage`.
42+
*/
1343
export interface IExtractorMessageOptions {
1444
category: ExtractorMessageCategory;
1545
messageId: tsdoc.TSDocMessageId | ExtractorMessageId | string;
@@ -20,21 +50,45 @@ export interface IExtractorMessageOptions {
2050
}
2151

2252
/**
23-
* Represents an error or warning that occurred during parsing.
53+
* This object is used to report an error or warning that occurred during API Extractor's analysis.
54+
*
55+
* @public
2456
*/
2557
export class ExtractorMessage {
58+
/**
59+
* The category of issue.
60+
*/
2661
public readonly category: ExtractorMessageCategory;
2762

63+
/**
64+
* A text string that uniquely identifies the issue type. This identifier can be used to suppress
65+
* or configure the reporting of issues, and also to search for help about an issue.
66+
*/
2867
public readonly messageId: tsdoc.TSDocMessageId | ExtractorMessageId | string;
2968

69+
/**
70+
* The text description of this issue.
71+
*/
3072
public readonly text: string;
3173

74+
/**
75+
* The absolute path to the affected input source file, if there is one.
76+
*/
3277
public readonly sourceFilePath: string | undefined;
3378

79+
/**
80+
* The line number where the issue occurred in the input source file. This is not used if `sourceFilePath`
81+
* is undefined.
82+
*/
3483
public readonly sourceFileLine: number | undefined;
3584

85+
/**
86+
* The column number where the issue occurred in the input source file. This is not used if `sourceFilePath`
87+
* is undefined.
88+
*/
3689
public readonly sourceFileColumn: number | undefined;
3790

91+
/** @internal */
3892
public constructor(options: IExtractorMessageOptions) {
3993
this.category = options.category;
4094
this.messageId = options.messageId;

‎apps/api-extractor/src/api/ExtractorMessageId.ts‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
22
// See LICENSE in the project root for license information.
33

4+
/**
5+
* Unique identifiers for messages reported by API Extractor during its analysis.
6+
*
7+
* @remarks
8+
*
9+
* These strings are possible values for the {@link ExtractorMessage.messageId} property
10+
* when the `ExtractorMessage.category` is {@link ExtractorMessageCategory.Extractor}.
11+
*
12+
* @public
13+
*/
414
export const enum ExtractorMessageId {
515
/**
616
* The doc comment should not contain more than one release tag.

‎apps/api-extractor/src/collector/Collector.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
IExtractorValidationRulesConfig,
1717
ExtractorValidationRulePolicy
1818
} from '../api/IExtractorConfig';
19+
import { ExtractorMessageId } from '../api/ExtractorMessageId';
1920

2021
import { CollectorEntity } from './CollectorEntity';
2122
import { AstSymbolTable, AstEntity } from '../analyzer/AstSymbolTable';
@@ -30,7 +31,6 @@ import { DeclarationMetadata } from './DeclarationMetadata';
3031
import { SymbolMetadata } from './SymbolMetadata';
3132
import { TypeScriptInternals } from '../analyzer/TypeScriptInternals';
3233
import { MessageRouter } from './MessageRouter';
33-
import { ExtractorMessageId } from './ExtractorMessageId';
3434

3535
/**
3636
* Options for Collector constructor.

‎apps/api-extractor/src/collector/MessageRouter.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ import * as tsdoc from '@microsoft/tsdoc';
66

77
import { TypeScriptMessageFormatter } from '../analyzer/TypeScriptMessageFormatter';
88
import { AstDeclaration } from '../analyzer/AstDeclaration';
9+
import { AstSymbol } from '../analyzer/AstSymbol';
910
import {
1011
ExtractorMessage,
1112
ExtractorMessageCategory,
1213
IExtractorMessageOptions
13-
} from './ExtractorMessage';
14-
import { AstSymbol } from '../analyzer/AstSymbol';
15-
import { ExtractorMessageId } from './ExtractorMessageId';
14+
} from '../api/ExtractorMessage';
15+
import { ExtractorMessageId } from '../api/ExtractorMessageId';
1616

1717
export class MessageRouter {
1818
private _messages: ExtractorMessage[];

‎apps/api-extractor/src/index.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
export { ReleaseTag } from './aedoc/ReleaseTag';
1313

1414
export { Extractor, IAnalyzeProjectOptions, IExtractorOptions } from './api/Extractor';
15+
export { ExtractorMessage, ExtractorMessageCategory } from './api/ExtractorMessage';
16+
export { ExtractorMessageId } from './api/ExtractorMessageId';
1517
export {
1618
IExtractorTsconfigCompilerConfig,
1719
IExtractorRuntimeCompilerConfig,

‎common/reviews/api/api-extractor.api.ts‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,33 @@ declare class Extractor {
503503
static readonly version: string;
504504
}
505505

506+
// @public
507+
declare class ExtractorMessage {
508+
// @internal (undocumented)
509+
constructor(options: IExtractorMessageOptions);
510+
readonly category: ExtractorMessageCategory;
511+
readonly messageId: tsdoc.TSDocMessageId | ExtractorMessageId | string;
512+
readonly sourceFileColumn: number | undefined;
513+
readonly sourceFileLine: number | undefined;
514+
readonly sourceFilePath: string | undefined;
515+
readonly text: string;
516+
}
517+
518+
// @public
519+
declare const enum ExtractorMessageCategory {
520+
Compiler = "Compiler",
521+
Extractor = "Extractor",
522+
TSDoc = "TSDoc"
523+
}
524+
525+
// @public
526+
declare const enum ExtractorMessageId {
527+
ExtraReleaseTag = "ae-extra-release-tag",
528+
InconsistentReleaseTags = "ae-inconsistent-release-tags",
529+
MisplacedPackageTag = "ae-misplaced-package-tag",
530+
MissingReleaseTag = "ae-missing-release-tag"
531+
}
532+
506533
// @public
507534
declare const enum ExtractorValidationRulePolicy {
508535
allow = "allow",

0 commit comments

Comments
 (0)