Skip to content

Commit

Permalink
Merge pull request #4392 from microsoft/octogonz/ae-undocumented-fix
Browse files Browse the repository at this point in the history
[api-extractor] Fix an issue where "ae-undocumented" was incorrectly reported for private members
  • Loading branch information
octogonz authored Nov 10, 2023
2 parents 2e26d1f + c87ac33 commit d861d22
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 27 deletions.
2 changes: 1 addition & 1 deletion apps/api-extractor/build-tests.cmd
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
@ECHO OFF
@SETLOCAL
rush test -t api-extractor-lib1-test -t api-extractor-lib2-test -t api-extractor-lib3-test -t api-extractor-scenarios -t api-extractor-test-01 -t api-extractor-test-02 -t api-extractor-test-03 -t api-extractor-test-04 -t api-documenter-test
rush test -t tag:api-extractor-tests
42 changes: 26 additions & 16 deletions apps/api-extractor/src/generators/ApiReportGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ export class ApiReportGenerator {
): void {
// Should we process this declaration at all?
// eslint-disable-next-line no-bitwise
if ((astDeclaration.modifierFlags & ts.ModifierFlags.Private) !== 0) {
if (!ApiReportGenerator._shouldIncludeInReport(astDeclaration)) {
span.modification.skipAll();
return;
}
Expand Down Expand Up @@ -402,23 +402,27 @@ export class ApiReportGenerator {
astDeclaration
);

if (sortChildren) {
span.modification.sortChildren = true;
child.modification.sortKey = Collector.getSortKeyIgnoringUnderscore(
childAstDeclaration.astSymbol.localName
);
}
if (ApiReportGenerator._shouldIncludeInReport(childAstDeclaration)) {
if (sortChildren) {
span.modification.sortChildren = true;
child.modification.sortKey = Collector.getSortKeyIgnoringUnderscore(
childAstDeclaration.astSymbol.localName
);
}

if (!insideTypeLiteral) {
const messagesToReport: ExtractorMessage[] =
collector.messageRouter.fetchAssociatedMessagesForReviewFile(childAstDeclaration);
const aedocSynopsis: string = ApiReportGenerator._getAedocSynopsis(
collector,
childAstDeclaration,
messagesToReport
);
if (!insideTypeLiteral) {
const messagesToReport: ExtractorMessage[] =
collector.messageRouter.fetchAssociatedMessagesForReviewFile(childAstDeclaration);

child.modification.prefix = aedocSynopsis + child.modification.prefix;
// NOTE: This generates ae-undocumented messages as a side effect
const aedocSynopsis: string = ApiReportGenerator._getAedocSynopsis(
collector,
childAstDeclaration,
messagesToReport
);

child.modification.prefix = aedocSynopsis + child.modification.prefix;
}
}
}

Expand All @@ -427,6 +431,12 @@ export class ApiReportGenerator {
}
}

private static _shouldIncludeInReport(astDeclaration: AstDeclaration): boolean {
// Private declarations are not included in the API report
// eslint-disable-next-line no-bitwise
return (astDeclaration.modifierFlags & ts.ModifierFlags.Private) === 0;
}

/**
* For declarations marked as `@preapproved`, this is used instead of _modifySpan().
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@microsoft/api-extractor",
"comment": "Fix an issue where \"ae-undocumented\" was incorrectly reported for private members",
"type": "patch"
}
],
"packageName": "@microsoft/api-extractor"
}
30 changes: 20 additions & 10 deletions rush.json
Original file line number Diff line number Diff line change
Expand Up @@ -483,61 +483,71 @@
"packageName": "api-documenter-test",
"projectFolder": "build-tests/api-documenter-test",
"reviewCategory": "tests",
"shouldPublish": false
"shouldPublish": false,
"tags": ["api-extractor-tests"]
},
{
"packageName": "api-documenter-scenarios",
"projectFolder": "build-tests/api-documenter-scenarios",
"reviewCategory": "tests",
"shouldPublish": false
"shouldPublish": false,
"tags": ["api-extractor-tests"]
},
{
"packageName": "api-extractor-lib1-test",
"projectFolder": "build-tests/api-extractor-lib1-test",
"reviewCategory": "tests",
"shouldPublish": false
"shouldPublish": false,
"tags": ["api-extractor-tests"]
},
{
"packageName": "api-extractor-lib2-test",
"projectFolder": "build-tests/api-extractor-lib2-test",
"reviewCategory": "tests",
"shouldPublish": false
"shouldPublish": false,
"tags": ["api-extractor-tests"]
},
{
"packageName": "api-extractor-lib3-test",
"projectFolder": "build-tests/api-extractor-lib3-test",
"reviewCategory": "tests",
"shouldPublish": false
"shouldPublish": false,
"tags": ["api-extractor-tests"]
},
{
"packageName": "api-extractor-scenarios",
"projectFolder": "build-tests/api-extractor-scenarios",
"reviewCategory": "tests",
"shouldPublish": false
"shouldPublish": false,
"tags": ["api-extractor-tests"]
},
{
"packageName": "api-extractor-test-01",
"projectFolder": "build-tests/api-extractor-test-01",
"reviewCategory": "tests",
"shouldPublish": false
"shouldPublish": false,
"tags": ["api-extractor-tests"]
},
{
"packageName": "api-extractor-test-02",
"projectFolder": "build-tests/api-extractor-test-02",
"reviewCategory": "tests",
"shouldPublish": false
"shouldPublish": false,
"tags": ["api-extractor-tests"]
},
{
"packageName": "api-extractor-test-03",
"projectFolder": "build-tests/api-extractor-test-03",
"reviewCategory": "tests",
"shouldPublish": false
"shouldPublish": false,
"tags": ["api-extractor-tests"]
},
{
"packageName": "api-extractor-test-04",
"projectFolder": "build-tests/api-extractor-test-04",
"reviewCategory": "tests",
"shouldPublish": false
"shouldPublish": false,
"tags": ["api-extractor-tests"]
},
{
"packageName": "eslint-7-7-test",
Expand Down

0 comments on commit d861d22

Please sign in to comment.