Skip to content

Commit 1361612

Browse files
committed
Remove unnecessary code
1 parent 920a125 commit 1361612

File tree

6 files changed

+28
-53
lines changed

6 files changed

+28
-53
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ export interface IConfigDocModel {
141141
*
142142
* @defaultValue `false`
143143
*/
144-
includeForgottenExports?: boolean;
144+
includeForgottenExports?: boolean;
145145

146146
/**
147147
* The URL to the `<projectFolder>` token where the project's source code can be viewed on a website like GitHub or
@@ -153,9 +153,9 @@ export interface IConfigDocModel {
153153
* item's file path is "api/ExtractorConfig.ts", the full URL file path would be
154154
* "https://github.com/microsoft/rushstack/tree/main/apps/api-extractor/api/ExtractorConfig.js".
155155
*
156-
* Can be omitted if you don't care about including source code links in your API documentation reference.
156+
* Can be omitted if you don't need source code links in your API documentation reference.
157157
*/
158-
projectFolderUrl?: string;
158+
projectFolderUrl?: string;
159159
}
160160

161161
/**

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

Lines changed: 17 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,7 @@ export class ApiModelGenerator {
152152
releaseTag: ReleaseTag.None,
153153
excerptTokens: [],
154154
isExported,
155-
fileUrlPath,
156-
parent: parentApiItem
155+
fileUrlPath
157156
});
158157
parentApiItem.addMember(apiNamespace);
159158
}
@@ -309,8 +308,7 @@ export class ApiModelGenerator {
309308
overloadIndex,
310309
excerptTokens,
311310
returnTypeTokenRange,
312-
fileUrlPath,
313-
parent: parentApiItem
311+
fileUrlPath
314312
});
315313

316314
parentApiItem.addMember(apiCallSignature);
@@ -351,8 +349,7 @@ export class ApiModelGenerator {
351349
parameters,
352350
overloadIndex,
353351
excerptTokens,
354-
fileUrlPath,
355-
parent: parentApiItem
352+
fileUrlPath
356353
});
357354

358355
parentApiItem.addMember(apiConstructor);
@@ -408,8 +405,7 @@ export class ApiModelGenerator {
408405
extendsTokenRange,
409406
implementsTokenRanges,
410407
isExported,
411-
fileUrlPath,
412-
parent: parentApiItem
408+
fileUrlPath
413409
});
414410

415411
parentApiItem.addMember(apiClass);
@@ -466,8 +462,7 @@ export class ApiModelGenerator {
466462
overloadIndex,
467463
excerptTokens,
468464
returnTypeTokenRange,
469-
fileUrlPath,
470-
parent: parentApiItem
465+
fileUrlPath
471466
});
472467

473468
parentApiItem.addMember(apiConstructSignature);
@@ -496,8 +491,7 @@ export class ApiModelGenerator {
496491
excerptTokens,
497492
preserveMemberOrder,
498493
isExported,
499-
fileUrlPath,
500-
parent: parentApiItem
494+
fileUrlPath
501495
});
502496
parentApiItem.addMember(apiEnum);
503497
}
@@ -539,8 +533,7 @@ export class ApiModelGenerator {
539533
releaseTag,
540534
excerptTokens,
541535
initializerTokenRange,
542-
fileUrlPath,
543-
parent: parentApiItem
536+
fileUrlPath
544537
});
545538

546539
parentApiItem.addMember(apiEnumMember);
@@ -590,8 +583,7 @@ export class ApiModelGenerator {
590583
excerptTokens,
591584
returnTypeTokenRange,
592585
isExported,
593-
fileUrlPath,
594-
parent: parentApiItem
586+
fileUrlPath
595587
});
596588

597589
parentApiItem.addMember(apiFunction);
@@ -636,8 +628,7 @@ export class ApiModelGenerator {
636628
excerptTokens,
637629
returnTypeTokenRange,
638630
isReadonly,
639-
fileUrlPath,
640-
parent: parentApiItem
631+
fileUrlPath
641632
});
642633

643634
parentApiItem.addMember(apiIndexSignature);
@@ -689,8 +680,7 @@ export class ApiModelGenerator {
689680
typeParameters,
690681
extendsTokenRanges,
691682
isExported,
692-
fileUrlPath,
693-
parent: parentApiItem
683+
fileUrlPath
694684
});
695685

696686
parentApiItem.addMember(apiInterface);
@@ -752,8 +742,7 @@ export class ApiModelGenerator {
752742
overloadIndex,
753743
excerptTokens,
754744
returnTypeTokenRange,
755-
fileUrlPath,
756-
parent: parentApiItem
745+
fileUrlPath
757746
});
758747

759748
parentApiItem.addMember(apiMethod);
@@ -808,8 +797,7 @@ export class ApiModelGenerator {
808797
overloadIndex,
809798
excerptTokens,
810799
returnTypeTokenRange,
811-
fileUrlPath,
812-
parent: parentApiItem
800+
fileUrlPath
813801
});
814802

815803
parentApiItem.addMember(apiMethodSignature);
@@ -837,8 +825,7 @@ export class ApiModelGenerator {
837825
releaseTag,
838826
excerptTokens,
839827
isExported,
840-
fileUrlPath,
841-
parent: parentApiItem
828+
fileUrlPath
842829
});
843830
parentApiItem.addMember(apiNamespace);
844831
}
@@ -901,8 +888,7 @@ export class ApiModelGenerator {
901888
excerptTokens,
902889
propertyTypeTokenRange,
903890
initializerTokenRange,
904-
fileUrlPath,
905-
parent: parentApiItem
891+
fileUrlPath
906892
});
907893
parentApiItem.addMember(apiProperty);
908894
} else {
@@ -947,8 +933,7 @@ export class ApiModelGenerator {
947933
excerptTokens,
948934
propertyTypeTokenRange,
949935
isReadonly,
950-
fileUrlPath,
951-
parent: parentApiItem
936+
fileUrlPath
952937
});
953938

954939
parentApiItem.addMember(apiPropertySignature);
@@ -995,8 +980,7 @@ export class ApiModelGenerator {
995980
excerptTokens,
996981
typeTokenRange,
997982
isExported,
998-
fileUrlPath,
999-
parent: parentApiItem
983+
fileUrlPath
1000984
});
1001985

1002986
parentApiItem.addMember(apiTypeAlias);
@@ -1041,8 +1025,7 @@ export class ApiModelGenerator {
10411025
initializerTokenRange,
10421026
isReadonly,
10431027
isExported,
1044-
fileUrlPath,
1045-
parent: parentApiItem
1028+
fileUrlPath
10461029
});
10471030

10481031
parentApiItem.addMember(apiVariable);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@
226226
* item's file path is "api/ExtractorConfig.ts", the full URL file path would be
227227
* "https://github.com/microsoft/rushstack/tree/main/apps/api-extractor/api/ExtractorConfig.js".
228228
*
229-
* Can be omitted if you don't care about including source code links in your API documentation reference.
229+
* Can be omitted if you don't need source code links in your API documentation reference.
230230
*
231231
* SUPPORTED TOKENS: none
232232
* DEFAULT VALUE: ""

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108
"type": "boolean"
109109
},
110110
"projectFolderUrl": {
111-
"description": "The URL to the `<projectFolder>` token where the project's source code can be viewed on a website like GitHub or Azure DevOps. This URL is concatenated with the file paths serialized to the doc model to produce URL file paths to individual API items. For example, if the `projectFolderUrl` is \"https://github.com/microsoft/rushstack/tree/main/apps/api-extractor\" and an API item's file path is \"api/ExtractorConfig.ts\", the full URL file path would be \"https://github.com/microsoft/rushstack/tree/main/apps/api-extractor/api/ExtractorConfig.js\". Can be omitted if you don't care about including source code links in your API documentation reference.",
111+
"description": "The URL to the `<projectFolder>` token where the project's source code can be viewed on a website like GitHub or Azure DevOps. This URL is concatenated with the file paths serialized to the doc model to produce URL file paths to individual API items. For example, if the `projectFolderUrl` is \"https://github.com/microsoft/rushstack/tree/main/apps/api-extractor\" and an API item's file path is \"api/ExtractorConfig.ts\", the full URL file path would be \"https://github.com/microsoft/rushstack/tree/main/apps/api-extractor/api/ExtractorConfig.js\". Can be omitted if you don't need source code links in your API documentation reference.",
112112
"type": "string"
113113
}
114114
},

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -752,8 +752,6 @@ export interface IApiDeclaredItemOptions extends IApiDocumentedItemOptions {
752752
excerptTokens: IExcerptToken[];
753753
// (undocumented)
754754
fileUrlPath?: string;
755-
// (undocumented)
756-
parent?: ApiItemContainerMixin;
757755
}
758756

759757
// @public

libraries/api-extractor-model/src/items/ApiDeclaredItem.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,13 @@ import { ApiDocumentedItem, IApiDocumentedItemJson, IApiDocumentedItemOptions }
66
import { Excerpt, ExcerptToken, IExcerptTokenRange, IExcerptToken } from '../mixins/Excerpt';
77
import { DeserializerContext } from '../model/DeserializerContext';
88
import { SourceLocation } from '../model/SourceLocation';
9-
import { ApiItemContainerMixin } from '../mixins/ApiItemContainerMixin';
109

1110
/**
1211
* Constructor options for {@link ApiDeclaredItem}.
1312
* @public
1413
*/
1514
export interface IApiDeclaredItemOptions extends IApiDocumentedItemOptions {
1615
excerptTokens: IExcerptToken[];
17-
parent?: ApiItemContainerMixin;
1816
fileUrlPath?: string;
1917
}
2018

@@ -55,10 +53,7 @@ export class ApiDeclaredItem extends ApiDocumentedItem {
5553
this._excerpt = new Excerpt(this.excerptTokens, { startIndex: 0, endIndex: this.excerptTokens.length });
5654

5755
const projectFolderUrl: string | undefined = this.getAssociatedPackage()?.projectFolderUrl;
58-
const fileUrlPath: string | undefined =
59-
options.parent instanceof ApiDeclaredItem
60-
? options.fileUrlPath || options.parent.sourceLocation.fileUrlPath
61-
: options.fileUrlPath;
56+
const fileUrlPath: string | undefined = options.fileUrlPath || this._parentSourceLocation?.fileUrlPath;
6257

6358
this._sourceLocation = new SourceLocation({
6459
projectFolderUrl: projectFolderUrl,
@@ -140,16 +135,11 @@ export class ApiDeclaredItem extends ApiDocumentedItem {
140135
return excerptToken;
141136
});
142137

143-
let parentSourceLocation: SourceLocation | undefined;
144-
if (this.parent instanceof ApiDeclaredItem) {
145-
parentSourceLocation = this.parent.sourceLocation;
146-
}
147-
148138
// Only serialize this API item's file URL path if it exists and it's different from its parent's
149139
// (a little optimization to keep the doc model succinct).
150140
if (
151141
this._sourceLocation.fileUrlPath &&
152-
this._sourceLocation.fileUrlPath !== parentSourceLocation?.fileUrlPath
142+
this._sourceLocation.fileUrlPath !== this._parentSourceLocation?.fileUrlPath
153143
) {
154144
jsonObject.fileUrlPath = this._sourceLocation.fileUrlPath;
155145
}
@@ -161,4 +151,8 @@ export class ApiDeclaredItem extends ApiDocumentedItem {
161151
public buildExcerpt(tokenRange: IExcerptTokenRange): Excerpt {
162152
return new Excerpt(this.excerptTokens, tokenRange);
163153
}
154+
155+
private get _parentSourceLocation(): SourceLocation | undefined {
156+
return this.parent instanceof ApiDeclaredItem ? this.parent.sourceLocation : undefined;
157+
}
164158
}

0 commit comments

Comments
 (0)