Skip to content

Commit 0261283

Browse files
committed
[api-extractor] addressing comments
1 parent b93f549 commit 0261283

File tree

19 files changed

+22
-44
lines changed

19 files changed

+22
-44
lines changed

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -653,16 +653,14 @@ export class ApiModelGenerator {
653653
const apiItemMetadata: ApiItemMetadata = this._collector.fetchApiItemMetadata(astDeclaration);
654654
const docComment: tsdoc.DocComment | undefined = apiItemMetadata.tsdocComment;
655655
const releaseTag: ReleaseTag = apiItemMetadata.effectiveReleaseTag;
656-
const isReadonly: boolean = this._determineReadonly(astDeclaration);
657656

658657
apiInterface = new ApiInterface({
659658
name,
660659
docComment,
661660
releaseTag,
662661
excerptTokens,
663662
typeParameters,
664-
extendsTokenRanges,
665-
isReadonly
663+
extendsTokenRanges
666664
});
667665

668666
parentApiItem.addMember(apiInterface);
@@ -675,8 +673,11 @@ export class ApiModelGenerator {
675673
const apiItemMetadata: ApiItemMetadata = this._collector.fetchApiItemMetadata(astDeclaration);
676674
const docComment: tsdoc.DocComment | undefined = apiItemMetadata.tsdocComment;
677675
const declarationMetadata: DeclarationMetadata = this._collector.fetchDeclarationMetadata(astDeclaration);
676+
//Line 1: sees whether the readonly modifier is present
677+
//Line 2: sees if the TSDoc comment for @readonly is present
678+
//Line 3: sees whether a getter is present for a property with no setter
678679
return (astDeclaration.modifierFlags & ts.ModifierFlags.Readonly) !== 0
679-
|| (docComment !== undefined && docComment.modifierTagSet.hasTagName('@readonly'))
680+
|| (docComment !== undefined && docComment.modifierTagSet.hasTagName('@readonly'))
680681
|| (declarationMetadata.ancillaryDeclarations.length === 0 && astDeclaration.declaration.kind === ts.SyntaxKind.GetAccessor);
681682
}
682683

build-tests/api-documenter-test/etc/api-documenter-test.api.json

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,6 @@
190190
"text": "export interface Constraint "
191191
}
192192
],
193-
"isReadonly": false,
194193
"releaseTag": "Public",
195194
"name": "Constraint",
196195
"members": [],
@@ -272,7 +271,6 @@
272271
"text": "export interface DefaultType "
273272
}
274273
],
275-
"isReadonly": false,
276274
"releaseTag": "Public",
277275
"name": "DefaultType",
278276
"members": [],
@@ -991,7 +989,6 @@
991989
"text": "export interface DocClassInterfaceMerge "
992990
}
993991
],
994-
"isReadonly": false,
995992
"releaseTag": "Public",
996993
"name": "DocClassInterfaceMerge",
997994
"members": [],
@@ -1448,7 +1445,6 @@
14481445
"text": "export interface IDocInterface1 "
14491446
}
14501447
],
1451-
"isReadonly": false,
14521448
"releaseTag": "Public",
14531449
"name": "IDocInterface1",
14541450
"members": [
@@ -1502,7 +1498,6 @@
15021498
"text": " "
15031499
}
15041500
],
1505-
"isReadonly": false,
15061501
"releaseTag": "Public",
15071502
"name": "IDocInterface2",
15081503
"members": [
@@ -1553,7 +1548,6 @@
15531548
"text": "export interface IDocInterface3 "
15541549
}
15551550
],
1556-
"isReadonly": false,
15571551
"releaseTag": "Public",
15581552
"name": "IDocInterface3",
15591553
"members": [
@@ -1773,7 +1767,6 @@
17731767
"text": "export interface IDocInterface4 "
17741768
}
17751769
],
1776-
"isReadonly": false,
17771770
"releaseTag": "Public",
17781771
"name": "IDocInterface4",
17791772
"members": [
@@ -1903,7 +1896,6 @@
19031896
"text": "export interface IDocInterface5 "
19041897
}
19051898
],
1906-
"isReadonly": false,
19071899
"releaseTag": "Public",
19081900
"name": "IDocInterface5",
19091901
"members": [
@@ -1947,7 +1939,6 @@
19471939
"text": "export interface IDocInterface6 "
19481940
}
19491941
],
1950-
"isReadonly": false,
19511942
"releaseTag": "Public",
19521943
"name": "IDocInterface6",
19531944
"members": [
@@ -2242,7 +2233,6 @@
22422233
"text": "export interface IDocInterface7 "
22432234
}
22442235
],
2245-
"isReadonly": false,
22462236
"releaseTag": "Public",
22472237
"name": "IDocInterface7",
22482238
"members": [

build-tests/api-extractor-scenarios/etc/test-outputs/apiItemKinds/api-extractor-scenarios.api.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,6 @@
406406
"text": "export interface IInterface "
407407
}
408408
],
409-
"isReadonly": false,
410409
"releaseTag": "Public",
411410
"name": "IInterface",
412411
"members": [

build-tests/api-extractor-scenarios/etc/test-outputs/docReferences3/api-extractor-scenarios.api.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,6 @@
180180
"text": "export interface A "
181181
}
182182
],
183-
"isReadonly": false,
184183
"releaseTag": "Public",
185184
"name": "A",
186185
"members": [

build-tests/api-extractor-scenarios/etc/test-outputs/dynamicImportType2/api-extractor-scenarios.api.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,6 @@
180180
"text": "export interface IExample "
181181
}
182182
],
183-
"isReadonly": false,
184183
"releaseTag": "Public",
185184
"name": "IExample",
186185
"members": [

build-tests/api-extractor-scenarios/etc/test-outputs/dynamicImportType3/api-extractor-scenarios.api.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,6 @@
180180
"text": "export interface IExample "
181181
}
182182
],
183-
"isReadonly": false,
184183
"releaseTag": "Public",
185184
"name": "IExample",
186185
"members": [

build-tests/api-extractor-scenarios/etc/test-outputs/exportEquals/api-extractor-scenarios.api.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,6 @@
180180
"text": "export interface ITeamsContext "
181181
}
182182
],
183-
"isReadonly": false,
184183
"releaseTag": "Public",
185184
"name": "ITeamsContext",
186185
"members": [

build-tests/api-extractor-scenarios/etc/test-outputs/importType/api-extractor-scenarios.api.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,6 @@
189189
"text": " "
190190
}
191191
],
192-
"isReadonly": false,
193192
"releaseTag": "Public",
194193
"name": "A",
195194
"members": [],
@@ -219,7 +218,6 @@
219218
"text": " "
220219
}
221220
],
222-
"isReadonly": false,
223221
"releaseTag": "Public",
224222
"name": "B",
225223
"members": [],
@@ -249,7 +247,6 @@
249247
"text": " "
250248
}
251249
],
252-
"isReadonly": false,
253250
"releaseTag": "Public",
254251
"name": "C",
255252
"members": [],

build-tests/api-extractor-scenarios/etc/test-outputs/inconsistentReleaseTags/api-extractor-scenarios.api.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,6 @@
180180
"text": "export interface IBeta "
181181
}
182182
],
183-
"isReadonly": false,
184183
"releaseTag": "Beta",
185184
"name": "IBeta",
186185
"members": [

build-tests/api-extractor-scenarios/etc/test-outputs/namedDefaultImport/api-extractor-scenarios.api.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,6 @@
180180
"text": "export interface DefaultImportTypes "
181181
}
182182
],
183-
"isReadonly": false,
184183
"releaseTag": "Public",
185184
"name": "DefaultImportTypes",
186185
"members": [

build-tests/api-extractor-scenarios/etc/test-outputs/readonlyDeclarations/api-extractor-scenarios.api.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,6 @@
180180
"text": "export interface _IInternalThing "
181181
}
182182
],
183-
"isReadonly": false,
184183
"releaseTag": "Public",
185184
"name": "_IInternalThing",
186185
"members": [

build-tests/api-extractor-scenarios/etc/test-outputs/typeParameters/api-extractor-scenarios.api.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,6 @@
379379
"text": "export interface GenericInterface<T> "
380380
}
381381
],
382-
"isReadonly": false,
383382
"releaseTag": "Public",
384383
"typeParameters": [
385384
{
@@ -446,7 +445,6 @@
446445
"text": "export interface InterfaceWithGenericCallSignature "
447446
}
448447
],
449-
"isReadonly": false,
450448
"releaseTag": "Public",
451449
"name": "InterfaceWithGenericCallSignature",
452450
"members": [
@@ -502,7 +500,6 @@
502500
"text": "export interface InterfaceWithGenericConstructSignature "
503501
}
504502
],
505-
"isReadonly": false,
506503
"releaseTag": "Public",
507504
"name": "InterfaceWithGenericConstructSignature",
508505
"members": [

common/changes/@microsoft/api-documenter/api-readonly-mixin_2022-05-19-20-18.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
"changes": [
33
{
44
"packageName": "@microsoft/api-documenter",
5-
"comment": "Adding readonlyMixin for Api Extractor",
6-
"type": "patch"
5+
"comment": "Add support for rendering readonly information next to API items",
6+
"type": "minor"
77
}
88
],
99
"packageName": "@microsoft/api-documenter"

common/changes/@microsoft/api-extractor-model/api-readonly-mixin_2022-05-19-20-18.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
"changes": [
33
{
44
"packageName": "@microsoft/api-extractor-model",
5-
"comment": "Adding readonlyMixin for Api Extractor",
6-
"type": "patch"
5+
"comment": "Adding isReadonly field to the models of relevant api pieces.",
6+
"type": "minor"
77
}
88
],
99
"packageName": "@microsoft/api-extractor-model"

common/changes/@microsoft/api-extractor/api-readonly-mixin_2022-05-19-20-18.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{
44
"packageName": "@microsoft/api-extractor",
55
"comment": "Adding readonlyMixin for Api Extractor",
6-
"type": "patch"
6+
"type": "minor"
77
}
88
],
99
"packageName": "@microsoft/api-extractor"

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -494,8 +494,10 @@ export class ApiPropertyItem extends ApiPropertyItem_base {
494494
serializeInto(jsonObject: Partial<IApiPropertyItemJson>): void;
495495
}
496496

497+
// Warning: (ae-forgotten-export) The symbol "ApiPropertySignature_base" needs to be exported by the entry point index.d.ts
498+
//
497499
// @public
498-
export class ApiPropertySignature extends ApiPropertyItem {
500+
export class ApiPropertySignature extends ApiPropertySignature_base {
499501
constructor(options: IApiPropertySignatureOptions);
500502
// @beta @override (undocumented)
501503
buildCanonicalReference(): DeclarationReference;
@@ -717,7 +719,7 @@ export interface IApiIndexSignatureOptions extends IApiParameterListMixinOptions
717719
}
718720

719721
// @public
720-
export interface IApiInterfaceOptions extends IApiItemContainerMixinOptions, IApiNameMixinOptions, IApiTypeParameterListMixinOptions, IApiReleaseTagMixinOptions, IApiDeclaredItemOptions, IApiReadonlyMixinOptions {
722+
export interface IApiInterfaceOptions extends IApiItemContainerMixinOptions, IApiNameMixinOptions, IApiTypeParameterListMixinOptions, IApiReleaseTagMixinOptions, IApiDeclaredItemOptions {
721723
// (undocumented)
722724
extendsTokenRanges: IExcerptTokenRange[];
723725
}
@@ -802,7 +804,7 @@ export interface IApiPropertyOptions extends IApiPropertyItemOptions, IApiReadon
802804
}
803805

804806
// @public
805-
export interface IApiPropertySignatureOptions extends IApiPropertyItemOptions {
807+
export interface IApiPropertySignatureOptions extends IApiPropertyItemOptions, IApiReadonlyMixinOptions {
806808
}
807809

808810
// @public

libraries/api-extractor-model/src/mixins/ApiReadonlyMixin.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ export interface IApiReadonlyMixinJson extends IApiItemJson {
1919
const _isReadonly: unique symbol = Symbol('ApiReadonlyMixin._isReadonly');
2020

2121
/**
22-
* The mixin base class for API items that can have type parameters.
22+
* The mixin base class for API items that cannot be modified after instantiation.
23+
* Examples such as the readonly modifier and only having a getter but no setter.
2324
*
2425
* @remarks
2526
*

libraries/api-extractor-model/src/model/ApiInterface.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import {
2727
IApiTypeParameterListMixinJson,
2828
ApiTypeParameterListMixin
2929
} from '../mixins/ApiTypeParameterListMixin';
30-
import { ApiReadonlyMixin, IApiReadonlyMixinOptions } from '../mixins/ApiReadonlyMixin';
3130
import { DeserializerContext } from './DeserializerContext';
3231

3332
/**
@@ -39,8 +38,7 @@ export interface IApiInterfaceOptions
3938
IApiNameMixinOptions,
4039
IApiTypeParameterListMixinOptions,
4140
IApiReleaseTagMixinOptions,
42-
IApiDeclaredItemOptions,
43-
IApiReadonlyMixinOptions {
41+
IApiDeclaredItemOptions {
4442
extendsTokenRanges: IExcerptTokenRange[];
4543
}
4644

@@ -71,7 +69,7 @@ export interface IApiInterfaceJson
7169
* @public
7270
*/
7371
export class ApiInterface extends ApiItemContainerMixin(
74-
ApiNameMixin(ApiTypeParameterListMixin(ApiReleaseTagMixin(ApiReadonlyMixin(ApiDeclaredItem))))
72+
ApiNameMixin(ApiTypeParameterListMixin(ApiReleaseTagMixin(ApiDeclaredItem)))
7573
) {
7674
private readonly _extendsTypes: HeritageType[] = [];
7775

libraries/api-extractor-model/src/model/ApiPropertySignature.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ import {
99
} from '@microsoft/tsdoc/lib-commonjs/beta/DeclarationReference';
1010
import { ApiItemKind } from '../items/ApiItem';
1111
import { ApiPropertyItem, IApiPropertyItemOptions } from '../items/ApiPropertyItem';
12-
12+
import { ApiReadonlyMixin, IApiReadonlyMixinOptions } from '../mixins/ApiReadonlyMixin';
1313
/**
1414
* Constructor options for {@link ApiPropertySignature}.
1515
* @public
1616
*/
17-
export interface IApiPropertySignatureOptions extends IApiPropertyItemOptions {}
17+
export interface IApiPropertySignatureOptions extends IApiPropertyItemOptions, IApiReadonlyMixinOptions {}
1818

1919
/**
2020
* Represents a TypeScript property declaration that belongs to an `ApiInterface`.
@@ -38,7 +38,7 @@ export interface IApiPropertySignatureOptions extends IApiPropertyItemOptions {}
3838
*
3939
* @public
4040
*/
41-
export class ApiPropertySignature extends ApiPropertyItem {
41+
export class ApiPropertySignature extends ApiReadonlyMixin(ApiPropertyItem) {
4242
public constructor(options: IApiPropertySignatureOptions) {
4343
super(options);
4444
}

0 commit comments

Comments
 (0)