62 lines
2.8 KiB
JavaScript
62 lines
2.8 KiB
JavaScript
|
"use strict";
|
||
|
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
||
|
// See LICENSE in the project root for license information.
|
||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||
|
exports.ApiFunction = void 0;
|
||
|
const DeclarationReference_1 = require("@microsoft/tsdoc/lib-commonjs/beta/DeclarationReference");
|
||
|
const ApiItem_1 = require("../items/ApiItem");
|
||
|
const ApiDeclaredItem_1 = require("../items/ApiDeclaredItem");
|
||
|
const ApiParameterListMixin_1 = require("../mixins/ApiParameterListMixin");
|
||
|
const ApiReleaseTagMixin_1 = require("../mixins/ApiReleaseTagMixin");
|
||
|
const ApiReturnTypeMixin_1 = require("../mixins/ApiReturnTypeMixin");
|
||
|
const ApiNameMixin_1 = require("../mixins/ApiNameMixin");
|
||
|
const ApiTypeParameterListMixin_1 = require("../mixins/ApiTypeParameterListMixin");
|
||
|
const ApiExportedMixin_1 = require("../mixins/ApiExportedMixin");
|
||
|
/**
|
||
|
* Represents a TypeScript function declaration.
|
||
|
*
|
||
|
* @remarks
|
||
|
*
|
||
|
* This is part of the {@link ApiModel} hierarchy of classes, which are serializable representations of
|
||
|
* API declarations.
|
||
|
*
|
||
|
* `ApiFunction` represents a TypeScript declaration such as this example:
|
||
|
*
|
||
|
* ```ts
|
||
|
* export function getAverage(x: number, y: number): number {
|
||
|
* return (x + y) / 2.0;
|
||
|
* }
|
||
|
* ```
|
||
|
*
|
||
|
* Functions are exported by an entry point module or by a namespace. Compare with {@link ApiMethod}, which
|
||
|
* represents a function that is a member of a class.
|
||
|
*
|
||
|
* @public
|
||
|
*/
|
||
|
class ApiFunction extends (0, ApiNameMixin_1.ApiNameMixin)((0, ApiTypeParameterListMixin_1.ApiTypeParameterListMixin)((0, ApiParameterListMixin_1.ApiParameterListMixin)((0, ApiReleaseTagMixin_1.ApiReleaseTagMixin)((0, ApiReturnTypeMixin_1.ApiReturnTypeMixin)((0, ApiExportedMixin_1.ApiExportedMixin)(ApiDeclaredItem_1.ApiDeclaredItem)))))) {
|
||
|
constructor(options) {
|
||
|
super(options);
|
||
|
}
|
||
|
static getContainerKey(name, overloadIndex) {
|
||
|
return `${name}|${ApiItem_1.ApiItemKind.Function}|${overloadIndex}`;
|
||
|
}
|
||
|
/** @override */
|
||
|
get kind() {
|
||
|
return ApiItem_1.ApiItemKind.Function;
|
||
|
}
|
||
|
/** @override */
|
||
|
get containerKey() {
|
||
|
return ApiFunction.getContainerKey(this.name, this.overloadIndex);
|
||
|
}
|
||
|
/** @beta @override */
|
||
|
buildCanonicalReference() {
|
||
|
const nameComponent = DeclarationReference_1.DeclarationReference.parseComponent(this.name);
|
||
|
const navigation = this.isExported ? "." /* Navigation.Exports */ : "~" /* Navigation.Locals */;
|
||
|
return (this.parent ? this.parent.canonicalReference : DeclarationReference_1.DeclarationReference.empty())
|
||
|
.addNavigationStep(navigation, nameComponent)
|
||
|
.withMeaning("function" /* Meaning.Function */)
|
||
|
.withOverloadIndex(this.overloadIndex);
|
||
|
}
|
||
|
}
|
||
|
exports.ApiFunction = ApiFunction;
|
||
|
//# sourceMappingURL=ApiFunction.js.map
|