1 line
8.3 KiB
Plaintext
1 line
8.3 KiB
Plaintext
{"version":3,"file":"DocDeclarationReference.js","sourceRoot":"","sources":["../../src/nodes/DocDeclarationReference.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAA+F;AAG/F,2CAAuD;AACvD,2DAA0D;AAC1D,yDAAwD;AAsBxD;;;;;;GAMG;AACH;IAA6C,2CAAO;IAYlD;;;OAGG;IACH,iCACE,UAAyF;;QAD3F,YAGE,kBAAM,UAAU,CAAC,SAwClB;QAtCC,IAAI,iBAAO,CAAC,kBAAkB,CAAC,UAAU,CAAC,EAAE;YAC1C,IAAI,UAAU,CAAC,kBAAkB,EAAE;gBACjC,KAAI,CAAC,mBAAmB,GAAG,IAAI,uBAAU,CAAC;oBACxC,aAAa,EAAE,KAAI,CAAC,aAAa;oBACjC,WAAW,EAAE,wBAAW,CAAC,gCAAgC;oBACzD,OAAO,EAAE,UAAU,CAAC,kBAAkB;iBACvC,CAAC,CAAC;aACJ;YACD,IAAI,UAAU,CAAC,iBAAiB,EAAE;gBAChC,KAAI,CAAC,kBAAkB,GAAG,IAAI,uBAAU,CAAC;oBACvC,aAAa,EAAE,KAAI,CAAC,aAAa;oBACjC,WAAW,EAAE,wBAAW,CAAC,+BAA+B;oBACxD,OAAO,EAAE,UAAU,CAAC,iBAAiB;iBACtC,CAAC,CAAC;aACJ;YACD,IAAI,UAAU,CAAC,iBAAiB,EAAE;gBAChC,KAAI,CAAC,kBAAkB,GAAG,IAAI,uBAAU,CAAC;oBACvC,aAAa,EAAE,KAAI,CAAC,aAAa;oBACjC,WAAW,EAAE,wBAAW,CAAC,+BAA+B;oBACxD,OAAO,EAAE,UAAU,CAAC,iBAAiB;iBACtC,CAAC,CAAC;aACJ;YACD,IAAI,UAAU,CAAC,6BAA6B,EAAE;gBAC5C,KAAI,CAAC,8BAA8B,GAAG,IAAI,uBAAU,CAAC;oBACnD,aAAa,EAAE,KAAI,CAAC,aAAa;oBACjC,WAAW,EA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,GAAlB;QACE,IAAM,aAAa,GAAkB,IAAI,6BAAa,EAAE,CAAC;QACzD,IAAM,OAAO,GAAiB,IAAI,2BAAY,EAAE,CAAC;QACjD,OAAO,CAAC,0BAA0B,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;QACxD,OAAO,aAAa,CAAC,QAAQ,EAAE,CAAC;IAClC,CAAC;IAED,gBAAgB;IACN,iDAAe,GAAzB;QACE;YACE,IAAI,CAAC,mBAAmB;YACxB,IAAI,CAAC,kBAAkB;YACvB,IAAI,CAAC,kBAAkB;YACvB,IAAI,CAAC,8BAA8B;WAChC,IAAI,CAAC,iBAAiB,EACzB;IACJ,CAAC;IACH,8BAAC;AAAD,CAAC,AA/HD,CAA6C,iBAAO,GA+HnD;AA/HY,0DAAuB","sourcesContent":["import { DocNode, DocNodeKind, IDocNodeParameters, IDocNodeParsedParameters } from './DocNode';\r\nimport { DocMemberReference } from './DocMemberReference';\r\nimport { TokenSequence } from '../parser/TokenSequence';\r\nimport { DocExcerpt, ExcerptKind } from './DocExcerpt';\r\nimport { StringBuilder } from '../emitters/StringBuilder';\r\nimport { TSDocEmitter } from '../emitters/TSDocEmitter';\r\n\r\n/**\r\n * Constructor parameters for {@link DocDeclarationReference}.\r\n */\r\nexport interface IDocDeclarationReferenceParameters extends IDocNodeParameters {\r\n packageName?: string;\r\n importPath?: string;\r\n memberReferences?: DocMemberReference[];\r\n}\r\n\r\n/**\r\n * Constructor parameters for {@link DocDeclarationReference}.\r\n */\r\nexport interface IDocDeclarationReferenceParsedParameters extends IDocNodeParsedParameters {\r\n packageNameExcerpt?: TokenSequence;\r\n importPathExcerpt?: TokenSequence;\r\n importHashExcerpt?: TokenSequence;\r\n spacingAfterImportHashExcerpt?: TokenSequence;\r\n memberReferences?: DocMemberReference[];\r\n}\r\n\r\n/**\r\n * Represents a declaration reference.\r\n *\r\n * @remarks\r\n * Declaration references are TSDoc expressions used by tags such as `{@link}`\r\n * or `{@inheritDoc}` that need to refer to another declaration.\r\n */\r\nexport class DocDeclarationReference extends DocNode {\r\n private _packageName: string | undefined;\r\n private readonly _packageNameExcerpt: DocExcerpt | undefined;\r\n\r\n private _importPath: string | undefined;\r\n private readonly _importPathExcerpt: DocExcerpt | undefined;\r\n\r\n private readonly _importHashExcerpt: DocExcerpt | undefined;\r\n private readonly _spacingAfterImportHashExcerpt: DocExcerpt | undefined;\r\n\r\n private readonly _memberReferences: DocMemberReference[];\r\n\r\n /**\r\n * Don't call this directly. Instead use {@link TSDocParser}\r\n * @internal\r\n */\r\n public constructor(\r\n parameters: IDocDeclarationReferenceParameters | IDocDeclarationReferenceParsedParameters\r\n ) {\r\n super(parameters);\r\n\r\n if (DocNode.isParsedParameters(parameters)) {\r\n if (parameters.packageNameExcerpt) {\r\n this._packageNameExcerpt = new DocExcerpt({\r\n configuration: this.configuration,\r\n excerptKind: ExcerptKind.DeclarationReference_PackageName,\r\n content: parameters.packageNameExcerpt\r\n });\r\n }\r\n if (parameters.importPathExcerpt) {\r\n this._importPathExcerpt = new DocExcerpt({\r\n configuration: this.configuration,\r\n excerptKind: ExcerptKind.DeclarationReference_ImportPath,\r\n content: parameters.importPathExcerpt\r\n });\r\n }\r\n if (parameters.importHashExcerpt) {\r\n this._importHashExcerpt = new DocExcerpt({\r\n configuration: this.configuration,\r\n excerptKind: ExcerptKind.DeclarationReference_ImportHash,\r\n content: parameters.importHashExcerpt\r\n });\r\n }\r\n if (parameters.spacingAfterImportHashExcerpt) {\r\n this._spacingAfterImportHashExcerpt = new DocExcerpt({\r\n configuration: this.configuration,\r\n excerptKind: ExcerptKind.Spacing,\r\n content: parameters.spacingAfterImportHashExcerpt\r\n });\r\n }\r\n } else {\r\n this._packageName = parameters.packageName;\r\n this._importPath = parameters.importPath;\r\n }\r\n\r\n this._memberReferences = [];\r\n if (parameters.memberReferences) {\r\n this._memberReferences.push(...parameters.memberReferences);\r\n }\r\n }\r\n\r\n /** @override */\r\n public get kind(): DocNodeKind | string {\r\n return DocNodeKind.DeclarationReference;\r\n }\r\n\r\n /**\r\n * The optional package name, which may optionally include an NPM scope.\r\n *\r\n * Example: `\"@scope/my-package\"`\r\n */\r\n public get packageName(): string | undefined {\r\n if (this._packageName === undefined) {\r\n if (this._packageNameExcerpt !== undefined) {\r\n this._packageName = this._packageNameExcerpt.content.toString();\r\n }\r\n }\r\n return this._packageName;\r\n }\r\n\r\n /**\r\n * The optional import path. If a package name is provided, then if an import path is provided,\r\n * the path must start with a \"/\" delimiter; otherwise paths are resolved relative to the source file\r\n * containing the reference.\r\n *\r\n * Example: `\"/path1/path2\"`\r\n * Example: `\"./path1/path2\"`\r\n * Example: `\"../path2/path2\"`\r\n */\r\n public get importPath(): string | undefined {\r\n if (this._importPath === undefined) {\r\n if (this._importPathExcerpt !== undefined) {\r\n this._importPath = this._importPathExcerpt.content.toString();\r\n }\r\n }\r\n return this._importPath;\r\n }\r\n\r\n /**\r\n * The chain of member references that indicate the declaration being referenced.\r\n * If this list is empty, then either the packageName or importPath must be provided,\r\n * because the reference refers to a module.\r\n */\r\n public get memberReferences(): ReadonlyArray<DocMemberReference> {\r\n return this._memberReferences;\r\n }\r\n\r\n /**\r\n * Generates the TSDoc representation of this declaration reference.\r\n */\r\n public emitAsTsdoc(): string {\r\n const stringBuilder: StringBuilder = new StringBuilder();\r\n const emitter: TSDocEmitter = new TSDocEmitter();\r\n emitter.renderDeclarationReference(stringBuilder, this);\r\n return stringBuilder.toString();\r\n }\r\n\r\n /** @override */\r\n protected onGetChildNodes(): ReadonlyArray<DocNode | undefined> {\r\n return [\r\n this._packageNameExcerpt,\r\n this._importPathExcerpt,\r\n this._importHashExcerpt,\r\n this._spacingAfterImportHashExcerpt,\r\n ...this._memberReferences\r\n ];\r\n }\r\n}\r\n"]} |