Skip to content

Commit aa04bcc

Browse files
authored
Merge pull request #4370 from microsoft/octogonz/ae-undocumented
[api-extractor] Add a new message "ae-undocumented"
2 parents 9ce7570 + d447e7e commit aa04bcc

File tree

9 files changed

+94
-53
lines changed

9 files changed

+94
-53
lines changed

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

+20
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,25 @@ export const enum ExtractorMessageId {
1717
*/
1818
ExtraReleaseTag = 'ae-extra-release-tag',
1919

20+
/**
21+
* "Missing documentation for ___."
22+
* @remarks
23+
* The `ae-undocumented` message is only generated if the API report feature is enabled.
24+
*
25+
* Because the API report file already annotates undocumented items with `// (undocumented)`,
26+
* the `ae-undocumented` message is not logged by default. To see it, add a setting such as:
27+
* ```json
28+
* "messages": {
29+
* "extractorMessageReporting": {
30+
* "ae-undocumented": {
31+
* "logLevel": "warning"
32+
* }
33+
* }
34+
* }
35+
* ```
36+
*/
37+
Undocumented = 'ae-undocumented',
38+
2039
/**
2140
* "This symbol has another declaration with a different release tag."
2241
*/
@@ -106,6 +125,7 @@ export const enum ExtractorMessageId {
106125

107126
export const allExtractorMessageIds: Set<string> = new Set<string>([
108127
'ae-extra-release-tag',
128+
'ae-undocumented',
109129
'ae-different-release-tags',
110130
'ae-incompatible-release-tags',
111131
'ae-missing-release-tag',

apps/api-extractor/src/collector/ApiItemMetadata.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export class ApiItemMetadata {
7676
public tsdocComment: tsdoc.DocComment | undefined;
7777

7878
// Assigned by DocCommentEnhancer
79-
public needsDocumentation: boolean = true;
79+
public undocumented: boolean = true;
8080

8181
public docCommentEnhancerVisitorState: VisitorState = VisitorState.Unvisited;
8282

apps/api-extractor/src/enhancers/DocCommentEnhancer.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export class DocCommentEnhancer {
7373
// Constructors always do pretty much the same thing, so it's annoying to require people to write
7474
// descriptions for them. Instead, if the constructor lacks a TSDoc summary, then API Extractor
7575
// will auto-generate one.
76-
metadata.needsDocumentation = false;
76+
metadata.undocumented = false;
7777

7878
// The class that contains this constructor
7979
const classDeclaration: AstDeclaration = astDeclaration.parent!;
@@ -135,12 +135,12 @@ export class DocCommentEnhancer {
135135

136136
if (metadata.tsdocComment) {
137137
// Require the summary to contain at least 10 non-spacing characters
138-
metadata.needsDocumentation = !tsdoc.PlainTextEmitter.hasAnyTextContent(
138+
metadata.undocumented = !tsdoc.PlainTextEmitter.hasAnyTextContent(
139139
metadata.tsdocComment.summarySection,
140140
10
141141
);
142142
} else {
143-
metadata.needsDocumentation = true;
143+
metadata.undocumented = true;
144144
}
145145
}
146146

apps/api-extractor/src/generators/ApiReportGenerator.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { AstNamespaceImport } from '../analyzer/AstNamespaceImport';
2020
import type { AstEntity } from '../analyzer/AstEntity';
2121
import type { AstModuleExportInfo } from '../analyzer/AstModule';
2222
import { SourceFileLocationFormatter } from '../analyzer/SourceFileLocationFormatter';
23+
import { ExtractorMessageId } from '../api/ExtractorMessageId';
2324

2425
export class ApiReportGenerator {
2526
private static _trimSpacesRegExp: RegExp = / +$/gm;
@@ -522,8 +523,14 @@ export class ApiReportGenerator {
522523
}
523524
}
524525

525-
if (apiItemMetadata.needsDocumentation) {
526+
if (apiItemMetadata.undocumented) {
526527
footerParts.push('(undocumented)');
528+
529+
collector.messageRouter.addAnalyzerIssue(
530+
ExtractorMessageId.Undocumented,
531+
`Missing documentation for "${astDeclaration.astSymbol.localName}".`,
532+
astDeclaration
533+
);
527534
}
528535

529536
if (footerParts.length > 0) {

apps/api-extractor/src/schemas/api-extractor-defaults.json

+3
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@
6969
"logLevel": "warning",
7070
"addToApiReportFile": true
7171
},
72+
"ae-undocumented": {
73+
"logLevel": "none"
74+
},
7275
"ae-unresolved-inheritdoc-reference": {
7376
"logLevel": "warning",
7477
"addToApiReportFile": true

build-tests/install-test-workspace/workspace/common/pnpm-lock.yaml

+47-47
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@microsoft/api-extractor",
5+
"comment": "Add a new message \"ae-undocumented\" to support logging of undocumented API items",
6+
"type": "minor"
7+
}
8+
],
9+
"packageName": "@microsoft/api-extractor"
10+
}

common/reviews/api/api-extractor.api.md

+1
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ export const enum ExtractorMessageId {
144144
PreapprovedBadReleaseTag = "ae-preapproved-bad-release-tag",
145145
PreapprovedUnsupportedType = "ae-preapproved-unsupported-type",
146146
SetterWithDocs = "ae-setter-with-docs",
147+
Undocumented = "ae-undocumented",
147148
UnresolvedInheritDocBase = "ae-unresolved-inheritdoc-base",
148149
UnresolvedInheritDocReference = "ae-unresolved-inheritdoc-reference",
149150
UnresolvedLink = "ae-unresolved-link",

libraries/rush-lib/src/logic/base/BaseInstallManagerTypes.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export interface IInstallManagerOptions {
5353
recheckShrinkwrap: boolean;
5454

5555
/**
56-
* Do not attempt to access the network. Report an error if the required dependencies
56+
* Do not attempt to access the network. Report an error if the required dependencies
5757
* cannot be obtained from the local cache.
5858
*/
5959
offline: boolean;

0 commit comments

Comments
 (0)