@microsoft/api-extractor-model 7.14.0 → 7.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.json +12 -0
- package/CHANGELOG.md +8 -1
- package/dist/rollup.d.ts +2 -2
- package/dist/tsdoc-metadata.json +1 -1
- package/lib/index.js +3 -1
- package/lib/index.js.map +1 -1
- package/lib/items/ApiItem.d.ts +1 -1
- package/lib/items/ApiItem.d.ts.map +1 -1
- package/lib/items/ApiItem.js +43 -14
- package/lib/items/ApiItem.js.map +1 -1
- package/lib/mixins/Excerpt.d.ts +1 -1
- package/lib/mixins/Excerpt.d.ts.map +1 -1
- package/lib/mixins/Excerpt.js +13 -1
- package/lib/mixins/Excerpt.js.map +1 -1
- package/lib/model/ApiCallSignature.js +3 -2
- package/lib/model/ApiCallSignature.js.map +1 -1
- package/lib/model/ApiClass.js +3 -2
- package/lib/model/ApiClass.js.map +1 -1
- package/lib/model/ApiConstructSignature.js +3 -2
- package/lib/model/ApiConstructSignature.js.map +1 -1
- package/lib/model/ApiConstructor.js +3 -2
- package/lib/model/ApiConstructor.js.map +1 -1
- package/lib/model/ApiEntryPoint.js +1 -1
- package/lib/model/ApiEntryPoint.js.map +1 -1
- package/lib/model/ApiEnum.js +4 -3
- package/lib/model/ApiEnum.js.map +1 -1
- package/lib/model/ApiEnumMember.js +2 -1
- package/lib/model/ApiEnumMember.js.map +1 -1
- package/lib/model/ApiFunction.js +3 -2
- package/lib/model/ApiFunction.js.map +1 -1
- package/lib/model/ApiIndexSignature.js +3 -2
- package/lib/model/ApiIndexSignature.js.map +1 -1
- package/lib/model/ApiInterface.js +3 -2
- package/lib/model/ApiInterface.js.map +1 -1
- package/lib/model/ApiMethod.js +4 -3
- package/lib/model/ApiMethod.js.map +1 -1
- package/lib/model/ApiMethodSignature.js +3 -2
- package/lib/model/ApiMethodSignature.js.map +1 -1
- package/lib/model/ApiModel.js +2 -2
- package/lib/model/ApiModel.js.map +1 -1
- package/lib/model/ApiNamespace.js +3 -2
- package/lib/model/ApiNamespace.js.map +1 -1
- package/lib/model/ApiPackage.js +2 -2
- package/lib/model/ApiPackage.js.map +1 -1
- package/lib/model/ApiProperty.js +4 -3
- package/lib/model/ApiProperty.js.map +1 -1
- package/lib/model/ApiPropertySignature.js +3 -2
- package/lib/model/ApiPropertySignature.js.map +1 -1
- package/lib/model/ApiTypeAlias.js +3 -2
- package/lib/model/ApiTypeAlias.js.map +1 -1
- package/lib/model/ApiVariable.js +3 -2
- package/lib/model/ApiVariable.js.map +1 -1
- package/lib/model/Deserializer.js +20 -19
- package/lib/model/Deserializer.js.map +1 -1
- package/lib/model/ModelReferenceResolver.js +8 -7
- package/lib/model/ModelReferenceResolver.js.map +1 -1
- package/package.json +4 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApiEntryPoint.js","sourceRoot":"","sources":["../../src/model/ApiEntryPoint.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,kGAA+F;AAC/F,8CAAwD;AACxD,2EAAuG;AACvG,yDAA4E;AAC5E,6CAA0C;AAQ1C;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAa,aAAc,SAAQ,IAAA,6CAAqB,EAAC,IAAA,2BAAY,EAAC,iBAAO,CAAC,CAAC;IAC7E,YAAmB,OAA8B;QAC/C,KAAK,CAAC,OAAO,CAAC,CAAC;IACjB,CAAC;IAED,gBAAgB;IAChB,IAAW,IAAI;QACb,
|
|
1
|
+
{"version":3,"file":"ApiEntryPoint.js","sourceRoot":"","sources":["../../src/model/ApiEntryPoint.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,kGAA+F;AAC/F,8CAAwD;AACxD,2EAAuG;AACvG,yDAA4E;AAC5E,6CAA0C;AAQ1C;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAa,aAAc,SAAQ,IAAA,6CAAqB,EAAC,IAAA,2BAAY,EAAC,iBAAO,CAAC,CAAC;IAC7E,YAAmB,OAA8B;QAC/C,KAAK,CAAC,OAAO,CAAC,CAAC;IACjB,CAAC;IAED,gBAAgB;IAChB,IAAW,IAAI;QACb,OAAO,qBAAW,CAAC,UAAU,CAAC;IAChC,CAAC;IAED,gBAAgB;IAChB,IAAW,YAAY;QACrB,uFAAuF;QACvF,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IAED;;;;;;;;;;;OAWG;IACH,IAAW,UAAU;QACnB,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IAED,sBAAsB;IACf,uBAAuB;QAC5B,IAAI,IAAI,CAAC,MAAM,YAAY,uBAAU,EAAE;YACrC,OAAO,2CAAoB,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;SACxE;QAED,OAAO,2CAAoB,CAAC,KAAK,EAAE,CAAC;IACtC,CAAC;CACF;AAxCD,sCAwCC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport { DeclarationReference } from '@microsoft/tsdoc/lib-commonjs/beta/DeclarationReference';\r\nimport { ApiItem, ApiItemKind } from '../items/ApiItem';\r\nimport { ApiItemContainerMixin, IApiItemContainerMixinOptions } from '../mixins/ApiItemContainerMixin';\r\nimport { IApiNameMixinOptions, ApiNameMixin } from '../mixins/ApiNameMixin';\r\nimport { ApiPackage } from './ApiPackage';\r\n\r\n/**\r\n * Constructor options for {@link ApiEntryPoint}.\r\n * @public\r\n */\r\nexport interface IApiEntryPointOptions extends IApiItemContainerMixinOptions, IApiNameMixinOptions {}\r\n\r\n/**\r\n * Represents the entry point for an NPM package.\r\n *\r\n * @remarks\r\n *\r\n * This is part of the {@link ApiModel} hierarchy of classes, which are serializable representations of\r\n * API declarations.\r\n *\r\n * `ApiEntryPoint` represents the entry point to an NPM package. API Extractor does not currently support\r\n * analysis of multiple entry points, but the `ApiEntryPoint` object is included to support a future feature.\r\n * In the current implementation, `ApiEntryPoint.importPath` is always the empty string.\r\n *\r\n * For example, suppose the package.json file looks like this:\r\n *\r\n * ```json\r\n * {\r\n * \"name\": \"example-library\",\r\n * \"version\": \"1.0.0\",\r\n * \"main\": \"./lib/index.js\",\r\n * \"typings\": \"./lib/index.d.ts\"\r\n * }\r\n * ```\r\n *\r\n * In this example, the `ApiEntryPoint` would represent the TypeScript module for `./lib/index.js`.\r\n *\r\n * @public\r\n */\r\nexport class ApiEntryPoint extends ApiItemContainerMixin(ApiNameMixin(ApiItem)) {\r\n public constructor(options: IApiEntryPointOptions) {\r\n super(options);\r\n }\r\n\r\n /** @override */\r\n public get kind(): ApiItemKind {\r\n return ApiItemKind.EntryPoint;\r\n }\r\n\r\n /** @override */\r\n public get containerKey(): string {\r\n // No prefix needed, because ApiEntryPoint is the only possible member of an ApiPackage\r\n return this.name;\r\n }\r\n\r\n /**\r\n * The module path for this entry point, relative to the parent `ApiPackage`. In the current implementation,\r\n * this is always the empty string, indicating the default entry point.\r\n *\r\n * @remarks\r\n *\r\n * API Extractor does not currently support analysis of multiple entry points. If that feature is implemented\r\n * in the future, then the `ApiEntryPoint.importPath` will be used to distinguish different entry points,\r\n * for example: `controls/Button` in `import { Button } from \"example-package/controls/Button\";`.\r\n *\r\n * The `ApiEntryPoint.name` property stores the same value as `ApiEntryPoint.importPath`.\r\n */\r\n public get importPath(): string {\r\n return this.name;\r\n }\r\n\r\n /** @beta @override */\r\n public buildCanonicalReference(): DeclarationReference {\r\n if (this.parent instanceof ApiPackage) {\r\n return DeclarationReference.package(this.parent.name, this.importPath);\r\n }\r\n\r\n return DeclarationReference.empty();\r\n }\r\n}\r\n"]}
|
package/lib/model/ApiEnum.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.ApiEnum = void 0;
|
|
6
6
|
const DeclarationReference_1 = require("@microsoft/tsdoc/lib-commonjs/beta/DeclarationReference");
|
|
7
|
+
const ApiItem_1 = require("../items/ApiItem");
|
|
7
8
|
const ApiDeclaredItem_1 = require("../items/ApiDeclaredItem");
|
|
8
9
|
const ApiReleaseTagMixin_1 = require("../mixins/ApiReleaseTagMixin");
|
|
9
10
|
const ApiItemContainerMixin_1 = require("../mixins/ApiItemContainerMixin");
|
|
@@ -33,11 +34,11 @@ class ApiEnum extends (0, ApiItemContainerMixin_1.ApiItemContainerMixin)((0, Api
|
|
|
33
34
|
super(options);
|
|
34
35
|
}
|
|
35
36
|
static getContainerKey(name) {
|
|
36
|
-
return `${name}|${
|
|
37
|
+
return `${name}|${ApiItem_1.ApiItemKind.Enum}`;
|
|
37
38
|
}
|
|
38
39
|
/** @override */
|
|
39
40
|
get kind() {
|
|
40
|
-
return
|
|
41
|
+
return ApiItem_1.ApiItemKind.Enum;
|
|
41
42
|
}
|
|
42
43
|
/** @override */
|
|
43
44
|
get members() {
|
|
@@ -49,7 +50,7 @@ class ApiEnum extends (0, ApiItemContainerMixin_1.ApiItemContainerMixin)((0, Api
|
|
|
49
50
|
}
|
|
50
51
|
/** @override */
|
|
51
52
|
addMember(member) {
|
|
52
|
-
if (member.kind !==
|
|
53
|
+
if (member.kind !== ApiItem_1.ApiItemKind.EnumMember) {
|
|
53
54
|
throw new Error('Only ApiEnumMember objects can be added to an ApiEnum');
|
|
54
55
|
}
|
|
55
56
|
super.addMember(member);
|
package/lib/model/ApiEnum.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApiEnum.js","sourceRoot":"","sources":["../../src/model/ApiEnum.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,kGAKiE;
|
|
1
|
+
{"version":3,"file":"ApiEnum.js","sourceRoot":"","sources":["../../src/model/ApiEnum.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,kGAK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","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport {\r\n DeclarationReference,\r\n Meaning,\r\n Navigation,\r\n Component\r\n} from '@microsoft/tsdoc/lib-commonjs/beta/DeclarationReference';\r\nimport { ApiItemKind } from '../items/ApiItem';\r\nimport { ApiDeclaredItem, IApiDeclaredItemOptions } from '../items/ApiDeclaredItem';\r\nimport { ApiReleaseTagMixin, IApiReleaseTagMixinOptions } from '../mixins/ApiReleaseTagMixin';\r\nimport { ApiItemContainerMixin, IApiItemContainerMixinOptions } from '../mixins/ApiItemContainerMixin';\r\nimport { ApiEnumMember } from './ApiEnumMember';\r\nimport { IApiNameMixinOptions, ApiNameMixin } from '../mixins/ApiNameMixin';\r\n\r\n/**\r\n * Constructor options for {@link ApiEnum}.\r\n * @public\r\n */\r\nexport interface IApiEnumOptions\r\n extends IApiItemContainerMixinOptions,\r\n IApiNameMixinOptions,\r\n IApiReleaseTagMixinOptions,\r\n IApiDeclaredItemOptions {}\r\n\r\n/**\r\n * Represents a TypeScript enum declaration.\r\n *\r\n * @remarks\r\n *\r\n * This is part of the {@link ApiModel} hierarchy of classes, which are serializable representations of\r\n * API declarations.\r\n *\r\n * `ApiEnum` represents an enum declaration such as `FontSizes` in the example below:\r\n *\r\n * ```ts\r\n * export enum FontSizes {\r\n * Small = 100,\r\n * Medium = 200,\r\n * Large = 300\r\n * }\r\n * ```\r\n *\r\n * @public\r\n */\r\nexport class ApiEnum extends ApiItemContainerMixin(ApiNameMixin(ApiReleaseTagMixin(ApiDeclaredItem))) {\r\n public constructor(options: IApiEnumOptions) {\r\n super(options);\r\n }\r\n\r\n public static getContainerKey(name: string): string {\r\n return `${name}|${ApiItemKind.Enum}`;\r\n }\r\n\r\n /** @override */\r\n public get kind(): ApiItemKind {\r\n return ApiItemKind.Enum;\r\n }\r\n\r\n /** @override */\r\n public get members(): ReadonlyArray<ApiEnumMember> {\r\n return super.members as ReadonlyArray<ApiEnumMember>;\r\n }\r\n\r\n /** @override */\r\n public get containerKey(): string {\r\n return ApiEnum.getContainerKey(this.name);\r\n }\r\n\r\n /** @override */\r\n public addMember(member: ApiEnumMember): void {\r\n if (member.kind !== ApiItemKind.EnumMember) {\r\n throw new Error('Only ApiEnumMember objects can be added to an ApiEnum');\r\n }\r\n super.addMember(member);\r\n }\r\n\r\n /** @beta @override */\r\n public buildCanonicalReference(): DeclarationReference {\r\n const nameComponent: Component = DeclarationReference.parseComponent(this.name);\r\n return (this.parent ? this.parent.canonicalReference : DeclarationReference.empty())\r\n .addNavigationStep(Navigation.Exports, nameComponent)\r\n .withMeaning(Meaning.Enum);\r\n }\r\n}\r\n"]}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.ApiEnumMember = void 0;
|
|
6
6
|
const DeclarationReference_1 = require("@microsoft/tsdoc/lib-commonjs/beta/DeclarationReference");
|
|
7
|
+
const ApiItem_1 = require("../items/ApiItem");
|
|
7
8
|
const ApiDeclaredItem_1 = require("../items/ApiDeclaredItem");
|
|
8
9
|
const ApiReleaseTagMixin_1 = require("../mixins/ApiReleaseTagMixin");
|
|
9
10
|
const ApiNameMixin_1 = require("../mixins/ApiNameMixin");
|
|
@@ -43,7 +44,7 @@ class ApiEnumMember extends (0, ApiNameMixin_1.ApiNameMixin)((0, ApiReleaseTagMi
|
|
|
43
44
|
}
|
|
44
45
|
/** @override */
|
|
45
46
|
get kind() {
|
|
46
|
-
return
|
|
47
|
+
return ApiItem_1.ApiItemKind.EnumMember;
|
|
47
48
|
}
|
|
48
49
|
/** @override */
|
|
49
50
|
get containerKey() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApiEnumMember.js","sourceRoot":"","sources":["../../src/model/ApiEnumMember.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,kGAKiE;
|
|
1
|
+
{"version":3,"file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C,CAAC;QAChF,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC,CAAC,2CAAoB,CAAC,KAAK,EAAE,CAAC;aACjF,iBAAiB,oBAAqB,aAAa,CAAC;aACpD,WAAW,uBAAgB,CAAC;IACjC,CAAC;CACF;AApDD,sCAoDC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport {\r\n DeclarationReference,\r\n Meaning,\r\n Navigation,\r\n Component\r\n} from '@microsoft/tsdoc/lib-commonjs/beta/DeclarationReference';\r\nimport { ApiItemKind } from '../items/ApiItem';\r\nimport { ApiDeclaredItem, IApiDeclaredItemOptions, IApiDeclaredItemJson } from '../items/ApiDeclaredItem';\r\nimport { ApiReleaseTagMixin, IApiReleaseTagMixinOptions } from '../mixins/ApiReleaseTagMixin';\r\nimport { Excerpt, IExcerptTokenRange } from '../mixins/Excerpt';\r\nimport { IApiNameMixinOptions, ApiNameMixin } from '../mixins/ApiNameMixin';\r\nimport { DeserializerContext } from './DeserializerContext';\r\n\r\n/**\r\n * Constructor options for {@link ApiEnumMember}.\r\n * @public\r\n */\r\nexport interface IApiEnumMemberOptions\r\n extends IApiNameMixinOptions,\r\n IApiReleaseTagMixinOptions,\r\n IApiDeclaredItemOptions {\r\n initializerTokenRange: IExcerptTokenRange;\r\n}\r\n\r\nexport interface IApiEnumMemberJson extends IApiDeclaredItemJson {\r\n initializerTokenRange: IExcerptTokenRange;\r\n}\r\n\r\n/**\r\n * Represents a member of a TypeScript enum declaration.\r\n *\r\n * @remarks\r\n *\r\n * This is part of the {@link ApiModel} hierarchy of classes, which are serializable representations of\r\n * API declarations.\r\n *\r\n * `ApiEnumMember` represents an enum member such as `Small = 100` in the example below:\r\n *\r\n * ```ts\r\n * export enum FontSizes {\r\n * Small = 100,\r\n * Medium = 200,\r\n * Large = 300\r\n * }\r\n * ```\r\n *\r\n * @public\r\n */\r\nexport class ApiEnumMember extends ApiNameMixin(ApiReleaseTagMixin(ApiDeclaredItem)) {\r\n /**\r\n * An {@link Excerpt} that describes the value of the enum member.\r\n */\r\n public readonly initializerExcerpt: Excerpt;\r\n\r\n public constructor(options: IApiEnumMemberOptions) {\r\n super(options);\r\n\r\n this.initializerExcerpt = this.buildExcerpt(options.initializerTokenRange);\r\n }\r\n\r\n public static getContainerKey(name: string): string {\r\n // No prefix needed, because ApiEnumMember is the only possible member of an ApiEnum\r\n return name;\r\n }\r\n\r\n /** @override */\r\n public static onDeserializeInto(\r\n options: Partial<IApiEnumMemberOptions>,\r\n context: DeserializerContext,\r\n jsonObject: IApiEnumMemberJson\r\n ): void {\r\n super.onDeserializeInto(options, context, jsonObject);\r\n\r\n options.initializerTokenRange = jsonObject.initializerTokenRange;\r\n }\r\n\r\n /** @override */\r\n public get kind(): ApiItemKind {\r\n return ApiItemKind.EnumMember;\r\n }\r\n\r\n /** @override */\r\n public get containerKey(): string {\r\n return ApiEnumMember.getContainerKey(this.name);\r\n }\r\n\r\n /** @override */\r\n public serializeInto(jsonObject: Partial<IApiEnumMemberJson>): void {\r\n super.serializeInto(jsonObject);\r\n\r\n jsonObject.initializerTokenRange = this.initializerExcerpt.tokenRange;\r\n }\r\n\r\n /** @beta @override */\r\n public buildCanonicalReference(): DeclarationReference {\r\n const nameComponent: Component = DeclarationReference.parseComponent(this.name);\r\n return (this.parent ? this.parent.canonicalReference : DeclarationReference.empty())\r\n .addNavigationStep(Navigation.Exports, nameComponent)\r\n .withMeaning(Meaning.Member);\r\n }\r\n}\r\n"]}
|
package/lib/model/ApiFunction.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.ApiFunction = void 0;
|
|
6
6
|
const DeclarationReference_1 = require("@microsoft/tsdoc/lib-commonjs/beta/DeclarationReference");
|
|
7
|
+
const ApiItem_1 = require("../items/ApiItem");
|
|
7
8
|
const ApiDeclaredItem_1 = require("../items/ApiDeclaredItem");
|
|
8
9
|
const ApiParameterListMixin_1 = require("../mixins/ApiParameterListMixin");
|
|
9
10
|
const ApiReleaseTagMixin_1 = require("../mixins/ApiReleaseTagMixin");
|
|
@@ -36,11 +37,11 @@ class ApiFunction extends (0, ApiNameMixin_1.ApiNameMixin)((0, ApiTypeParameterL
|
|
|
36
37
|
super(options);
|
|
37
38
|
}
|
|
38
39
|
static getContainerKey(name, overloadIndex) {
|
|
39
|
-
return `${name}|${
|
|
40
|
+
return `${name}|${ApiItem_1.ApiItemKind.Function}|${overloadIndex}`;
|
|
40
41
|
}
|
|
41
42
|
/** @override */
|
|
42
43
|
get kind() {
|
|
43
|
-
return
|
|
44
|
+
return ApiItem_1.ApiItemKind.Function;
|
|
44
45
|
}
|
|
45
46
|
/** @override */
|
|
46
47
|
get containerKey() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApiFunction.js","sourceRoot":"","sources":["../../src/model/ApiFunction.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,kGAKiE;
|
|
1
|
+
{"version":3,"file":"ApiFunction.js","sourceRoot":"","sources":["../../src/model/ApiFunction.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,kGAKiE;AACjE,8CAA+C;AAC/C,8DAAoF;AACpF,2EAAuG;AACvG,qEAA8F;AAC9F,qEAA8F;AAC9F,yDAA4E;AAC5E,mFAG6C;AAc7C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAa,WAAY,SAAQ,IAAA,2BAAY,EAC3C,IAAA,qDAAyB,EAAC,IAAA,6CAAqB,EAAC,IAAA,uCAAkB,EAAC,IAAA,uCAAkB,EAAC,iCAAe,CAAC,CAAC,CAAC,CAAC,CAC1G;IACC,YAAmB,OAA4B;QAC7C,KAAK,CAAC,OAAO,CAAC,CAAC;IACjB,CAAC;IAEM,MAAM,CAAC,eAAe,CAAC,IAAY,EAAE,aAAqB;QAC/D,OAAO,GAAG,IAAI,IAAI,qBAAW,CAAC,QAAQ,IAAI,aAAa,EAAE,CAAC;IAC5D,CAAC;IAED,gBAAgB;IAChB,IAAW,IAAI;QACb,OAAO,qBAAW,CAAC,QAAQ,CAAC;IAC9B,CAAC;IAED,gBAAgB;IAChB,IAAW,YAAY;QACrB,OAAO,WAAW,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;IACpE,CAAC;IAED,sBAAsB;IACf,uBAAuB;QAC5B,MAAM,aAAa,GAAc,2CAAoB,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAChF,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC,CAAC,2CAAoB,CAAC,KAAK,EAAE,CAAC;aACjF,iBAAiB,oBAAqB,aAAa,CAAC;aACpD,WAAW,2BAAkB;aAC7B,iBAAiB,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAC3C,CAAC;CACF;AA7BD,kCA6BC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport {\r\n DeclarationReference,\r\n Meaning,\r\n Navigation,\r\n Component\r\n} from '@microsoft/tsdoc/lib-commonjs/beta/DeclarationReference';\r\nimport { ApiItemKind } from '../items/ApiItem';\r\nimport { IApiDeclaredItemOptions, ApiDeclaredItem } from '../items/ApiDeclaredItem';\r\nimport { IApiParameterListMixinOptions, ApiParameterListMixin } from '../mixins/ApiParameterListMixin';\r\nimport { IApiReleaseTagMixinOptions, ApiReleaseTagMixin } from '../mixins/ApiReleaseTagMixin';\r\nimport { IApiReturnTypeMixinOptions, ApiReturnTypeMixin } from '../mixins/ApiReturnTypeMixin';\r\nimport { IApiNameMixinOptions, ApiNameMixin } from '../mixins/ApiNameMixin';\r\nimport {\r\n IApiTypeParameterListMixinOptions,\r\n ApiTypeParameterListMixin\r\n} from '../mixins/ApiTypeParameterListMixin';\r\n\r\n/**\r\n * Constructor options for {@link ApiFunction}.\r\n * @public\r\n */\r\nexport interface IApiFunctionOptions\r\n extends IApiNameMixinOptions,\r\n IApiTypeParameterListMixinOptions,\r\n IApiParameterListMixinOptions,\r\n IApiReleaseTagMixinOptions,\r\n IApiReturnTypeMixinOptions,\r\n IApiDeclaredItemOptions {}\r\n\r\n/**\r\n * Represents a TypeScript function declaration.\r\n *\r\n * @remarks\r\n *\r\n * This is part of the {@link ApiModel} hierarchy of classes, which are serializable representations of\r\n * API declarations.\r\n *\r\n * `ApiFunction` represents a TypeScript declaration such as this example:\r\n *\r\n * ```ts\r\n * export function getAverage(x: number, y: number): number {\r\n * return (x + y) / 2.0;\r\n * }\r\n * ```\r\n *\r\n * Functions are exported by an entry point module or by a namespace. Compare with {@link ApiMethod}, which\r\n * represents a function that is a member of a class.\r\n *\r\n * @public\r\n */\r\nexport class ApiFunction extends ApiNameMixin(\r\n ApiTypeParameterListMixin(ApiParameterListMixin(ApiReleaseTagMixin(ApiReturnTypeMixin(ApiDeclaredItem))))\r\n) {\r\n public constructor(options: IApiFunctionOptions) {\r\n super(options);\r\n }\r\n\r\n public static getContainerKey(name: string, overloadIndex: number): string {\r\n return `${name}|${ApiItemKind.Function}|${overloadIndex}`;\r\n }\r\n\r\n /** @override */\r\n public get kind(): ApiItemKind {\r\n return ApiItemKind.Function;\r\n }\r\n\r\n /** @override */\r\n public get containerKey(): string {\r\n return ApiFunction.getContainerKey(this.name, this.overloadIndex);\r\n }\r\n\r\n /** @beta @override */\r\n public buildCanonicalReference(): DeclarationReference {\r\n const nameComponent: Component = DeclarationReference.parseComponent(this.name);\r\n return (this.parent ? this.parent.canonicalReference : DeclarationReference.empty())\r\n .addNavigationStep(Navigation.Exports, nameComponent)\r\n .withMeaning(Meaning.Function)\r\n .withOverloadIndex(this.overloadIndex);\r\n }\r\n}\r\n"]}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.ApiIndexSignature = void 0;
|
|
6
6
|
const DeclarationReference_1 = require("@microsoft/tsdoc/lib-commonjs/beta/DeclarationReference");
|
|
7
|
+
const ApiItem_1 = require("../items/ApiItem");
|
|
7
8
|
const ApiDeclaredItem_1 = require("../items/ApiDeclaredItem");
|
|
8
9
|
const ApiParameterListMixin_1 = require("../mixins/ApiParameterListMixin");
|
|
9
10
|
const ApiReleaseTagMixin_1 = require("../mixins/ApiReleaseTagMixin");
|
|
@@ -35,11 +36,11 @@ class ApiIndexSignature extends (0, ApiParameterListMixin_1.ApiParameterListMixi
|
|
|
35
36
|
super(options);
|
|
36
37
|
}
|
|
37
38
|
static getContainerKey(overloadIndex) {
|
|
38
|
-
return `|${
|
|
39
|
+
return `|${ApiItem_1.ApiItemKind.IndexSignature}|${overloadIndex}`;
|
|
39
40
|
}
|
|
40
41
|
/** @override */
|
|
41
42
|
get kind() {
|
|
42
|
-
return
|
|
43
|
+
return ApiItem_1.ApiItemKind.IndexSignature;
|
|
43
44
|
}
|
|
44
45
|
/** @override */
|
|
45
46
|
get containerKey() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApiIndexSignature.js","sourceRoot":"","sources":["../../src/model/ApiIndexSignature.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,kGAIiE;
|
|
1
|
+
{"version":3,"file":"ApiIndexSignature.js","sourceRoot":"","sources":["../../src/model/ApiIndexSignature.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,kGAIiE;AACjE,8CAA+C;AAC/C,8DAAoF;AACpF,2EAAuG;AACvG,qEAA8F;AAC9F,qEAA8F;AAY9F;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAa,iBAAkB,SAAQ,IAAA,6CAAqB,EAC1D,IAAA,uCAAkB,EAAC,IAAA,uCAAkB,EAAC,iCAAe,CAAC,CAAC,CACxD;IACC,YAAmB,OAAkC;QACnD,KAAK,CAAC,OAAO,CAAC,CAAC;IACjB,CAAC;IAEM,MAAM,CAAC,eAAe,CAAC,aAAqB;QACjD,OAAO,IAAI,qBAAW,CAAC,cAAc,IAAI,aAAa,EAAE,CAAC;IAC3D,CAAC;IAED,gBAAgB;IAChB,IAAW,IAAI;QACb,OAAO,qBAAW,CAAC,cAAc,CAAC;IACpC,CAAC;IAED,gBAAgB;IAChB,IAAW,YAAY;QACrB,OAAO,iBAAiB,CAAC,eAAe,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAC/D,CAAC;IAED,sBAAsB;IACf,uBAAuB;QAC5B,MAAM,MAAM,GAAyB,IAAI,CAAC,MAAM;YAC9C,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,kBAAkB;YAChC,CAAC,CAAC,iDAAiD;gBACjD,2CAAoB,CAAC,KAAK,EAAE,CAAC,iBAAiB,oBAAqB,UAAU,CAAC,CAAC;QACnF,OAAO,MAAM,CAAC,WAAW,8BAAwB,CAAC,iBAAiB,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAC1F,CAAC;CACF;AA7BD,8CA6BC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport {\r\n DeclarationReference,\r\n Meaning,\r\n Navigation\r\n} from '@microsoft/tsdoc/lib-commonjs/beta/DeclarationReference';\r\nimport { ApiItemKind } from '../items/ApiItem';\r\nimport { IApiDeclaredItemOptions, ApiDeclaredItem } from '../items/ApiDeclaredItem';\r\nimport { IApiParameterListMixinOptions, ApiParameterListMixin } from '../mixins/ApiParameterListMixin';\r\nimport { IApiReleaseTagMixinOptions, ApiReleaseTagMixin } from '../mixins/ApiReleaseTagMixin';\r\nimport { IApiReturnTypeMixinOptions, ApiReturnTypeMixin } from '../mixins/ApiReturnTypeMixin';\r\n\r\n/**\r\n * Constructor options for {@link ApiIndexSignature}.\r\n * @public\r\n */\r\nexport interface IApiIndexSignatureOptions\r\n extends IApiParameterListMixinOptions,\r\n IApiReleaseTagMixinOptions,\r\n IApiReturnTypeMixinOptions,\r\n IApiDeclaredItemOptions {}\r\n\r\n/**\r\n * Represents a TypeScript index signature.\r\n *\r\n * @remarks\r\n *\r\n * This is part of the {@link ApiModel} hierarchy of classes, which are serializable representations of\r\n * API declarations.\r\n *\r\n * `ApiIndexSignature` represents a TypeScript declaration such as `[x: number]: number` in this example:\r\n *\r\n * ```ts\r\n * export interface INumberTable {\r\n * // An index signature\r\n * [value: number]: number;\r\n *\r\n * // An overloaded index signature\r\n * [name: string]: number;\r\n * }\r\n * ```\r\n *\r\n * @public\r\n */\r\nexport class ApiIndexSignature extends ApiParameterListMixin(\r\n ApiReleaseTagMixin(ApiReturnTypeMixin(ApiDeclaredItem))\r\n) {\r\n public constructor(options: IApiIndexSignatureOptions) {\r\n super(options);\r\n }\r\n\r\n public static getContainerKey(overloadIndex: number): string {\r\n return `|${ApiItemKind.IndexSignature}|${overloadIndex}`;\r\n }\r\n\r\n /** @override */\r\n public get kind(): ApiItemKind {\r\n return ApiItemKind.IndexSignature;\r\n }\r\n\r\n /** @override */\r\n public get containerKey(): string {\r\n return ApiIndexSignature.getContainerKey(this.overloadIndex);\r\n }\r\n\r\n /** @beta @override */\r\n public buildCanonicalReference(): DeclarationReference {\r\n const parent: DeclarationReference = this.parent\r\n ? this.parent.canonicalReference\r\n : // .withMeaning() requires some kind of component\r\n DeclarationReference.empty().addNavigationStep(Navigation.Members, '(parent)');\r\n return parent.withMeaning(Meaning.IndexSignature).withOverloadIndex(this.overloadIndex);\r\n }\r\n}\r\n"]}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.ApiInterface = void 0;
|
|
6
6
|
const DeclarationReference_1 = require("@microsoft/tsdoc/lib-commonjs/beta/DeclarationReference");
|
|
7
|
+
const ApiItem_1 = require("../items/ApiItem");
|
|
7
8
|
const ApiItemContainerMixin_1 = require("../mixins/ApiItemContainerMixin");
|
|
8
9
|
const ApiDeclaredItem_1 = require("../items/ApiDeclaredItem");
|
|
9
10
|
const ApiReleaseTagMixin_1 = require("../mixins/ApiReleaseTagMixin");
|
|
@@ -36,7 +37,7 @@ class ApiInterface extends (0, ApiItemContainerMixin_1.ApiItemContainerMixin)((0
|
|
|
36
37
|
}
|
|
37
38
|
}
|
|
38
39
|
static getContainerKey(name) {
|
|
39
|
-
return `${name}|${
|
|
40
|
+
return `${name}|${ApiItem_1.ApiItemKind.Interface}`;
|
|
40
41
|
}
|
|
41
42
|
/** @override */
|
|
42
43
|
static onDeserializeInto(options, context, jsonObject) {
|
|
@@ -45,7 +46,7 @@ class ApiInterface extends (0, ApiItemContainerMixin_1.ApiItemContainerMixin)((0
|
|
|
45
46
|
}
|
|
46
47
|
/** @override */
|
|
47
48
|
get kind() {
|
|
48
|
-
return
|
|
49
|
+
return ApiItem_1.ApiItemKind.Interface;
|
|
49
50
|
}
|
|
50
51
|
/** @override */
|
|
51
52
|
get containerKey() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApiInterface.js","sourceRoot":"","sources":["../../src/model/ApiInterface.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,kGAKiE;
|
|
1
|
+
{"version":3,"file":"ApiInterface.js","sourceRoot":"","sources":["../../src/model/ApiInterface.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,kGAKiE;AACjE,8CAA+C;AAC/C,2EAIyC;AACzC,8DAA0G;AAC1G,qEAIsC;AAEtC,iDAA8C;AAC9C,yDAA+F;AAC/F,mFAI6C;AAyB7C;;;;;;;;;;;;;;;;GAgBG;AACH,MAAa,YAAa,SAAQ,IAAA,6CAAqB,EACrD,IAAA,2BAAY,EAAC,IAAA,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5B,MAAM,aAAa,GAAc,2CAAoB,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAChF,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC,CAAC,2CAAoB,CAAC,KAAK,EAAE,CAAC;aACjF,iBAAiB,oBAAqB,aAAa,CAAC;aACpD,WAAW,6BAAmB,CAAC;IACpC,CAAC;CACF;AA3DD,oCA2DC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport {\r\n DeclarationReference,\r\n Meaning,\r\n Navigation,\r\n Component\r\n} from '@microsoft/tsdoc/lib-commonjs/beta/DeclarationReference';\r\nimport { ApiItemKind } from '../items/ApiItem';\r\nimport {\r\n ApiItemContainerMixin,\r\n IApiItemContainerMixinOptions,\r\n IApiItemContainerJson\r\n} from '../mixins/ApiItemContainerMixin';\r\nimport { ApiDeclaredItem, IApiDeclaredItemOptions, IApiDeclaredItemJson } from '../items/ApiDeclaredItem';\r\nimport {\r\n IApiReleaseTagMixinOptions,\r\n ApiReleaseTagMixin,\r\n IApiReleaseTagMixinJson\r\n} from '../mixins/ApiReleaseTagMixin';\r\nimport { IExcerptTokenRange } from '../mixins/Excerpt';\r\nimport { HeritageType } from './HeritageType';\r\nimport { IApiNameMixinOptions, ApiNameMixin, IApiNameMixinJson } from '../mixins/ApiNameMixin';\r\nimport {\r\n IApiTypeParameterListMixinOptions,\r\n IApiTypeParameterListMixinJson,\r\n ApiTypeParameterListMixin\r\n} from '../mixins/ApiTypeParameterListMixin';\r\nimport { DeserializerContext } from './DeserializerContext';\r\n\r\n/**\r\n * Constructor options for {@link ApiInterface}.\r\n * @public\r\n */\r\nexport interface IApiInterfaceOptions\r\n extends IApiItemContainerMixinOptions,\r\n IApiNameMixinOptions,\r\n IApiTypeParameterListMixinOptions,\r\n IApiReleaseTagMixinOptions,\r\n IApiDeclaredItemOptions {\r\n extendsTokenRanges: IExcerptTokenRange[];\r\n}\r\n\r\nexport interface IApiInterfaceJson\r\n extends IApiItemContainerJson,\r\n IApiNameMixinJson,\r\n IApiTypeParameterListMixinJson,\r\n IApiReleaseTagMixinJson,\r\n IApiDeclaredItemJson {\r\n extendsTokenRanges: IExcerptTokenRange[];\r\n}\r\n\r\n/**\r\n * Represents a TypeScript class declaration.\r\n *\r\n * @remarks\r\n *\r\n * This is part of the {@link ApiModel} hierarchy of classes, which are serializable representations of\r\n * API declarations.\r\n *\r\n * `ApiInterface` represents a TypeScript declaration such as this:\r\n *\r\n * ```ts\r\n * export interface X extends Y {\r\n * }\r\n * ```\r\n *\r\n * @public\r\n */\r\nexport class ApiInterface extends ApiItemContainerMixin(\r\n ApiNameMixin(ApiTypeParameterListMixin(ApiReleaseTagMixin(ApiDeclaredItem)))\r\n) {\r\n private readonly _extendsTypes: HeritageType[] = [];\r\n\r\n public constructor(options: IApiInterfaceOptions) {\r\n super(options);\r\n\r\n for (const extendsTokenRange of options.extendsTokenRanges) {\r\n this._extendsTypes.push(new HeritageType(this.buildExcerpt(extendsTokenRange)));\r\n }\r\n }\r\n\r\n public static getContainerKey(name: string): string {\r\n return `${name}|${ApiItemKind.Interface}`;\r\n }\r\n\r\n /** @override */\r\n public static onDeserializeInto(\r\n options: Partial<IApiInterfaceOptions>,\r\n context: DeserializerContext,\r\n jsonObject: IApiInterfaceJson\r\n ): void {\r\n super.onDeserializeInto(options, context, jsonObject);\r\n\r\n options.extendsTokenRanges = jsonObject.extendsTokenRanges;\r\n }\r\n\r\n /** @override */\r\n public get kind(): ApiItemKind {\r\n return ApiItemKind.Interface;\r\n }\r\n\r\n /** @override */\r\n public get containerKey(): string {\r\n return ApiInterface.getContainerKey(this.name);\r\n }\r\n\r\n /**\r\n * The list of base interfaces that this interface inherits from using the `extends` keyword.\r\n */\r\n public get extendsTypes(): ReadonlyArray<HeritageType> {\r\n return this._extendsTypes;\r\n }\r\n\r\n /** @override */\r\n public serializeInto(jsonObject: Partial<IApiInterfaceJson>): void {\r\n super.serializeInto(jsonObject);\r\n\r\n jsonObject.extendsTokenRanges = this.extendsTypes.map((x) => x.excerpt.tokenRange);\r\n }\r\n\r\n /** @beta @override */\r\n public buildCanonicalReference(): DeclarationReference {\r\n const nameComponent: Component = DeclarationReference.parseComponent(this.name);\r\n return (this.parent ? this.parent.canonicalReference : DeclarationReference.empty())\r\n .addNavigationStep(Navigation.Exports, nameComponent)\r\n .withMeaning(Meaning.Interface);\r\n }\r\n}\r\n"]}
|
package/lib/model/ApiMethod.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.ApiMethod = void 0;
|
|
6
6
|
const DeclarationReference_1 = require("@microsoft/tsdoc/lib-commonjs/beta/DeclarationReference");
|
|
7
|
+
const ApiItem_1 = require("../items/ApiItem");
|
|
7
8
|
const ApiStaticMixin_1 = require("../mixins/ApiStaticMixin");
|
|
8
9
|
const ApiDeclaredItem_1 = require("../items/ApiDeclaredItem");
|
|
9
10
|
const ApiParameterListMixin_1 = require("../mixins/ApiParameterListMixin");
|
|
@@ -39,15 +40,15 @@ class ApiMethod extends (0, ApiNameMixin_1.ApiNameMixin)((0, ApiTypeParameterLis
|
|
|
39
40
|
}
|
|
40
41
|
static getContainerKey(name, isStatic, overloadIndex) {
|
|
41
42
|
if (isStatic) {
|
|
42
|
-
return `${name}|${
|
|
43
|
+
return `${name}|${ApiItem_1.ApiItemKind.Method}|static|${overloadIndex}`;
|
|
43
44
|
}
|
|
44
45
|
else {
|
|
45
|
-
return `${name}|${
|
|
46
|
+
return `${name}|${ApiItem_1.ApiItemKind.Method}|instance|${overloadIndex}`;
|
|
46
47
|
}
|
|
47
48
|
}
|
|
48
49
|
/** @override */
|
|
49
50
|
get kind() {
|
|
50
|
-
return
|
|
51
|
+
return ApiItem_1.ApiItemKind.Method;
|
|
51
52
|
}
|
|
52
53
|
/** @override */
|
|
53
54
|
get containerKey() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApiMethod.js","sourceRoot":"","sources":["../../src/model/ApiMethod.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,kGAKiE;
|
|
1
|
+
{"version":3,"file":"ApiMethod.js","sourceRoot":"","sources":["../../src/model/ApiMethod.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,kGAKiE;AACjE,8CAA+C;AAC/C,6DAAkF;AAClF,8DAAoF;AACpF,2EAAuG;AACvG,qEAA8F;AAC9F,qEAA8F;AAC9F,yDAA4E;AAC5E,mFAG6C;AAC7C,iEAAwF;AAgBxF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAa,SAAU,SAAQ,IAAA,2BAAY,EACzC,IAAA,qDAAyB,EACvB,IAAA,6CAAqB,EACnB,IAAA,uCAAkB,EAAC,IAAA,uCAAkB,EAAC,IAAA,+BAAc,EAAC,IAAA,mCAAgB,EAAC,iCAAe,CAAC,CAAC,CAAC,CAAC,CAC1F,CACF,CACF;IACC,YAAmB,OAA0B;QAC3C,KAAK,CAAC,OAAO,CAAC,CAAC;IACjB,CAAC;IAEM,MAAM,CAAC,eAAe,CAAC,IAAY,EAAE,QAAiB,EAAE,aAAqB;QAClF,IAAI,QAAQ,EAAE;YACZ,OAAO,GAAG,IAAI,IAAI,qBAAW,CAAC,MAAM,WAAW,aAAa,EAAE,CAAC;SAChE;aAAM;YACL,OAAO,GAAG,IAAI,IAAI,qBAAW,CAAC,MAAM,aAAa,aAAa,EAAE,CAAC;SAClE;IACH,CAAC;IAED,gBAAgB;IAChB,IAAW,IAAI;QACb,OAAO,qBAAW,CAAC,MAAM,CAAC;IAC5B,CAAC;IAED,gBAAgB;IAChB,IAAW,YAAY;QACrB,OAAO,SAAS,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;IACjF,CAAC;IAED,sBAAsB;IACf,uBAAuB;QAC5B,MAAM,aAAa,GAAc,2CAAoB,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAChF,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC,CAAC,2CAAoB,CAAC,KAAK,EAAE,CAAC;aACjF,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,mBAAoB,CAAC,kBAAmB,EAAE,aAAa,CAAC;aACzF,WAAW,uBAAgB;aAC3B,iBAAiB,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAC3C,CAAC;CACF;AArCD,8BAqCC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport {\r\n DeclarationReference,\r\n Meaning,\r\n Navigation,\r\n Component\r\n} from '@microsoft/tsdoc/lib-commonjs/beta/DeclarationReference';\r\nimport { ApiItemKind } from '../items/ApiItem';\r\nimport { ApiStaticMixin, IApiStaticMixinOptions } from '../mixins/ApiStaticMixin';\r\nimport { IApiDeclaredItemOptions, ApiDeclaredItem } from '../items/ApiDeclaredItem';\r\nimport { IApiParameterListMixinOptions, ApiParameterListMixin } from '../mixins/ApiParameterListMixin';\r\nimport { IApiReleaseTagMixinOptions, ApiReleaseTagMixin } from '../mixins/ApiReleaseTagMixin';\r\nimport { ApiReturnTypeMixin, IApiReturnTypeMixinOptions } from '../mixins/ApiReturnTypeMixin';\r\nimport { IApiNameMixinOptions, ApiNameMixin } from '../mixins/ApiNameMixin';\r\nimport {\r\n ApiTypeParameterListMixin,\r\n IApiTypeParameterListMixinOptions\r\n} from '../mixins/ApiTypeParameterListMixin';\r\nimport { ApiOptionalMixin, IApiOptionalMixinOptions } from '../mixins/ApiOptionalMixin';\r\n\r\n/**\r\n * Constructor options for {@link ApiMethod}.\r\n * @public\r\n */\r\nexport interface IApiMethodOptions\r\n extends IApiNameMixinOptions,\r\n IApiTypeParameterListMixinOptions,\r\n IApiParameterListMixinOptions,\r\n IApiReleaseTagMixinOptions,\r\n IApiReturnTypeMixinOptions,\r\n IApiStaticMixinOptions,\r\n IApiOptionalMixinOptions,\r\n IApiDeclaredItemOptions {}\r\n\r\n/**\r\n * Represents a TypeScript member function declaration that belongs to an `ApiClass`.\r\n *\r\n * @remarks\r\n *\r\n * This is part of the {@link ApiModel} hierarchy of classes, which are serializable representations of\r\n * API declarations.\r\n *\r\n * `ApiMethod` represents a TypeScript declaration such as the `render` member function in this example:\r\n *\r\n * ```ts\r\n * export class Widget {\r\n * public render(): void { }\r\n * }\r\n * ```\r\n *\r\n * Compare with {@link ApiMethodSignature}, which represents a method belonging to an interface.\r\n * For example, a class method can be `static` but an interface method cannot.\r\n *\r\n * @public\r\n */\r\nexport class ApiMethod extends ApiNameMixin(\r\n ApiTypeParameterListMixin(\r\n ApiParameterListMixin(\r\n ApiReleaseTagMixin(ApiReturnTypeMixin(ApiStaticMixin(ApiOptionalMixin(ApiDeclaredItem))))\r\n )\r\n )\r\n) {\r\n public constructor(options: IApiMethodOptions) {\r\n super(options);\r\n }\r\n\r\n public static getContainerKey(name: string, isStatic: boolean, overloadIndex: number): string {\r\n if (isStatic) {\r\n return `${name}|${ApiItemKind.Method}|static|${overloadIndex}`;\r\n } else {\r\n return `${name}|${ApiItemKind.Method}|instance|${overloadIndex}`;\r\n }\r\n }\r\n\r\n /** @override */\r\n public get kind(): ApiItemKind {\r\n return ApiItemKind.Method;\r\n }\r\n\r\n /** @override */\r\n public get containerKey(): string {\r\n return ApiMethod.getContainerKey(this.name, this.isStatic, this.overloadIndex);\r\n }\r\n\r\n /** @beta @override */\r\n public buildCanonicalReference(): DeclarationReference {\r\n const nameComponent: Component = DeclarationReference.parseComponent(this.name);\r\n return (this.parent ? this.parent.canonicalReference : DeclarationReference.empty())\r\n .addNavigationStep(this.isStatic ? Navigation.Exports : Navigation.Members, nameComponent)\r\n .withMeaning(Meaning.Member)\r\n .withOverloadIndex(this.overloadIndex);\r\n }\r\n}\r\n"]}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.ApiMethodSignature = void 0;
|
|
6
6
|
const DeclarationReference_1 = require("@microsoft/tsdoc/lib-commonjs/beta/DeclarationReference");
|
|
7
|
+
const ApiItem_1 = require("../items/ApiItem");
|
|
7
8
|
const ApiDeclaredItem_1 = require("../items/ApiDeclaredItem");
|
|
8
9
|
const ApiParameterListMixin_1 = require("../mixins/ApiParameterListMixin");
|
|
9
10
|
const ApiReleaseTagMixin_1 = require("../mixins/ApiReleaseTagMixin");
|
|
@@ -37,11 +38,11 @@ class ApiMethodSignature extends (0, ApiNameMixin_1.ApiNameMixin)((0, ApiTypePar
|
|
|
37
38
|
super(options);
|
|
38
39
|
}
|
|
39
40
|
static getContainerKey(name, overloadIndex) {
|
|
40
|
-
return `${name}|${
|
|
41
|
+
return `${name}|${ApiItem_1.ApiItemKind.MethodSignature}|${overloadIndex}`;
|
|
41
42
|
}
|
|
42
43
|
/** @override */
|
|
43
44
|
get kind() {
|
|
44
|
-
return
|
|
45
|
+
return ApiItem_1.ApiItemKind.MethodSignature;
|
|
45
46
|
}
|
|
46
47
|
/** @override */
|
|
47
48
|
get containerKey() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApiMethodSignature.js","sourceRoot":"","sources":["../../src/model/ApiMethodSignature.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,kGAKiE;
|
|
1
|
+
{"version":3,"file":"ApiMethodSignature.js","sourceRoot":"","sources":["../../src/model/ApiMethodSignature.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,kGAKiE;AACjE,8CAA+C;AAC/C,8DAAoF;AACpF,2EAAuG;AACvG,qEAA8F;AAC9F,qEAA8F;AAC9F,yDAA4E;AAC5E,mFAG6C;AAC7C,iEAAwF;AAYxF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAa,kBAAmB,SAAQ,IAAA,2BAAY,EAClD,IAAA,qDAAyB,EACvB,IAAA,6CAAqB,EAAC,IAAA,uCAAkB,EAAC,IAAA,uCAAkB,EAAC,IAAA,mCAAgB,EAAC,iCAAe,CAAC,CAAC,CAAC,CAAC,CACjG,CACF;IACC,YAAmB,OAAmC;QACpD,KAAK,CAAC,OAAO,CAAC,CAAC;IACjB,CAAC;IAEM,MAAM,CAAC,eAAe,CAAC,IAAY,EAAE,aAAqB;QAC/D,OAAO,GAAG,IAAI,IAAI,qBAAW,CAAC,eAAe,IAAI,aAAa,EAAE,CAAC;IACnE,CAAC;IAED,gBAAgB;IAChB,IAAW,IAAI;QACb,OAAO,qBAAW,CAAC,eAAe,CAAC;IACrC,CAAC;IAED,gBAAgB;IAChB,IAAW,YAAY;QACrB,OAAO,kBAAkB,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;IAC3E,CAAC;IAED,sBAAsB;IACf,uBAAuB;QAC5B,MAAM,aAAa,GAAc,2CAAoB,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAChF,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC,CAAC,2CAAoB,CAAC,KAAK,EAAE,CAAC;aACjF,iBAAiB,oBAAqB,aAAa,CAAC;aACpD,WAAW,uBAAgB;aAC3B,iBAAiB,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAC3C,CAAC;CACF;AA/BD,gDA+BC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport {\r\n DeclarationReference,\r\n Meaning,\r\n Navigation,\r\n Component\r\n} from '@microsoft/tsdoc/lib-commonjs/beta/DeclarationReference';\r\nimport { ApiItemKind } from '../items/ApiItem';\r\nimport { ApiDeclaredItem, IApiDeclaredItemOptions } from '../items/ApiDeclaredItem';\r\nimport { ApiParameterListMixin, IApiParameterListMixinOptions } from '../mixins/ApiParameterListMixin';\r\nimport { ApiReleaseTagMixin, IApiReleaseTagMixinOptions } from '../mixins/ApiReleaseTagMixin';\r\nimport { IApiReturnTypeMixinOptions, ApiReturnTypeMixin } from '../mixins/ApiReturnTypeMixin';\r\nimport { IApiNameMixinOptions, ApiNameMixin } from '../mixins/ApiNameMixin';\r\nimport {\r\n IApiTypeParameterListMixinOptions,\r\n ApiTypeParameterListMixin\r\n} from '../mixins/ApiTypeParameterListMixin';\r\nimport { ApiOptionalMixin, IApiOptionalMixinOptions } from '../mixins/ApiOptionalMixin';\r\n\r\n/** @public */\r\nexport interface IApiMethodSignatureOptions\r\n extends IApiNameMixinOptions,\r\n IApiTypeParameterListMixinOptions,\r\n IApiParameterListMixinOptions,\r\n IApiReleaseTagMixinOptions,\r\n IApiReturnTypeMixinOptions,\r\n IApiOptionalMixinOptions,\r\n IApiDeclaredItemOptions {}\r\n\r\n/**\r\n * Represents a TypeScript member function declaration that belongs to an `ApiInterface`.\r\n *\r\n * @remarks\r\n *\r\n * This is part of the {@link ApiModel} hierarchy of classes, which are serializable representations of\r\n * API declarations.\r\n *\r\n * `ApiMethodSignature` represents a TypeScript declaration such as the `render` member function in this example:\r\n *\r\n * ```ts\r\n * export interface IWidget {\r\n * render(): void;\r\n * }\r\n * ```\r\n *\r\n * Compare with {@link ApiMethod}, which represents a method belonging to a class.\r\n * For example, a class method can be `static` but an interface method cannot.\r\n *\r\n * @public\r\n */\r\nexport class ApiMethodSignature extends ApiNameMixin(\r\n ApiTypeParameterListMixin(\r\n ApiParameterListMixin(ApiReleaseTagMixin(ApiReturnTypeMixin(ApiOptionalMixin(ApiDeclaredItem))))\r\n )\r\n) {\r\n public constructor(options: IApiMethodSignatureOptions) {\r\n super(options);\r\n }\r\n\r\n public static getContainerKey(name: string, overloadIndex: number): string {\r\n return `${name}|${ApiItemKind.MethodSignature}|${overloadIndex}`;\r\n }\r\n\r\n /** @override */\r\n public get kind(): ApiItemKind {\r\n return ApiItemKind.MethodSignature;\r\n }\r\n\r\n /** @override */\r\n public get containerKey(): string {\r\n return ApiMethodSignature.getContainerKey(this.name, this.overloadIndex);\r\n }\r\n\r\n /** @beta @override */\r\n public buildCanonicalReference(): DeclarationReference {\r\n const nameComponent: Component = DeclarationReference.parseComponent(this.name);\r\n return (this.parent ? this.parent.canonicalReference : DeclarationReference.empty())\r\n .addNavigationStep(Navigation.Members, nameComponent)\r\n .withMeaning(Meaning.Member)\r\n .withOverloadIndex(this.overloadIndex);\r\n }\r\n}\r\n"]}
|
package/lib/model/ApiModel.js
CHANGED
|
@@ -64,7 +64,7 @@ class ApiModel extends (0, ApiItemContainerMixin_1.ApiItemContainerMixin)(ApiIte
|
|
|
64
64
|
}
|
|
65
65
|
/** @override */
|
|
66
66
|
get kind() {
|
|
67
|
-
return
|
|
67
|
+
return ApiItem_1.ApiItemKind.Model;
|
|
68
68
|
}
|
|
69
69
|
/** @override */
|
|
70
70
|
get containerKey() {
|
|
@@ -75,7 +75,7 @@ class ApiModel extends (0, ApiItemContainerMixin_1.ApiItemContainerMixin)(ApiIte
|
|
|
75
75
|
}
|
|
76
76
|
/** @override */
|
|
77
77
|
addMember(member) {
|
|
78
|
-
if (member.kind !==
|
|
78
|
+
if (member.kind !== ApiItem_1.ApiItemKind.Package) {
|
|
79
79
|
throw new Error('Only items of type ApiPackage may be added to an ApiModel');
|
|
80
80
|
}
|
|
81
81
|
super.addMember(member);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApiModel.js","sourceRoot":"","sources":["../../src/model/ApiModel.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,kGAA+F;AAC/F,8CAAwD;AACxD,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;IACH,CAAC;IAED,sBAAsB;IACf,uBAAuB;QAC5B,OAAO,2CAAoB,CAAC,KAAK,EAAE,CAAC;IACtC,CAAC;CACF;AApJD,4BAoJC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport { DeclarationReference } from '@microsoft/tsdoc/lib-commonjs/beta/DeclarationReference';\r\nimport { ApiItem, ApiItemKind } from '../items/ApiItem';\r\nimport { ApiItemContainerMixin } from '../mixins/ApiItemContainerMixin';\r\nimport { ApiPackage } from './ApiPackage';\r\nimport { PackageName } from '@rushstack/node-core-library';\r\nimport { ModelReferenceResolver, IResolveDeclarationReferenceResult } from './ModelReferenceResolver';\r\nimport { DocDeclarationReference } from '@microsoft/tsdoc';\r\n\r\n/**\r\n * A serializable representation of a collection of API declarations.\r\n *\r\n * @remarks\r\n *\r\n * An `ApiModel` represents a collection of API declarations that can be serialized to disk. It captures all the\r\n * important information needed to generate documentation, without any reliance on the TypeScript compiler engine.\r\n *\r\n * An `ApiModel` acts as the root of a tree of objects that all inherit from the `ApiItem` base class.\r\n * The tree children are determined by the {@link (ApiItemContainerMixin:interface)} mixin base class. The model\r\n * contains packages. Packages have an entry point (today, only one). And the entry point can contain various types\r\n * of API declarations. The container relationships might look like this:\r\n *\r\n * ```\r\n * Things that can contain other things:\r\n *\r\n * - ApiModel\r\n * - ApiPackage\r\n * - ApiEntryPoint\r\n * - ApiClass\r\n * - ApiMethod\r\n * - ApiProperty\r\n * - ApiEnum\r\n * - ApiEnumMember\r\n * - ApiInterface\r\n * - ApiMethodSignature\r\n * - ApiPropertySignature\r\n * - ApiNamespace\r\n * - (ApiClass, ApiEnum, ApiInterace, ...)\r\n *\r\n * ```\r\n *\r\n * Normally, API Extractor writes an .api.json file to disk for each project that it builds. Then, a tool like\r\n * API Documenter can load the various `ApiPackage` objects into a single `ApiModel` and process them as a group.\r\n * This is useful because compilation generally occurs separately (e.g. because projects may reside in different\r\n * Git repos, or because they build with different TypeScript compiler configurations that may be incompatible),\r\n * whereas API Documenter cannot detect broken hyperlinks without seeing the entire documentation set.\r\n *\r\n * @public\r\n */\r\nexport class ApiModel extends ApiItemContainerMixin(ApiItem) {\r\n private readonly _resolver: ModelReferenceResolver;\r\n\r\n private _packagesByName: Map<string, ApiPackage> | undefined = undefined;\r\n private _apiItemsByCanonicalReference: Map<string, ApiItem> | undefined = undefined;\r\n public constructor() {\r\n super({});\r\n\r\n this._resolver = new ModelReferenceResolver(this);\r\n }\r\n\r\n public loadPackage(apiJsonFilename: string): ApiPackage {\r\n const apiPackage: ApiPackage = ApiPackage.loadFromJsonFile(apiJsonFilename);\r\n this.addMember(apiPackage);\r\n return apiPackage;\r\n }\r\n\r\n /** @override */\r\n public get kind(): ApiItemKind {\r\n return ApiItemKind.Model;\r\n }\r\n\r\n /** @override */\r\n public get containerKey(): string {\r\n return '';\r\n }\r\n\r\n public get packages(): ReadonlyArray<ApiPackage> {\r\n return this.members as ReadonlyArray<ApiPackage>;\r\n }\r\n\r\n /** @override */\r\n public addMember(member: ApiPackage): void {\r\n if (member.kind !== ApiItemKind.Package) {\r\n throw new Error('Only items of type ApiPackage may be added to an ApiModel');\r\n }\r\n super.addMember(member);\r\n this._packagesByName = undefined; // invalidate the cache\r\n this._apiItemsByCanonicalReference = undefined; // invalidate the cache\r\n }\r\n\r\n /**\r\n * Efficiently finds a package by the NPM package name.\r\n *\r\n * @remarks\r\n *\r\n * If the NPM scope is omitted in the package name, it will still be found provided that it is an unambiguous match.\r\n * For example, it's often convenient to write `{@link node-core-library#JsonFile}` instead of\r\n * `{@link @rushstack/node-core-library#JsonFile}`.\r\n */\r\n public tryGetPackageByName(packageName: string): ApiPackage | undefined {\r\n // Build the lookup on demand\r\n if (this._packagesByName === undefined) {\r\n this._packagesByName = new Map<string, ApiPackage>();\r\n\r\n const unscopedMap: Map<string, ApiPackage | undefined> = new Map<string, ApiPackage | undefined>();\r\n\r\n for (const apiPackage of this.packages) {\r\n if (this._packagesByName.get(apiPackage.name)) {\r\n // This should not happen\r\n throw new Error(`The model contains multiple packages with the name ${apiPackage.name}`);\r\n }\r\n\r\n this._packagesByName.set(apiPackage.name, apiPackage);\r\n\r\n const unscopedName: string = PackageName.parse(apiPackage.name).unscopedName;\r\n\r\n if (unscopedMap.has(unscopedName)) {\r\n // If another package has the same unscoped name, then we won't register it\r\n unscopedMap.set(unscopedName, undefined);\r\n } else {\r\n unscopedMap.set(unscopedName, apiPackage);\r\n }\r\n }\r\n\r\n for (const [unscopedName, apiPackage] of unscopedMap) {\r\n if (apiPackage) {\r\n if (!this._packagesByName.has(unscopedName)) {\r\n // If the unscoped name is unambiguous, then we can also use it as a lookup\r\n this._packagesByName.set(unscopedName, apiPackage);\r\n }\r\n }\r\n }\r\n }\r\n\r\n return this._packagesByName.get(packageName);\r\n }\r\n\r\n public resolveDeclarationReference(\r\n declarationReference: DocDeclarationReference | DeclarationReference,\r\n contextApiItem: ApiItem | undefined\r\n ): IResolveDeclarationReferenceResult {\r\n if (declarationReference instanceof DocDeclarationReference) {\r\n return this._resolver.resolve(declarationReference, contextApiItem);\r\n } else if (declarationReference instanceof DeclarationReference) {\r\n // use this._apiItemsByCanonicalReference to look up ApiItem\r\n\r\n // Build the lookup on demand\r\n if (!this._apiItemsByCanonicalReference) {\r\n this._apiItemsByCanonicalReference = new Map<string, ApiItem>();\r\n\r\n for (const apiPackage of this.packages) {\r\n this._initApiItemsRecursive(apiPackage, this._apiItemsByCanonicalReference);\r\n }\r\n }\r\n\r\n const result: IResolveDeclarationReferenceResult = {\r\n resolvedApiItem: undefined,\r\n errorMessage: undefined\r\n };\r\n\r\n const apiItem: ApiItem | undefined = this._apiItemsByCanonicalReference.get(\r\n declarationReference.toString()\r\n );\r\n\r\n if (!apiItem) {\r\n result.errorMessage = `${declarationReference.toString()} can not be located`;\r\n } else {\r\n result.resolvedApiItem = apiItem;\r\n }\r\n\r\n return result;\r\n } else {\r\n // NOTE: The \"instanceof DeclarationReference\" test assumes a specific version of the @microsoft/tsdoc package.\r\n throw new Error(\r\n 'The \"declarationReference\" parameter must be an instance of' +\r\n ' DocDeclarationReference or DeclarationReference'\r\n );\r\n }\r\n }\r\n\r\n private _initApiItemsRecursive(apiItem: ApiItem, apiItemsByCanonicalReference: Map<string, ApiItem>): void {\r\n if (apiItem.canonicalReference && !apiItem.canonicalReference.isEmpty) {\r\n apiItemsByCanonicalReference.set(apiItem.canonicalReference.toString(), apiItem);\r\n }\r\n\r\n // Recurse container members\r\n if (ApiItemContainerMixin.isBaseClassOf(apiItem)) {\r\n for (const apiMember of apiItem.members) {\r\n this._initApiItemsRecursive(apiMember, apiItemsByCanonicalReference);\r\n }\r\n }\r\n }\r\n\r\n /** @beta @override */\r\n public buildCanonicalReference(): DeclarationReference {\r\n return DeclarationReference.empty();\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"ApiModel.js","sourceRoot":"","sources":["../../src/model/ApiModel.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,kGAA+F;AAC/F,8CAAwD;AACxD,2EAAwE;AACxE,6CAA0C;AAC1C,oEAA2D;AAC3D,qEAAsG;AACtG,4CAA2D;AAE3D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,MAAa,QAAS,SAAQ,IAAA,6CAAqB,EAAC,iBAAO,CAAC;IAK1D;QACE,KAAK,CAAC,EAAE,CAAC,CAAC;QAHJ,oBAAe,GAAwC,SAAS,CAAC;QACjE,kCAA6B,GAAqC,SAAS,CAAC;QAIlF,IAAI,CAAC,SAAS,GAAG,IAAI,+CAAsB,CAAC,IAAI,CAAC,CAAC;IACpD,CAAC;IAEM,WAAW,CAAC,eAAuB;QACxC,MAAM,UAAU,GAAe,uBAAU,CAAC,gBAAgB,CAAC,eAAe,CAAC,CAAC;QAC5E,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;QAC3B,OAAO,UAAU,CAAC;I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AAI,CAAC,OAAO,EAAE;gBACZ,MAAM,CAAC,YAAY,GAAG,GAAG,oBAAoB,CAAC,QAAQ,EAAE,qBAAqB,CAAC;aAC/E;iBAAM;gBACL,MAAM,CAAC,eAAe,GAAG,OAAO,CAAC;aAClC;YAED,OAAO,MAAM,CAAC;SACf;aAAM;YACL,+GAA+G;YAC/G,MAAM,IAAI,KAAK,CACb,6DAA6D;gBAC3D,kDAAkD,CACrD,CAAC;SACH;IACH,CAAC;IAEO,sBAAsB,CAAC,OAAgB,EAAE,4BAAkD;QACjG,IAAI,OAAO,CAAC,kBAAkB,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,OAAO,EAAE;YACrE,4BAA4B,CAAC,GAAG,CAAC,OAAO,CAAC,kBAAkB,CAAC,QAAQ,EAAE,EAAE,OAAO,CAAC,CAAC;SAClF;QAED,4BAA4B;QAC5B,IAAI,6CAAqB,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE;YAChD,KAAK,MAAM,SAAS,IAAI,OAAO,CAAC,OAAO,EAAE;gBACvC,IAAI,CAAC,sBAAsB,CAAC,SAAS,EAAE,4BAA4B,CAAC,CAAC;aACtE;SACF;IACH,CAAC;IAED,sBAAsB;IACf,uBAAuB;QAC5B,OAAO,2CAAoB,CAAC,KAAK,EAAE,CAAC;IACtC,CAAC;CACF;AApJD,4BAoJC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport { DeclarationReference } from '@microsoft/tsdoc/lib-commonjs/beta/DeclarationReference';\r\nimport { ApiItem, ApiItemKind } from '../items/ApiItem';\r\nimport { ApiItemContainerMixin } from '../mixins/ApiItemContainerMixin';\r\nimport { ApiPackage } from './ApiPackage';\r\nimport { PackageName } from '@rushstack/node-core-library';\r\nimport { ModelReferenceResolver, IResolveDeclarationReferenceResult } from './ModelReferenceResolver';\r\nimport { DocDeclarationReference } from '@microsoft/tsdoc';\r\n\r\n/**\r\n * A serializable representation of a collection of API declarations.\r\n *\r\n * @remarks\r\n *\r\n * An `ApiModel` represents a collection of API declarations that can be serialized to disk. It captures all the\r\n * important information needed to generate documentation, without any reliance on the TypeScript compiler engine.\r\n *\r\n * An `ApiModel` acts as the root of a tree of objects that all inherit from the `ApiItem` base class.\r\n * The tree children are determined by the {@link (ApiItemContainerMixin:interface)} mixin base class. The model\r\n * contains packages. Packages have an entry point (today, only one). And the entry point can contain various types\r\n * of API declarations. The container relationships might look like this:\r\n *\r\n * ```\r\n * Things that can contain other things:\r\n *\r\n * - ApiModel\r\n * - ApiPackage\r\n * - ApiEntryPoint\r\n * - ApiClass\r\n * - ApiMethod\r\n * - ApiProperty\r\n * - ApiEnum\r\n * - ApiEnumMember\r\n * - ApiInterface\r\n * - ApiMethodSignature\r\n * - ApiPropertySignature\r\n * - ApiNamespace\r\n * - (ApiClass, ApiEnum, ApiInterace, ...)\r\n *\r\n * ```\r\n *\r\n * Normally, API Extractor writes an .api.json file to disk for each project that it builds. Then, a tool like\r\n * API Documenter can load the various `ApiPackage` objects into a single `ApiModel` and process them as a group.\r\n * This is useful because compilation generally occurs separately (e.g. because projects may reside in different\r\n * Git repos, or because they build with different TypeScript compiler configurations that may be incompatible),\r\n * whereas API Documenter cannot detect broken hyperlinks without seeing the entire documentation set.\r\n *\r\n * @public\r\n */\r\nexport class ApiModel extends ApiItemContainerMixin(ApiItem) {\r\n private readonly _resolver: ModelReferenceResolver;\r\n\r\n private _packagesByName: Map<string, ApiPackage> | undefined = undefined;\r\n private _apiItemsByCanonicalReference: Map<string, ApiItem> | undefined = undefined;\r\n public constructor() {\r\n super({});\r\n\r\n this._resolver = new ModelReferenceResolver(this);\r\n }\r\n\r\n public loadPackage(apiJsonFilename: string): ApiPackage {\r\n const apiPackage: ApiPackage = ApiPackage.loadFromJsonFile(apiJsonFilename);\r\n this.addMember(apiPackage);\r\n return apiPackage;\r\n }\r\n\r\n /** @override */\r\n public get kind(): ApiItemKind {\r\n return ApiItemKind.Model;\r\n }\r\n\r\n /** @override */\r\n public get containerKey(): string {\r\n return '';\r\n }\r\n\r\n public get packages(): ReadonlyArray<ApiPackage> {\r\n return this.members as ReadonlyArray<ApiPackage>;\r\n }\r\n\r\n /** @override */\r\n public addMember(member: ApiPackage): void {\r\n if (member.kind !== ApiItemKind.Package) {\r\n throw new Error('Only items of type ApiPackage may be added to an ApiModel');\r\n }\r\n super.addMember(member);\r\n this._packagesByName = undefined; // invalidate the cache\r\n this._apiItemsByCanonicalReference = undefined; // invalidate the cache\r\n }\r\n\r\n /**\r\n * Efficiently finds a package by the NPM package name.\r\n *\r\n * @remarks\r\n *\r\n * If the NPM scope is omitted in the package name, it will still be found provided that it is an unambiguous match.\r\n * For example, it's often convenient to write `{@link node-core-library#JsonFile}` instead of\r\n * `{@link @rushstack/node-core-library#JsonFile}`.\r\n */\r\n public tryGetPackageByName(packageName: string): ApiPackage | undefined {\r\n // Build the lookup on demand\r\n if (this._packagesByName === undefined) {\r\n this._packagesByName = new Map<string, ApiPackage>();\r\n\r\n const unscopedMap: Map<string, ApiPackage | undefined> = new Map<string, ApiPackage | undefined>();\r\n\r\n for (const apiPackage of this.packages) {\r\n if (this._packagesByName.get(apiPackage.name)) {\r\n // This should not happen\r\n throw new Error(`The model contains multiple packages with the name ${apiPackage.name}`);\r\n }\r\n\r\n this._packagesByName.set(apiPackage.name, apiPackage);\r\n\r\n const unscopedName: string = PackageName.parse(apiPackage.name).unscopedName;\r\n\r\n if (unscopedMap.has(unscopedName)) {\r\n // If another package has the same unscoped name, then we won't register it\r\n unscopedMap.set(unscopedName, undefined);\r\n } else {\r\n unscopedMap.set(unscopedName, apiPackage);\r\n }\r\n }\r\n\r\n for (const [unscopedName, apiPackage] of unscopedMap) {\r\n if (apiPackage) {\r\n if (!this._packagesByName.has(unscopedName)) {\r\n // If the unscoped name is unambiguous, then we can also use it as a lookup\r\n this._packagesByName.set(unscopedName, apiPackage);\r\n }\r\n }\r\n }\r\n }\r\n\r\n return this._packagesByName.get(packageName);\r\n }\r\n\r\n public resolveDeclarationReference(\r\n declarationReference: DocDeclarationReference | DeclarationReference,\r\n contextApiItem: ApiItem | undefined\r\n ): IResolveDeclarationReferenceResult {\r\n if (declarationReference instanceof DocDeclarationReference) {\r\n return this._resolver.resolve(declarationReference, contextApiItem);\r\n } else if (declarationReference instanceof DeclarationReference) {\r\n // use this._apiItemsByCanonicalReference to look up ApiItem\r\n\r\n // Build the lookup on demand\r\n if (!this._apiItemsByCanonicalReference) {\r\n this._apiItemsByCanonicalReference = new Map<string, ApiItem>();\r\n\r\n for (const apiPackage of this.packages) {\r\n this._initApiItemsRecursive(apiPackage, this._apiItemsByCanonicalReference);\r\n }\r\n }\r\n\r\n const result: IResolveDeclarationReferenceResult = {\r\n resolvedApiItem: undefined,\r\n errorMessage: undefined\r\n };\r\n\r\n const apiItem: ApiItem | undefined = this._apiItemsByCanonicalReference.get(\r\n declarationReference.toString()\r\n );\r\n\r\n if (!apiItem) {\r\n result.errorMessage = `${declarationReference.toString()} can not be located`;\r\n } else {\r\n result.resolvedApiItem = apiItem;\r\n }\r\n\r\n return result;\r\n } else {\r\n // NOTE: The \"instanceof DeclarationReference\" test assumes a specific version of the @microsoft/tsdoc package.\r\n throw new Error(\r\n 'The \"declarationReference\" parameter must be an instance of' +\r\n ' DocDeclarationReference or DeclarationReference'\r\n );\r\n }\r\n }\r\n\r\n private _initApiItemsRecursive(apiItem: ApiItem, apiItemsByCanonicalReference: Map<string, ApiItem>): void {\r\n if (apiItem.canonicalReference && !apiItem.canonicalReference.isEmpty) {\r\n apiItemsByCanonicalReference.set(apiItem.canonicalReference.toString(), apiItem);\r\n }\r\n\r\n // Recurse container members\r\n if (ApiItemContainerMixin.isBaseClassOf(apiItem)) {\r\n for (const apiMember of apiItem.members) {\r\n this._initApiItemsRecursive(apiMember, apiItemsByCanonicalReference);\r\n }\r\n }\r\n }\r\n\r\n /** @beta @override */\r\n public buildCanonicalReference(): DeclarationReference {\r\n return DeclarationReference.empty();\r\n }\r\n}\r\n"]}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.ApiNamespace = void 0;
|
|
6
6
|
const DeclarationReference_1 = require("@microsoft/tsdoc/lib-commonjs/beta/DeclarationReference");
|
|
7
|
+
const ApiItem_1 = require("../items/ApiItem");
|
|
7
8
|
const ApiItemContainerMixin_1 = require("../mixins/ApiItemContainerMixin");
|
|
8
9
|
const ApiDeclaredItem_1 = require("../items/ApiDeclaredItem");
|
|
9
10
|
const ApiReleaseTagMixin_1 = require("../mixins/ApiReleaseTagMixin");
|
|
@@ -35,11 +36,11 @@ class ApiNamespace extends (0, ApiItemContainerMixin_1.ApiItemContainerMixin)((0
|
|
|
35
36
|
super(options);
|
|
36
37
|
}
|
|
37
38
|
static getContainerKey(name) {
|
|
38
|
-
return `${name}|${
|
|
39
|
+
return `${name}|${ApiItem_1.ApiItemKind.Namespace}`;
|
|
39
40
|
}
|
|
40
41
|
/** @override */
|
|
41
42
|
get kind() {
|
|
42
|
-
return
|
|
43
|
+
return ApiItem_1.ApiItemKind.Namespace;
|
|
43
44
|
}
|
|
44
45
|
/** @override */
|
|
45
46
|
get containerKey() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApiNamespace.js","sourceRoot":"","sources":["../../src/model/ApiNamespace.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,kGAKiE;
|
|
1
|
+
{"version":3,"file":"ApiNamespace.js","sourceRoot":"","sources":["../../src/model/ApiNamespace.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,kGAKiE;AACjE,8CAA+C;AAC/C,2EAAuG;AACvG,8DAAoF;AACpF,qEAA8F;AAC9F,yDAA4E;AAY5E;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAa,YAAa,SAAQ,IAAA,6CAAqB,EAAC,IAAA,2BAAY,EAAC,IAAA,uCAAkB,EAAC,iCAAe,CAAC,CAAC,CAAC;IACxG,YAAmB,OAA6B;QAC9C,KAAK,CAAC,OAAO,CAAC,CAAC;IACjB,CAAC;IAEM,MAAM,CAAC,eAAe,CAAC,IAAY;QACxC,OAAO,GAAG,IAAI,IAAI,qBAAW,CAAC,SAAS,EAAE,CAAC;IAC5C,CAAC;IAED,gBAAgB;IAChB,IAAW,IAAI;QACb,OAAO,qBAAW,CAAC,SAAS,CAAC;IAC/B,CAAC;IAED,gBAAgB;IAChB,IAAW,YAAY;QACrB,OAAO,YAAY,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACjD,CAAC;IAED,sBAAsB;IACf,uBAAuB;QAC5B,MAAM,aAAa,GAAc,2CAAoB,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAChF,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC,CAAC,2CAAoB,CAAC,KAAK,EAAE,CAAC;aACjF,iBAAiB,oBAAqB,aAAa,CAAC;aACpD,WAAW,6BAAmB,CAAC;IACpC,CAAC;CACF;AA1BD,oCA0BC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport {\r\n DeclarationReference,\r\n Meaning,\r\n Navigation,\r\n Component\r\n} from '@microsoft/tsdoc/lib-commonjs/beta/DeclarationReference';\r\nimport { ApiItemKind } from '../items/ApiItem';\r\nimport { ApiItemContainerMixin, IApiItemContainerMixinOptions } from '../mixins/ApiItemContainerMixin';\r\nimport { IApiDeclaredItemOptions, ApiDeclaredItem } from '../items/ApiDeclaredItem';\r\nimport { ApiReleaseTagMixin, IApiReleaseTagMixinOptions } from '../mixins/ApiReleaseTagMixin';\r\nimport { IApiNameMixinOptions, ApiNameMixin } from '../mixins/ApiNameMixin';\r\n\r\n/**\r\n * Constructor options for {@link ApiClass}.\r\n * @public\r\n */\r\nexport interface IApiNamespaceOptions\r\n extends IApiItemContainerMixinOptions,\r\n IApiNameMixinOptions,\r\n IApiReleaseTagMixinOptions,\r\n IApiDeclaredItemOptions {}\r\n\r\n/**\r\n * Represents a TypeScript namespace declaration.\r\n *\r\n * @remarks\r\n *\r\n * This is part of the {@link ApiModel} hierarchy of classes, which are serializable representations of\r\n * API declarations.\r\n *\r\n * `ApiNamespace` represents a TypeScript declaration such `X` or `Y` in this example:\r\n *\r\n * ```ts\r\n * export namespace X {\r\n * export namespace Y {\r\n * export interface IWidget {\r\n * render(): void;\r\n * }\r\n * }\r\n * }\r\n * ```\r\n *\r\n * @public\r\n */\r\nexport class ApiNamespace extends ApiItemContainerMixin(ApiNameMixin(ApiReleaseTagMixin(ApiDeclaredItem))) {\r\n public constructor(options: IApiNamespaceOptions) {\r\n super(options);\r\n }\r\n\r\n public static getContainerKey(name: string): string {\r\n return `${name}|${ApiItemKind.Namespace}`;\r\n }\r\n\r\n /** @override */\r\n public get kind(): ApiItemKind {\r\n return ApiItemKind.Namespace;\r\n }\r\n\r\n /** @override */\r\n public get containerKey(): string {\r\n return ApiNamespace.getContainerKey(this.name);\r\n }\r\n\r\n /** @beta @override */\r\n public buildCanonicalReference(): DeclarationReference {\r\n const nameComponent: Component = DeclarationReference.parseComponent(this.name);\r\n return (this.parent ? this.parent.canonicalReference : DeclarationReference.empty())\r\n .addNavigationStep(Navigation.Exports, nameComponent)\r\n .withMeaning(Meaning.Namespace);\r\n }\r\n}\r\n"]}
|
package/lib/model/ApiPackage.js
CHANGED
|
@@ -79,7 +79,7 @@ class ApiPackage extends (0, ApiItemContainerMixin_1.ApiItemContainerMixin)((0,
|
|
|
79
79
|
}
|
|
80
80
|
/** @override */
|
|
81
81
|
get kind() {
|
|
82
|
-
return
|
|
82
|
+
return ApiItem_1.ApiItemKind.Package;
|
|
83
83
|
}
|
|
84
84
|
/** @override */
|
|
85
85
|
get containerKey() {
|
|
@@ -102,7 +102,7 @@ class ApiPackage extends (0, ApiItemContainerMixin_1.ApiItemContainerMixin)((0,
|
|
|
102
102
|
}
|
|
103
103
|
/** @override */
|
|
104
104
|
addMember(member) {
|
|
105
|
-
if (member.kind !==
|
|
105
|
+
if (member.kind !== ApiItem_1.ApiItemKind.EntryPoint) {
|
|
106
106
|
throw new Error('Only items of type ApiEntryPoint may be added to an ApiPackage');
|
|
107
107
|
}
|
|
108
108
|
super.addMember(member);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApiPackage.js","sourceRoot":"","sources":["../../src/model/ApiPackage.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,kGAA+F;AAC/F,8CAAsE;AACtE,2EAAuG;AACvG,oEAMsC;AACtC,kEAA0F;AAE1F,yDAA4E;AAC5E,+DAAkF;AAClF,4CAAsD;AACtD,0DAA0D;AA8F1D;;;;;;;;;GASG;AACH,MAAa,UAAW,SAAQ,IAAA,6CAAqB,EAAC,IAAA,2BAAY,EAAC,qCAAiB,CAAC,CAAC;IAGpF,YAAmB,OAA2B;QAC5C,KAAK,CAAC,OAAO,CAAC,CAAC;QAEf,IAAI,CAAC,mBAAmB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IACxD,CAAC;IAEM,MAAM,CAAC,gBAAgB,CAAC,eAAuB;QACpD,MAAM,UAAU,GAAoB,4BAAQ,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QAEnE,IAAI,CAAC,UAAU,IAAI,CAAC,UAAU,CAAC,QAAQ,IAAI,OAAO,UAAU,CAAC,QAAQ,CAAC,aAAa,KAAK,QAAQ,EAAE;YAChG,MAAM,IAAI,KAAK,CACb,iBAAiB,eAAe,GAAG;gBACjC,+FAA+F,CAClG,CAAC;SACH;QAED,MAAM,aAAa,GAAW,UAAU,CAAC,QAAQ,CAAC,aAAa,CAAC;QAEhE,IAAI,aAAa,GAAG,0CAAoB,CAAC,gBAAgB,EAAE;YACzD,MAAM,IA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AU,GAAoB;YAClC,QAAQ,EAAE;gBACR,WAAW,EAAE,OAAO,CAAC,WAAW,IAAI,WAAW,CAAC,IAAI;gBACpD,gGAAgG;gBAChG,iEAAiE;gBACjE,WAAW,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,OAAO,CAAC,WAAW,IAAI,WAAW,CAAC,OAAO;gBAC1F,aAAa,EAAE,0CAAoB,CAAC,MAAM;gBAC1C,+BAA+B,EAAE,0CAAoB,CAAC,0BAA0B;gBAChF,WAAW;aACZ;SACiB,CAAC;QACrB,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;QAC/B,4BAAQ,CAAC,IAAI,CAAC,UAAU,EAAE,eAAe,EAAE,OAAO,CAAC,CAAC;IACtD,CAAC;IAED,sBAAsB;IACf,uBAAuB;QAC5B,OAAO,2CAAoB,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACjD,CAAC;CACF;AArJD,gCAqJC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport { DeclarationReference } from '@microsoft/tsdoc/lib-commonjs/beta/DeclarationReference';\r\nimport { ApiItem, ApiItemKind, IApiItemJson } from '../items/ApiItem';\r\nimport { ApiItemContainerMixin, IApiItemContainerMixinOptions } from '../mixins/ApiItemContainerMixin';\r\nimport {\r\n JsonFile,\r\n IJsonFileSaveOptions,\r\n PackageJsonLookup,\r\n IPackageJson,\r\n JsonObject\r\n} from '@rushstack/node-core-library';\r\nimport { ApiDocumentedItem, IApiDocumentedItemOptions } from '../items/ApiDocumentedItem';\r\nimport { ApiEntryPoint } from './ApiEntryPoint';\r\nimport { IApiNameMixinOptions, ApiNameMixin } from '../mixins/ApiNameMixin';\r\nimport { DeserializerContext, ApiJsonSchemaVersion } from './DeserializerContext';\r\nimport { TSDocConfiguration } from '@microsoft/tsdoc';\r\nimport { TSDocConfigFile } from '@microsoft/tsdoc-config';\r\n\r\n/**\r\n * Constructor options for {@link ApiPackage}.\r\n * @public\r\n */\r\nexport interface IApiPackageOptions\r\n extends IApiItemContainerMixinOptions,\r\n IApiNameMixinOptions,\r\n IApiDocumentedItemOptions {\r\n tsdocConfiguration: TSDocConfiguration;\r\n}\r\n\r\nexport interface IApiPackageMetadataJson {\r\n /**\r\n * The NPM package name for the tool that wrote the *.api.json file.\r\n * For informational purposes only.\r\n */\r\n toolPackage: string;\r\n\r\n /**\r\n * The NPM package version for the tool that wrote the *.api.json file.\r\n * For informational purposes only.\r\n */\r\n toolVersion: string;\r\n\r\n /**\r\n * The schema version for the .api.json file format. Used for determining whether the file format is\r\n * supported, and for backwards compatibility.\r\n */\r\n schemaVersion: ApiJsonSchemaVersion;\r\n\r\n /**\r\n * To support forwards compatibility, the `oldestForwardsCompatibleVersion` field tracks the oldest schema version\r\n * whose corresponding deserializer could safely load this file.\r\n *\r\n * @remarks\r\n * Normally api-extractor-model should refuse to load a schema version that is newer than the latest version\r\n * that its deserializer understands. However, sometimes a schema change may merely introduce some new fields\r\n * without modifying or removing any existing fields. In this case, an older api-extractor-model library can\r\n * safely deserialize the newer version (by ignoring the extra fields that it doesn't recognize). The newer\r\n * serializer can use this field to communicate that.\r\n *\r\n * If present, the `oldestForwardsCompatibleVersion` must be less than or equal to\r\n * `IApiPackageMetadataJson.schemaVersion`.\r\n */\r\n oldestForwardsCompatibleVersion?: ApiJsonSchemaVersion;\r\n\r\n /**\r\n * The TSDoc configuration that was used when analyzing the API for this package.\r\n *\r\n * @remarks\r\n *\r\n * The structure of this objet is defined by the `@microsoft/tsdoc-config` library.\r\n * Normally this configuration is loaded from the project's tsdoc.json file. It is stored\r\n * in the .api.json file so that doc comments can be parsed accurately when loading the file.\r\n */\r\n tsdocConfig: JsonObject;\r\n}\r\n\r\nexport interface IApiPackageJson extends IApiItemJson {\r\n /**\r\n * A file header that stores metadata about the tool that wrote the *.api.json file.\r\n */\r\n metadata: IApiPackageMetadataJson;\r\n}\r\n\r\n/**\r\n * Options for {@link ApiPackage.saveToJsonFile}.\r\n * @public\r\n */\r\nexport interface IApiPackageSaveOptions extends IJsonFileSaveOptions {\r\n /**\r\n * Optionally specifies a value for the \"toolPackage\" field in the output .api.json data file;\r\n * otherwise, the value will be \"api-extractor-model\".\r\n */\r\n toolPackage?: string;\r\n\r\n /**\r\n * Optionally specifies a value for the \"toolVersion\" field in the output .api.json data file;\r\n * otherwise, the value will be the current version of the api-extractor-model package.\r\n */\r\n toolVersion?: string;\r\n\r\n /**\r\n * Set to true only when invoking API Extractor's test harness.\r\n *\r\n * @remarks\r\n * When `testMode` is true, the `toolVersion` field in the .api.json file is assigned an empty string\r\n * to prevent spurious diffs in output files tracked for tests.\r\n */\r\n testMode?: boolean;\r\n}\r\n\r\n/**\r\n * Represents an NPM package containing API declarations.\r\n *\r\n * @remarks\r\n *\r\n * This is part of the {@link ApiModel} hierarchy of classes, which are serializable representations of\r\n * API declarations.\r\n *\r\n * @public\r\n */\r\nexport class ApiPackage extends ApiItemContainerMixin(ApiNameMixin(ApiDocumentedItem)) {\r\n private readonly _tsdocConfiguration: TSDocConfiguration;\r\n\r\n public constructor(options: IApiPackageOptions) {\r\n super(options);\r\n\r\n this._tsdocConfiguration = options.tsdocConfiguration;\r\n }\r\n\r\n public static loadFromJsonFile(apiJsonFilename: string): ApiPackage {\r\n const jsonObject: IApiPackageJson = JsonFile.load(apiJsonFilename);\r\n\r\n if (!jsonObject || !jsonObject.metadata || typeof jsonObject.metadata.schemaVersion !== 'number') {\r\n throw new Error(\r\n `Error loading ${apiJsonFilename}:` +\r\n `\\nThe file format is not recognized; the \"metadata.schemaVersion\" field is missing or invalid`\r\n );\r\n }\r\n\r\n const schemaVersion: number = jsonObject.metadata.schemaVersion;\r\n\r\n if (schemaVersion < ApiJsonSchemaVersion.OLDEST_SUPPORTED) {\r\n throw new Error(\r\n `Error loading ${apiJsonFilename}:` +\r\n `\\nThe file format is version ${schemaVersion},` +\r\n ` whereas ${ApiJsonSchemaVersion.OLDEST_SUPPORTED} is the oldest version supported by this tool`\r\n );\r\n }\r\n\r\n let oldestForwardsCompatibleVersion: number = schemaVersion;\r\n if (jsonObject.metadata.oldestForwardsCompatibleVersion) {\r\n // Sanity check\r\n if (jsonObject.metadata.oldestForwardsCompatibleVersion > schemaVersion) {\r\n throw new Error(\r\n `Error loading ${apiJsonFilename}:` +\r\n `\\nInvalid file format; \"oldestForwardsCompatibleVersion\" cannot be newer than \"schemaVersion\"`\r\n );\r\n }\r\n oldestForwardsCompatibleVersion = jsonObject.metadata.oldestForwardsCompatibleVersion;\r\n }\r\n\r\n let versionToDeserialize: number = schemaVersion;\r\n if (versionToDeserialize > ApiJsonSchemaVersion.LATEST) {\r\n // If the file format is too new, can we treat it as some earlier compatible version\r\n // as indicated by oldestForwardsCompatibleVersion?\r\n versionToDeserialize = Math.max(oldestForwardsCompatibleVersion, ApiJsonSchemaVersion.LATEST);\r\n\r\n if (versionToDeserialize > ApiJsonSchemaVersion.LATEST) {\r\n // Nope, still too new\r\n throw new Error(\r\n `Error loading ${apiJsonFilename}:` +\r\n `\\nThe file format version ${schemaVersion} was written by a newer release of` +\r\n ` the api-extractor-model library; you may need to upgrade your software`\r\n );\r\n }\r\n }\r\n\r\n const tsdocConfiguration: TSDocConfiguration = new TSDocConfiguration();\r\n\r\n if (versionToDeserialize >= ApiJsonSchemaVersion.V_1004) {\r\n const tsdocConfigFile: TSDocConfigFile = TSDocConfigFile.loadFromObject(\r\n jsonObject.metadata.tsdocConfig\r\n );\r\n if (tsdocConfigFile.hasErrors) {\r\n throw new Error(`Error loading ${apiJsonFilename}:\\n` + tsdocConfigFile.getErrorSummary());\r\n }\r\n\r\n tsdocConfigFile.configureParser(tsdocConfiguration);\r\n }\r\n\r\n const context: DeserializerContext = new DeserializerContext({\r\n apiJsonFilename,\r\n toolPackage: jsonObject.metadata.toolPackage,\r\n toolVersion: jsonObject.metadata.toolVersion,\r\n versionToDeserialize: versionToDeserialize,\r\n tsdocConfiguration\r\n });\r\n\r\n return ApiItem.deserialize(jsonObject, context) as ApiPackage;\r\n }\r\n\r\n /** @override */\r\n public get kind(): ApiItemKind {\r\n return ApiItemKind.Package;\r\n }\r\n\r\n /** @override */\r\n public get containerKey(): string {\r\n // No prefix needed, because ApiPackage is the only possible member of an ApiModel\r\n return this.name;\r\n }\r\n\r\n public get entryPoints(): ReadonlyArray<ApiEntryPoint> {\r\n return this.members as ReadonlyArray<ApiEntryPoint>;\r\n }\r\n\r\n /**\r\n * The TSDoc configuration that was used when analyzing the API for this package.\r\n *\r\n * @remarks\r\n *\r\n * Normally this configuration is loaded from the project's tsdoc.json file. It is stored\r\n * in the .api.json file so that doc comments can be parsed accurately when loading the file.\r\n */\r\n public get tsdocConfiguration(): TSDocConfiguration {\r\n return this._tsdocConfiguration;\r\n }\r\n\r\n /** @override */\r\n public addMember(member: ApiEntryPoint): void {\r\n if (member.kind !== ApiItemKind.EntryPoint) {\r\n throw new Error('Only items of type ApiEntryPoint may be added to an ApiPackage');\r\n }\r\n super.addMember(member);\r\n }\r\n\r\n public findEntryPointsByPath(importPath: string): ReadonlyArray<ApiEntryPoint> {\r\n return this.findMembersByName(importPath) as ReadonlyArray<ApiEntryPoint>;\r\n }\r\n\r\n public saveToJsonFile(apiJsonFilename: string, options?: IApiPackageSaveOptions): void {\r\n if (!options) {\r\n options = {};\r\n }\r\n\r\n const packageJson: IPackageJson = PackageJsonLookup.loadOwnPackageJson(__dirname);\r\n\r\n const tsdocConfigFile: TSDocConfigFile = TSDocConfigFile.loadFromParser(this.tsdocConfiguration);\r\n const tsdocConfig: JsonObject = tsdocConfigFile.saveToObject();\r\n\r\n const jsonObject: IApiPackageJson = {\r\n metadata: {\r\n toolPackage: options.toolPackage || packageJson.name,\r\n // In test mode, we don't write the real version, since that would cause spurious diffs whenever\r\n // the version is bumped. Instead we write a placeholder string.\r\n toolVersion: options.testMode ? '[test mode]' : options.toolVersion || packageJson.version,\r\n schemaVersion: ApiJsonSchemaVersion.LATEST,\r\n oldestForwardsCompatibleVersion: ApiJsonSchemaVersion.OLDEST_FORWARDS_COMPATIBLE,\r\n tsdocConfig\r\n }\r\n } as IApiPackageJson;\r\n this.serializeInto(jsonObject);\r\n JsonFile.save(jsonObject, apiJsonFilename, options);\r\n }\r\n\r\n /** @beta @override */\r\n public buildCanonicalReference(): DeclarationReference {\r\n return DeclarationReference.package(this.name);\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"ApiPackage.js","sourceRoot":"","sources":["../../src/model/ApiPackage.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,kGAA+F;AAC/F,8CAAsE;AACtE,2EAAuG;AACvG,oEAMsC;AACtC,kEAA0F;AAE1F,yDAA4E;AAC5E,+DAAkF;AAClF,4CAAsD;AACtD,0DAA0D;AA8F1D;;;;;;;;;GASG;AACH,MAAa,UAAW,SAAQ,IAAA,6CAAqB,EAAC,IAAA,2BAAY,EAAC,qCAAiB,CAAC,CAAC;IAGpF,YAAmB,OAA2B;QAC5C,KAAK,CAAC,OAAO,CAAC,CAAC;QAEf,IAAI,CAAC,mBAAmB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IACxD,CAAC;IAEM,MAAM,CAAC,gBAAgB,CAAC,eAAuB;QACpD,MAAM,UAAU,GAAoB,4BAAQ,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QAEnE,IAAI,CAAC,UAAU,IAAI,CAAC,UAAU,CAAC,QAAQ,IAAI,OAAO,UAAU,CAAC,QAAQ,CAAC,aAAa,KAAK,QAAQ,EAAE;YAChG,MAAM,IAAI,KAAK,CACb,iBAAiB,eAAe,GAAG;gBACjC,+FAA+F,CAClG,CAAC;SACH;QAED,MAAM,aAAa,GAAW,UAAU,CAAC,QAAQ,CAAC,aAAa,CAAC;QAEhE,IAAI,aAAa,GAAG,0CAAoB,CAAC,gBAAgB,EAAE;YACzD,MAAM,IAAI,KAAK,CACb,iBAAiB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C;QAE/D,MAAM,UAAU,GAAoB;YAClC,QAAQ,EAAE;gBACR,WAAW,EAAE,OAAO,CAAC,WAAW,IAAI,WAAW,CAAC,IAAI;gBACpD,gGAAgG;gBAChG,iEAAiE;gBACjE,WAAW,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,OAAO,CAAC,WAAW,IAAI,WAAW,CAAC,OAAO;gBAC1F,aAAa,EAAE,0CAAoB,CAAC,MAAM;gBAC1C,+BAA+B,EAAE,0CAAoB,CAAC,0BAA0B;gBAChF,WAAW;aACZ;SACiB,CAAC;QACrB,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;QAC/B,4BAAQ,CAAC,IAAI,CAAC,UAAU,EAAE,eAAe,EAAE,OAAO,CAAC,CAAC;IACtD,CAAC;IAED,sBAAsB;IACf,uBAAuB;QAC5B,OAAO,2CAAoB,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACjD,CAAC;CACF;AArJD,gCAqJC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport { DeclarationReference } from '@microsoft/tsdoc/lib-commonjs/beta/DeclarationReference';\r\nimport { ApiItem, ApiItemKind, IApiItemJson } from '../items/ApiItem';\r\nimport { ApiItemContainerMixin, IApiItemContainerMixinOptions } from '../mixins/ApiItemContainerMixin';\r\nimport {\r\n JsonFile,\r\n IJsonFileSaveOptions,\r\n PackageJsonLookup,\r\n IPackageJson,\r\n JsonObject\r\n} from '@rushstack/node-core-library';\r\nimport { ApiDocumentedItem, IApiDocumentedItemOptions } from '../items/ApiDocumentedItem';\r\nimport { ApiEntryPoint } from './ApiEntryPoint';\r\nimport { IApiNameMixinOptions, ApiNameMixin } from '../mixins/ApiNameMixin';\r\nimport { DeserializerContext, ApiJsonSchemaVersion } from './DeserializerContext';\r\nimport { TSDocConfiguration } from '@microsoft/tsdoc';\r\nimport { TSDocConfigFile } from '@microsoft/tsdoc-config';\r\n\r\n/**\r\n * Constructor options for {@link ApiPackage}.\r\n * @public\r\n */\r\nexport interface IApiPackageOptions\r\n extends IApiItemContainerMixinOptions,\r\n IApiNameMixinOptions,\r\n IApiDocumentedItemOptions {\r\n tsdocConfiguration: TSDocConfiguration;\r\n}\r\n\r\nexport interface IApiPackageMetadataJson {\r\n /**\r\n * The NPM package name for the tool that wrote the *.api.json file.\r\n * For informational purposes only.\r\n */\r\n toolPackage: string;\r\n\r\n /**\r\n * The NPM package version for the tool that wrote the *.api.json file.\r\n * For informational purposes only.\r\n */\r\n toolVersion: string;\r\n\r\n /**\r\n * The schema version for the .api.json file format. Used for determining whether the file format is\r\n * supported, and for backwards compatibility.\r\n */\r\n schemaVersion: ApiJsonSchemaVersion;\r\n\r\n /**\r\n * To support forwards compatibility, the `oldestForwardsCompatibleVersion` field tracks the oldest schema version\r\n * whose corresponding deserializer could safely load this file.\r\n *\r\n * @remarks\r\n * Normally api-extractor-model should refuse to load a schema version that is newer than the latest version\r\n * that its deserializer understands. However, sometimes a schema change may merely introduce some new fields\r\n * without modifying or removing any existing fields. In this case, an older api-extractor-model library can\r\n * safely deserialize the newer version (by ignoring the extra fields that it doesn't recognize). The newer\r\n * serializer can use this field to communicate that.\r\n *\r\n * If present, the `oldestForwardsCompatibleVersion` must be less than or equal to\r\n * `IApiPackageMetadataJson.schemaVersion`.\r\n */\r\n oldestForwardsCompatibleVersion?: ApiJsonSchemaVersion;\r\n\r\n /**\r\n * The TSDoc configuration that was used when analyzing the API for this package.\r\n *\r\n * @remarks\r\n *\r\n * The structure of this objet is defined by the `@microsoft/tsdoc-config` library.\r\n * Normally this configuration is loaded from the project's tsdoc.json file. It is stored\r\n * in the .api.json file so that doc comments can be parsed accurately when loading the file.\r\n */\r\n tsdocConfig: JsonObject;\r\n}\r\n\r\nexport interface IApiPackageJson extends IApiItemJson {\r\n /**\r\n * A file header that stores metadata about the tool that wrote the *.api.json file.\r\n */\r\n metadata: IApiPackageMetadataJson;\r\n}\r\n\r\n/**\r\n * Options for {@link ApiPackage.saveToJsonFile}.\r\n * @public\r\n */\r\nexport interface IApiPackageSaveOptions extends IJsonFileSaveOptions {\r\n /**\r\n * Optionally specifies a value for the \"toolPackage\" field in the output .api.json data file;\r\n * otherwise, the value will be \"api-extractor-model\".\r\n */\r\n toolPackage?: string;\r\n\r\n /**\r\n * Optionally specifies a value for the \"toolVersion\" field in the output .api.json data file;\r\n * otherwise, the value will be the current version of the api-extractor-model package.\r\n */\r\n toolVersion?: string;\r\n\r\n /**\r\n * Set to true only when invoking API Extractor's test harness.\r\n *\r\n * @remarks\r\n * When `testMode` is true, the `toolVersion` field in the .api.json file is assigned an empty string\r\n * to prevent spurious diffs in output files tracked for tests.\r\n */\r\n testMode?: boolean;\r\n}\r\n\r\n/**\r\n * Represents an NPM package containing API declarations.\r\n *\r\n * @remarks\r\n *\r\n * This is part of the {@link ApiModel} hierarchy of classes, which are serializable representations of\r\n * API declarations.\r\n *\r\n * @public\r\n */\r\nexport class ApiPackage extends ApiItemContainerMixin(ApiNameMixin(ApiDocumentedItem)) {\r\n private readonly _tsdocConfiguration: TSDocConfiguration;\r\n\r\n public constructor(options: IApiPackageOptions) {\r\n super(options);\r\n\r\n this._tsdocConfiguration = options.tsdocConfiguration;\r\n }\r\n\r\n public static loadFromJsonFile(apiJsonFilename: string): ApiPackage {\r\n const jsonObject: IApiPackageJson = JsonFile.load(apiJsonFilename);\r\n\r\n if (!jsonObject || !jsonObject.metadata || typeof jsonObject.metadata.schemaVersion !== 'number') {\r\n throw new Error(\r\n `Error loading ${apiJsonFilename}:` +\r\n `\\nThe file format is not recognized; the \"metadata.schemaVersion\" field is missing or invalid`\r\n );\r\n }\r\n\r\n const schemaVersion: number = jsonObject.metadata.schemaVersion;\r\n\r\n if (schemaVersion < ApiJsonSchemaVersion.OLDEST_SUPPORTED) {\r\n throw new Error(\r\n `Error loading ${apiJsonFilename}:` +\r\n `\\nThe file format is version ${schemaVersion},` +\r\n ` whereas ${ApiJsonSchemaVersion.OLDEST_SUPPORTED} is the oldest version supported by this tool`\r\n );\r\n }\r\n\r\n let oldestForwardsCompatibleVersion: number = schemaVersion;\r\n if (jsonObject.metadata.oldestForwardsCompatibleVersion) {\r\n // Sanity check\r\n if (jsonObject.metadata.oldestForwardsCompatibleVersion > schemaVersion) {\r\n throw new Error(\r\n `Error loading ${apiJsonFilename}:` +\r\n `\\nInvalid file format; \"oldestForwardsCompatibleVersion\" cannot be newer than \"schemaVersion\"`\r\n );\r\n }\r\n oldestForwardsCompatibleVersion = jsonObject.metadata.oldestForwardsCompatibleVersion;\r\n }\r\n\r\n let versionToDeserialize: number = schemaVersion;\r\n if (versionToDeserialize > ApiJsonSchemaVersion.LATEST) {\r\n // If the file format is too new, can we treat it as some earlier compatible version\r\n // as indicated by oldestForwardsCompatibleVersion?\r\n versionToDeserialize = Math.max(oldestForwardsCompatibleVersion, ApiJsonSchemaVersion.LATEST);\r\n\r\n if (versionToDeserialize > ApiJsonSchemaVersion.LATEST) {\r\n // Nope, still too new\r\n throw new Error(\r\n `Error loading ${apiJsonFilename}:` +\r\n `\\nThe file format version ${schemaVersion} was written by a newer release of` +\r\n ` the api-extractor-model library; you may need to upgrade your software`\r\n );\r\n }\r\n }\r\n\r\n const tsdocConfiguration: TSDocConfiguration = new TSDocConfiguration();\r\n\r\n if (versionToDeserialize >= ApiJsonSchemaVersion.V_1004) {\r\n const tsdocConfigFile: TSDocConfigFile = TSDocConfigFile.loadFromObject(\r\n jsonObject.metadata.tsdocConfig\r\n );\r\n if (tsdocConfigFile.hasErrors) {\r\n throw new Error(`Error loading ${apiJsonFilename}:\\n` + tsdocConfigFile.getErrorSummary());\r\n }\r\n\r\n tsdocConfigFile.configureParser(tsdocConfiguration);\r\n }\r\n\r\n const context: DeserializerContext = new DeserializerContext({\r\n apiJsonFilename,\r\n toolPackage: jsonObject.metadata.toolPackage,\r\n toolVersion: jsonObject.metadata.toolVersion,\r\n versionToDeserialize: versionToDeserialize,\r\n tsdocConfiguration\r\n });\r\n\r\n return ApiItem.deserialize(jsonObject, context) as ApiPackage;\r\n }\r\n\r\n /** @override */\r\n public get kind(): ApiItemKind {\r\n return ApiItemKind.Package;\r\n }\r\n\r\n /** @override */\r\n public get containerKey(): string {\r\n // No prefix needed, because ApiPackage is the only possible member of an ApiModel\r\n return this.name;\r\n }\r\n\r\n public get entryPoints(): ReadonlyArray<ApiEntryPoint> {\r\n return this.members as ReadonlyArray<ApiEntryPoint>;\r\n }\r\n\r\n /**\r\n * The TSDoc configuration that was used when analyzing the API for this package.\r\n *\r\n * @remarks\r\n *\r\n * Normally this configuration is loaded from the project's tsdoc.json file. It is stored\r\n * in the .api.json file so that doc comments can be parsed accurately when loading the file.\r\n */\r\n public get tsdocConfiguration(): TSDocConfiguration {\r\n return this._tsdocConfiguration;\r\n }\r\n\r\n /** @override */\r\n public addMember(member: ApiEntryPoint): void {\r\n if (member.kind !== ApiItemKind.EntryPoint) {\r\n throw new Error('Only items of type ApiEntryPoint may be added to an ApiPackage');\r\n }\r\n super.addMember(member);\r\n }\r\n\r\n public findEntryPointsByPath(importPath: string): ReadonlyArray<ApiEntryPoint> {\r\n return this.findMembersByName(importPath) as ReadonlyArray<ApiEntryPoint>;\r\n }\r\n\r\n public saveToJsonFile(apiJsonFilename: string, options?: IApiPackageSaveOptions): void {\r\n if (!options) {\r\n options = {};\r\n }\r\n\r\n const packageJson: IPackageJson = PackageJsonLookup.loadOwnPackageJson(__dirname);\r\n\r\n const tsdocConfigFile: TSDocConfigFile = TSDocConfigFile.loadFromParser(this.tsdocConfiguration);\r\n const tsdocConfig: JsonObject = tsdocConfigFile.saveToObject();\r\n\r\n const jsonObject: IApiPackageJson = {\r\n metadata: {\r\n toolPackage: options.toolPackage || packageJson.name,\r\n // In test mode, we don't write the real version, since that would cause spurious diffs whenever\r\n // the version is bumped. Instead we write a placeholder string.\r\n toolVersion: options.testMode ? '[test mode]' : options.toolVersion || packageJson.version,\r\n schemaVersion: ApiJsonSchemaVersion.LATEST,\r\n oldestForwardsCompatibleVersion: ApiJsonSchemaVersion.OLDEST_FORWARDS_COMPATIBLE,\r\n tsdocConfig\r\n }\r\n } as IApiPackageJson;\r\n this.serializeInto(jsonObject);\r\n JsonFile.save(jsonObject, apiJsonFilename, options);\r\n }\r\n\r\n /** @beta @override */\r\n public buildCanonicalReference(): DeclarationReference {\r\n return DeclarationReference.package(this.name);\r\n }\r\n}\r\n"]}
|