UNPKG

dgeni-packages

Version:

A collection of dgeni packages for generating documentation from source code

42 lines 1.82 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ParameterDoc = void 0; const nodeToString_1 = require("../services/TsParser/nodeToString"); const ApiDoc_1 = require("./ApiDoc"); /** * This represents a call parameter of an exported function or of a method of a class or interface. * You can find them on the `FunctionExportDoc.parameters` or `MethodMemberDoc.parameters` properties. * They are generated by the call to `getParameters` service. */ class ParameterDoc extends ApiDoc_1.BaseApiDoc { constructor(container, symbol, declaration) { super(container.host, container.moduleDoc, symbol, declaration); this.container = container; this.symbol = symbol; this.declaration = declaration; this.docType = 'parameter'; this.type = this.getTypeString(this.declaration); this.isOptional = !!(this.declaration.questionToken); this.isRestParam = !!(this.declaration.dotDotDotToken); this.defaultValue = this.declaration.initializer && (0, nodeToString_1.nodeToString)(this.declaration.initializer); this.paramText = this.getParamText(); this.description = this.content; this.id = `${this.container.id}~${this.name}`; this.aliases = (this.container.aliases || []).map(alias => `${alias}~${this.name}`); } getParamText() { let paramText = ''; if (this.isRestParam) paramText += '...'; paramText += this.name; if (this.isOptional) paramText += '?'; if (this.type) paramText += ': ' + this.type; if (this.defaultValue) paramText += ' = ' + this.defaultValue; return paramText.trim(); } } exports.ParameterDoc = ParameterDoc; //# sourceMappingURL=ParameterDoc.js.map