Skip to content

Commit

Permalink
Remove unnecessary code
Browse files Browse the repository at this point in the history
  • Loading branch information
zelliott committed Oct 11, 2022
1 parent 920a125 commit 1361612
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 53 deletions.
6 changes: 3 additions & 3 deletions apps/api-extractor/src/api/IConfigFile.ts
Expand Up @@ -141,7 +141,7 @@ export interface IConfigDocModel {
*
* @defaultValue `false`
*/
includeForgottenExports?: boolean;
includeForgottenExports?: boolean;

/**
* The URL to the `<projectFolder>` token where the project's source code can be viewed on a website like GitHub or
Expand All @@ -153,9 +153,9 @@ export interface IConfigDocModel {
* 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.
* Can be omitted if you don't need source code links in your API documentation reference.
*/
projectFolderUrl?: string;
projectFolderUrl?: string;
}

/**
Expand Down
51 changes: 17 additions & 34 deletions apps/api-extractor/src/generators/ApiModelGenerator.ts
Expand Up @@ -152,8 +152,7 @@ export class ApiModelGenerator {
releaseTag: ReleaseTag.None,
excerptTokens: [],
isExported,
fileUrlPath,
parent: parentApiItem
fileUrlPath
});
parentApiItem.addMember(apiNamespace);
}
Expand Down Expand Up @@ -309,8 +308,7 @@ export class ApiModelGenerator {
overloadIndex,
excerptTokens,
returnTypeTokenRange,
fileUrlPath,
parent: parentApiItem
fileUrlPath
});

parentApiItem.addMember(apiCallSignature);
Expand Down Expand Up @@ -351,8 +349,7 @@ export class ApiModelGenerator {
parameters,
overloadIndex,
excerptTokens,
fileUrlPath,
parent: parentApiItem
fileUrlPath
});

parentApiItem.addMember(apiConstructor);
Expand Down Expand Up @@ -408,8 +405,7 @@ export class ApiModelGenerator {
extendsTokenRange,
implementsTokenRanges,
isExported,
fileUrlPath,
parent: parentApiItem
fileUrlPath
});

parentApiItem.addMember(apiClass);
Expand Down Expand Up @@ -466,8 +462,7 @@ export class ApiModelGenerator {
overloadIndex,
excerptTokens,
returnTypeTokenRange,
fileUrlPath,
parent: parentApiItem
fileUrlPath
});

parentApiItem.addMember(apiConstructSignature);
Expand Down Expand Up @@ -496,8 +491,7 @@ export class ApiModelGenerator {
excerptTokens,
preserveMemberOrder,
isExported,
fileUrlPath,
parent: parentApiItem
fileUrlPath
});
parentApiItem.addMember(apiEnum);
}
Expand Down Expand Up @@ -539,8 +533,7 @@ export class ApiModelGenerator {
releaseTag,
excerptTokens,
initializerTokenRange,
fileUrlPath,
parent: parentApiItem
fileUrlPath
});

parentApiItem.addMember(apiEnumMember);
Expand Down Expand Up @@ -590,8 +583,7 @@ export class ApiModelGenerator {
excerptTokens,
returnTypeTokenRange,
isExported,
fileUrlPath,
parent: parentApiItem
fileUrlPath
});

parentApiItem.addMember(apiFunction);
Expand Down Expand Up @@ -636,8 +628,7 @@ export class ApiModelGenerator {
excerptTokens,
returnTypeTokenRange,
isReadonly,
fileUrlPath,
parent: parentApiItem
fileUrlPath
});

parentApiItem.addMember(apiIndexSignature);
Expand Down Expand Up @@ -689,8 +680,7 @@ export class ApiModelGenerator {
typeParameters,
extendsTokenRanges,
isExported,
fileUrlPath,
parent: parentApiItem
fileUrlPath
});

parentApiItem.addMember(apiInterface);
Expand Down Expand Up @@ -752,8 +742,7 @@ export class ApiModelGenerator {
overloadIndex,
excerptTokens,
returnTypeTokenRange,
fileUrlPath,
parent: parentApiItem
fileUrlPath
});

parentApiItem.addMember(apiMethod);
Expand Down Expand Up @@ -808,8 +797,7 @@ export class ApiModelGenerator {
overloadIndex,
excerptTokens,
returnTypeTokenRange,
fileUrlPath,
parent: parentApiItem
fileUrlPath
});

parentApiItem.addMember(apiMethodSignature);
Expand Down Expand Up @@ -837,8 +825,7 @@ export class ApiModelGenerator {
releaseTag,
excerptTokens,
isExported,
fileUrlPath,
parent: parentApiItem
fileUrlPath
});
parentApiItem.addMember(apiNamespace);
}
Expand Down Expand Up @@ -901,8 +888,7 @@ export class ApiModelGenerator {
excerptTokens,
propertyTypeTokenRange,
initializerTokenRange,
fileUrlPath,
parent: parentApiItem
fileUrlPath
});
parentApiItem.addMember(apiProperty);
} else {
Expand Down Expand Up @@ -947,8 +933,7 @@ export class ApiModelGenerator {
excerptTokens,
propertyTypeTokenRange,
isReadonly,
fileUrlPath,
parent: parentApiItem
fileUrlPath
});

parentApiItem.addMember(apiPropertySignature);
Expand Down Expand Up @@ -995,8 +980,7 @@ export class ApiModelGenerator {
excerptTokens,
typeTokenRange,
isExported,
fileUrlPath,
parent: parentApiItem
fileUrlPath
});

parentApiItem.addMember(apiTypeAlias);
Expand Down Expand Up @@ -1041,8 +1025,7 @@ export class ApiModelGenerator {
initializerTokenRange,
isReadonly,
isExported,
fileUrlPath,
parent: parentApiItem
fileUrlPath
});

parentApiItem.addMember(apiVariable);
Expand Down
2 changes: 1 addition & 1 deletion apps/api-extractor/src/schemas/api-extractor-template.json
Expand Up @@ -226,7 +226,7 @@
* 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.
* Can be omitted if you don't need source code links in your API documentation reference.
*
* SUPPORTED TOKENS: none
* DEFAULT VALUE: ""
Expand Down
2 changes: 1 addition & 1 deletion apps/api-extractor/src/schemas/api-extractor.schema.json
Expand Up @@ -108,7 +108,7 @@
"type": "boolean"
},
"projectFolderUrl": {
"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.",
"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.",
"type": "string"
}
},
Expand Down
2 changes: 0 additions & 2 deletions common/reviews/api/api-extractor-model.api.md
Expand Up @@ -752,8 +752,6 @@ export interface IApiDeclaredItemOptions extends IApiDocumentedItemOptions {
excerptTokens: IExcerptToken[];
// (undocumented)
fileUrlPath?: string;
// (undocumented)
parent?: ApiItemContainerMixin;
}

// @public
Expand Down
18 changes: 6 additions & 12 deletions libraries/api-extractor-model/src/items/ApiDeclaredItem.ts
Expand Up @@ -6,15 +6,13 @@ import { ApiDocumentedItem, IApiDocumentedItemJson, IApiDocumentedItemOptions }
import { Excerpt, ExcerptToken, IExcerptTokenRange, IExcerptToken } from '../mixins/Excerpt';
import { DeserializerContext } from '../model/DeserializerContext';
import { SourceLocation } from '../model/SourceLocation';
import { ApiItemContainerMixin } from '../mixins/ApiItemContainerMixin';

/**
* Constructor options for {@link ApiDeclaredItem}.
* @public
*/
export interface IApiDeclaredItemOptions extends IApiDocumentedItemOptions {
excerptTokens: IExcerptToken[];
parent?: ApiItemContainerMixin;
fileUrlPath?: string;
}

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

const projectFolderUrl: string | undefined = this.getAssociatedPackage()?.projectFolderUrl;
const fileUrlPath: string | undefined =
options.parent instanceof ApiDeclaredItem
? options.fileUrlPath || options.parent.sourceLocation.fileUrlPath
: options.fileUrlPath;
const fileUrlPath: string | undefined = options.fileUrlPath || this._parentSourceLocation?.fileUrlPath;

this._sourceLocation = new SourceLocation({
projectFolderUrl: projectFolderUrl,
Expand Down Expand Up @@ -140,16 +135,11 @@ export class ApiDeclaredItem extends ApiDocumentedItem {
return excerptToken;
});

let parentSourceLocation: SourceLocation | undefined;
if (this.parent instanceof ApiDeclaredItem) {
parentSourceLocation = this.parent.sourceLocation;
}

// Only serialize this API item's file URL path if it exists and it's different from its parent's
// (a little optimization to keep the doc model succinct).
if (
this._sourceLocation.fileUrlPath &&
this._sourceLocation.fileUrlPath !== parentSourceLocation?.fileUrlPath
this._sourceLocation.fileUrlPath !== this._parentSourceLocation?.fileUrlPath
) {
jsonObject.fileUrlPath = this._sourceLocation.fileUrlPath;
}
Expand All @@ -161,4 +151,8 @@ export class ApiDeclaredItem extends ApiDocumentedItem {
public buildExcerpt(tokenRange: IExcerptTokenRange): Excerpt {
return new Excerpt(this.excerptTokens, tokenRange);
}

private get _parentSourceLocation(): SourceLocation | undefined {
return this.parent instanceof ApiDeclaredItem ? this.parent.sourceLocation : undefined;
}
}

0 comments on commit 1361612

Please sign in to comment.