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AC,UAAU,GAAG,EAAE,CAAC;SAC5B;IACH,CAAC;CACF;AA5CD,8CA4CC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport * as tsdoc from '@microsoft/tsdoc';\nimport { ApiItem, type IApiItemOptions, type IApiItemJson } from './ApiItem';\nimport type { DeserializerContext } from '../model/DeserializerContext';\n\n/**\n * Constructor options for {@link ApiDocumentedItem}.\n * @public\n */\nexport interface IApiDocumentedItemOptions extends IApiItemOptions {\n docComment: tsdoc.DocComment | undefined;\n}\n\nexport interface IApiDocumentedItemJson extends IApiItemJson {\n docComment: string;\n}\n\n/**\n * An abstract base class for API declarations that can have an associated TSDoc comment.\n *\n * @remarks\n *\n * This is part of the {@link ApiModel} hierarchy of classes, which are serializable representations of\n * API declarations.\n *\n * @public\n */\nexport class ApiDocumentedItem extends ApiItem {\n private _tsdocComment: tsdoc.DocComment | undefined;\n\n public constructor(options: IApiDocumentedItemOptions) {\n super(options);\n this._tsdocComment = options.docComment;\n }\n\n /** @override */\n public static onDeserializeInto(\n options: Partial<IApiDocumentedItemOptions>,\n context: DeserializerContext,\n jsonObject: IApiItemJson\n ): void {\n super.onDeserializeInto(options, context, jsonObject);\n\n const documentedJson: IApiDocumentedItemJson = jsonObject as IApiDocumentedItemJson;\n\n if (documentedJson.docComment) {\n const tsdocParser: tsdoc.TSDocParser = new tsdoc.TSDocParser(context.tsdocConfiguration);\n\n // NOTE: For now, we ignore TSDoc errors found in a serialized .api.json file.\n // Normally these errors would have already been reported by API Extractor during analysis.\n // However, they could also arise if the JSON file was edited manually, or if the file was saved\n // using a different release of the software that used an incompatible syntax.\n const parserContext: tsdoc.ParserContext = tsdocParser.parseString(documentedJson.docComment);\n\n options.docComment = parserContext.docComment;\n }\n }\n\n public get tsdocComment(): tsdoc.DocComment | undefined {\n return this._tsdocComment;\n }\n\n /** @override */\n public serializeInto(jsonObject: Partial<IApiDocumentedItemJson>): void {\n super.serializeInto(jsonObject);\n if (this.tsdocComment !== undefined) {\n jsonObject.docComment = this.tsdocComment.emitAsTsdoc();\n } else {\n jsonObject.docComment = '';\n }\n }\n}\n"]} |