Skip to content

Commit

Permalink
Merge pull request #3387 from zelliott/protected-mixin
Browse files Browse the repository at this point in the history
[api-extractor] Adds support for surfacing whether a class member is protected
  • Loading branch information
octogonz authored Jun 7, 2022
2 parents 39ab387 + 22b4423 commit fd89af2
Show file tree
Hide file tree
Showing 53 changed files with 322 additions and 82 deletions.
6 changes: 6 additions & 0 deletions apps/api-extractor/src/generators/ApiModelGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,10 +334,12 @@ export class ApiModelGenerator {
const apiItemMetadata: ApiItemMetadata = this._collector.fetchApiItemMetadata(astDeclaration);
const docComment: tsdoc.DocComment | undefined = apiItemMetadata.tsdocComment;
const releaseTag: ReleaseTag = apiItemMetadata.effectiveReleaseTag;
const isProtected: boolean = (astDeclaration.modifierFlags & ts.ModifierFlags.Protected) !== 0;

apiConstructor = new ApiConstructor({
docComment,
releaseTag,
isProtected,
parameters,
overloadIndex,
excerptTokens
Expand Down Expand Up @@ -709,11 +711,13 @@ export class ApiModelGenerator {
}
const isOptional: boolean =
(astDeclaration.astSymbol.followedSymbol.flags & ts.SymbolFlags.Optional) !== 0;
const isProtected: boolean = (astDeclaration.modifierFlags & ts.ModifierFlags.Protected) !== 0;

apiMethod = new ApiMethod({
name,
docComment,
releaseTag,
isProtected,
isStatic,
isOptional,
typeParameters,
Expand Down Expand Up @@ -846,11 +850,13 @@ export class ApiModelGenerator {
const releaseTag: ReleaseTag = apiItemMetadata.effectiveReleaseTag;
const isOptional: boolean =
(astDeclaration.astSymbol.followedSymbol.flags & ts.SymbolFlags.Optional) !== 0;
const isProtected: boolean = (astDeclaration.modifierFlags & ts.ModifierFlags.Protected) !== 0;

apiProperty = new ApiProperty({
name,
docComment,
releaseTag,
isProtected,
isStatic,
isOptional,
excerptTokens,
Expand Down
34 changes: 26 additions & 8 deletions build-tests/api-documenter-test/etc/api-documenter-test.api.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"metadata": {
"toolPackage": "@microsoft/api-extractor",
"toolVersion": "[test mode]",
"schemaVersion": 1005,
"schemaVersion": 1006,
"oldestForwardsCompatibleVersion": 1001,
"tsdocConfig": {
"$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json",
Expand Down Expand Up @@ -255,7 +255,8 @@
"startIndex": 1,
"endIndex": 2
},
"isStatic": false
"isStatic": false,
"isProtected": false
}
],
"implementsTokenRanges": []
Expand Down Expand Up @@ -298,6 +299,7 @@
"text": "constructor();"
}
],
"isProtected": false,
"releaseTag": "Public",
"overloadIndex": 1,
"parameters": []
Expand All @@ -320,6 +322,7 @@
"text": ");"
}
],
"isProtected": false,
"releaseTag": "Public",
"overloadIndex": 2,
"parameters": [
Expand Down Expand Up @@ -400,6 +403,7 @@
],
"isOptional": false,
"isStatic": false,
"isProtected": false,
"returnTypeTokenRange": {
"startIndex": 1,
"endIndex": 2
Expand Down Expand Up @@ -445,6 +449,7 @@
],
"isOptional": false,
"isStatic": false,
"isProtected": false,
"returnTypeTokenRange": {
"startIndex": 5,
"endIndex": 6
Expand Down Expand Up @@ -499,6 +504,7 @@
],
"isOptional": false,
"isStatic": false,
"isProtected": false,
"returnTypeTokenRange": {
"startIndex": 3,
"endIndex": 4
Expand Down Expand Up @@ -567,6 +573,7 @@
],
"isOptional": false,
"isStatic": false,
"isProtected": false,
"returnTypeTokenRange": {
"startIndex": 8,
"endIndex": 9
Expand Down Expand Up @@ -618,6 +625,7 @@
],
"isOptional": false,
"isStatic": false,
"isProtected": false,
"returnTypeTokenRange": {
"startIndex": 1,
"endIndex": 2
Expand Down Expand Up @@ -653,7 +661,8 @@
"startIndex": 1,
"endIndex": 2
},
"isStatic": false
"isStatic": false,
"isProtected": false
},
{
"kind": "Property",
Expand Down Expand Up @@ -681,7 +690,8 @@
"startIndex": 1,
"endIndex": 2
},
"isStatic": false
"isStatic": false,
"isProtected": false
},
{
"kind": "Method",
Expand Down Expand Up @@ -711,6 +721,7 @@
],
"isOptional": false,
"isStatic": false,
"isProtected": false,
"returnTypeTokenRange": {
"startIndex": 3,
"endIndex": 4
Expand Down Expand Up @@ -754,7 +765,8 @@
"startIndex": 1,
"endIndex": 2
},
"isStatic": false
"isStatic": false,
"isProtected": false
},
{
"kind": "Property",
Expand Down Expand Up @@ -782,7 +794,8 @@
"startIndex": 1,
"endIndex": 2
},
"isStatic": false
"isStatic": false,
"isProtected": false
},
{
"kind": "Method",
Expand Down Expand Up @@ -820,6 +833,7 @@
],
"isOptional": false,
"isStatic": true,
"isProtected": false,
"returnTypeTokenRange": {
"startIndex": 5,
"endIndex": 6
Expand Down Expand Up @@ -866,6 +880,7 @@
],
"isOptional": false,
"isStatic": false,
"isProtected": false,
"returnTypeTokenRange": {
"startIndex": 1,
"endIndex": 2
Expand Down Expand Up @@ -904,7 +919,8 @@
"startIndex": 1,
"endIndex": 2
},
"isStatic": false
"isStatic": false,
"isProtected": false
},
{
"kind": "Property",
Expand All @@ -931,7 +947,8 @@
"startIndex": 1,
"endIndex": 2
},
"isStatic": false
"isStatic": false,
"isProtected": false
}
],
"extendsTokenRange": {
Expand Down Expand Up @@ -2449,6 +2466,7 @@
],
"isOptional": false,
"isStatic": false,
"isProtected": false,
"returnTypeTokenRange": {
"startIndex": 3,
"endIndex": 4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"metadata": {
"toolPackage": "@microsoft/api-extractor",
"toolVersion": "[test mode]",
"schemaVersion": 1005,
"schemaVersion": 1006,
"oldestForwardsCompatibleVersion": 1001,
"tsdocConfig": {
"$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"metadata": {
"toolPackage": "@microsoft/api-extractor",
"toolVersion": "[test mode]",
"schemaVersion": 1005,
"schemaVersion": 1006,
"oldestForwardsCompatibleVersion": 1001,
"tsdocConfig": {
"$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"metadata": {
"toolPackage": "@microsoft/api-extractor",
"toolVersion": "[test mode]",
"schemaVersion": 1005,
"schemaVersion": 1006,
"oldestForwardsCompatibleVersion": 1001,
"tsdocConfig": {
"$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"metadata": {
"toolPackage": "@microsoft/api-extractor",
"toolVersion": "[test mode]",
"schemaVersion": 1005,
"schemaVersion": 1006,
"oldestForwardsCompatibleVersion": 1001,
"tsdocConfig": {
"$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json",
Expand Down Expand Up @@ -203,6 +203,7 @@
],
"isOptional": false,
"isStatic": false,
"isProtected": false,
"returnTypeTokenRange": {
"startIndex": 1,
"endIndex": 2
Expand Down Expand Up @@ -256,6 +257,7 @@
],
"isOptional": false,
"isStatic": false,
"isProtected": false,
"returnTypeTokenRange": {
"startIndex": 3,
"endIndex": 4
Expand Down Expand Up @@ -303,6 +305,7 @@
],
"isOptional": false,
"isStatic": false,
"isProtected": false,
"returnTypeTokenRange": {
"startIndex": 1,
"endIndex": 4
Expand Down Expand Up @@ -603,6 +606,7 @@
],
"isOptional": false,
"isStatic": false,
"isProtected": false,
"returnTypeTokenRange": {
"startIndex": 1,
"endIndex": 2
Expand Down Expand Up @@ -640,6 +644,7 @@
],
"isOptional": false,
"isStatic": false,
"isProtected": false,
"returnTypeTokenRange": {
"startIndex": 3,
"endIndex": 4
Expand Down Expand Up @@ -683,7 +688,8 @@
"startIndex": 1,
"endIndex": 2
},
"isStatic": false
"isStatic": false,
"isProtected": false
},
{
"kind": "Property",
Expand All @@ -702,7 +708,8 @@
"startIndex": 0,
"endIndex": 0
},
"isStatic": false
"isStatic": false,
"isProtected": false
},
{
"kind": "Property",
Expand All @@ -729,7 +736,8 @@
"startIndex": 1,
"endIndex": 2
},
"isStatic": false
"isStatic": false,
"isProtected": false
},
{
"kind": "Property",
Expand Down Expand Up @@ -760,7 +768,8 @@
"startIndex": 1,
"endIndex": 2
},
"isStatic": false
"isStatic": false,
"isProtected": false
}
],
"implementsTokenRanges": []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"metadata": {
"toolPackage": "@microsoft/api-extractor",
"toolVersion": "[test mode]",
"schemaVersion": 1005,
"schemaVersion": 1006,
"oldestForwardsCompatibleVersion": 1001,
"tsdocConfig": {
"$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json",
Expand Down Expand Up @@ -279,7 +279,8 @@
"startIndex": 1,
"endIndex": 2
},
"isStatic": false
"isStatic": false,
"isProtected": false
},
{
"kind": "Property",
Expand All @@ -306,7 +307,8 @@
"startIndex": 1,
"endIndex": 2
},
"isStatic": false
"isStatic": false,
"isProtected": false
}
],
"extendsTokenRange": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"metadata": {
"toolPackage": "@microsoft/api-extractor",
"toolVersion": "[test mode]",
"schemaVersion": 1005,
"schemaVersion": 1006,
"oldestForwardsCompatibleVersion": 1001,
"tsdocConfig": {
"$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json",
Expand Down Expand Up @@ -209,7 +209,8 @@
"startIndex": 1,
"endIndex": 2
},
"isStatic": false
"isStatic": false,
"isProtected": false
}
],
"implementsTokenRanges": []
Expand Down Expand Up @@ -257,7 +258,8 @@
"startIndex": 1,
"endIndex": 3
},
"isStatic": false
"isStatic": false,
"isProtected": false
},
{
"kind": "Property",
Expand Down Expand Up @@ -289,7 +291,8 @@
"startIndex": 1,
"endIndex": 3
},
"isStatic": false
"isStatic": false,
"isProtected": false
}
],
"implementsTokenRanges": []
Expand Down
Loading

0 comments on commit fd89af2

Please sign in to comment.