UNPKG

typedoc-plugin-markdown

Version:

A plugin for TypeDoc that enables TypeScript API documentation to be generated in Markdown.

42 lines (41 loc) 1.8 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.declarationTitle = void 0; const typedoc_1 = require("typedoc"); const models_1 = require("typedoc/dist/lib/models"); const escape_1 = require("./escape"); const member_symbol_1 = require("./member-symbol"); const strip_comments_1 = require("./strip-comments"); const strip_line_breaks_1 = require("./strip-line-breaks"); const type_1 = require("./type"); function declarationTitle() { var _a; const md = [member_symbol_1.memberSymbol.call(this)]; if (this.flags && this.flags.length > 0 && !this.flags.isRest) { md.push(' ' + this.flags.map((flag) => `\`${flag}\``).join(' ')); } md.push(`${this.flags.isRest ? '... ' : ''} **${escape_1.escape(this.name)}**`); if (this instanceof typedoc_1.DeclarationReflection && this.typeParameters) { md.push(`<${this.typeParameters .map((typeParameter) => `\`${typeParameter.name}\``) .join(', ')}\\>`); } if (!((_a = this.parent) === null || _a === void 0 ? void 0 : _a.kindOf(models_1.ReflectionKind.Enum))) { md.push(getType(this)); } if (!(this.type instanceof models_1.LiteralType) && this.defaultValue && this.defaultValue !== '...') { md.push(` = \`${strip_line_breaks_1.stripLineBreaks(strip_comments_1.stripComments(this.defaultValue))}\``); } return md.join(''); } exports.declarationTitle = declarationTitle; function getType(reflection) { var _a; const reflectionType = reflection.type; if (reflectionType && ((_a = reflectionType.declaration) === null || _a === void 0 ? void 0 : _a.children)) { return ': `Object`'; } return (': ' + type_1.type.call(reflectionType ? reflectionType : reflection, 'object')); }