typedoc-plugin-markdown
Version:
A plugin for TypeDoc that enables TypeScript API documentation to be generated in Markdown.
43 lines (42 loc) • 1.8 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.typeAndParent = void 0;
const typedoc_1 = require("typedoc");
const theme_1 = require("../../theme");
const escape_1 = require("./escape");
function typeAndParent() {
var _a, _b, _c;
if (this) {
if ('elementType' in this) {
return typeAndParent.call(this.elementType) + '[]';
}
else {
if (this.reflection) {
const md = [];
if (this.reflection instanceof typedoc_1.SignatureReflection) {
if ((_b = (_a = this.reflection.parent) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.url) {
md.push(getUrl(this.reflection.parent.parent.name, this.reflection.parent.parent.url));
if (this.reflection.parent.url) {
md.push(getUrl(this.reflection.parent.name, this.reflection.parent.url));
}
}
}
else {
if ((_c = this.reflection.parent) === null || _c === void 0 ? void 0 : _c.url) {
md.push(getUrl(this.reflection.parent.name, this.reflection.parent.url));
if (this.reflection.url) {
md.push(getUrl(this.reflection.name, this.reflection.url));
}
}
}
return md.join('.');
}
else {
return escape_1.escape(this.toString());
}
}
}
return 'void';
}
exports.typeAndParent = typeAndParent;
const getUrl = (name, url) => `[${name}](${theme_1.default.HANDLEBARS.helpers.relativeURL(url)})`;