@storm-stack/core
Version:
A build toolkit and runtime used by Storm Software in TypeScript applications
98 lines (89 loc) • 3.28 kB
JavaScript
var chunkGRNJVY7I_cjs = require('./chunk-GRNJVY7I.cjs');
var Handlebars = require('handlebars');
var typedoc = require('typedoc');
function _interopNamespace(e) {
if (e && e.__esModule) return e;
var n = Object.create(null);
if (e) {
Object.keys(e).forEach(function (k) {
if (k !== 'default') {
var d = Object.getOwnPropertyDescriptor(e, k);
Object.defineProperty(n, k, d.get ? d : {
enumerable: true,
get: function () { return e[k]; }
});
}
});
}
n.default = e;
return Object.freeze(n);
}
var Handlebars__namespace = /*#__PURE__*/_interopNamespace(Handlebars);
function escapeChars(str) {
return str.replace(/>/g, "\\>").replace(/_/g, "\\_").replace(/`/g, "\\`").replace(/\|/g, "\\|");
}
chunkGRNJVY7I_cjs.__name(escapeChars, "escapeChars");
function stripLineBreaks(str) {
return str ? str.replace(/\n/g, " ").replace(/\r/g, " ").replace(/\t/g, " ").replace(/\s{2,}/g, " ").trim() : "";
}
chunkGRNJVY7I_cjs.__name(stripLineBreaks, "stripLineBreaks");
function registerTOCHelper(theme) {
function innerRegisterTOCHelper() {
const md = [];
const { hideInPageTOC } = theme;
const isVisible = this.groups?.some((group) => group.allChildrenHaveOwnDocument());
function pushGroup(group, md2) {
const children = group.children.map((child) => {
const propertyType = [
typedoc.ReflectionKind.Property,
typedoc.ReflectionKind.Variable
].includes(child.kind) ? `: ${getPropertyType(child)}` : "";
return `- [${escapeChars(child.name)}](${Handlebars__namespace.helpers.relativeURL ? Handlebars__namespace.helpers.relativeURL(child.url) : child.url})${propertyType}`;
});
md2.push(children.join("\n"));
}
chunkGRNJVY7I_cjs.__name(pushGroup, "pushGroup");
if (!hideInPageTOC && this.groups || isVisible && this.groups) {
if (!hideInPageTOC) {
md.push(`## Table of contents
`);
}
const headingLevel = hideInPageTOC ? `##` : `###`;
this.groups?.forEach((group) => {
const groupTitle = group.title;
if (group.categories) {
group.categories.forEach((category) => {
md.push(`${headingLevel} ${category.title} ${groupTitle}
`);
pushGroup(category, md);
md.push("\n");
});
} else if (!hideInPageTOC || group.allChildrenHaveOwnDocument()) {
md.push(`${headingLevel} ${groupTitle}
`);
pushGroup(group, md);
md.push("\n");
}
});
}
return md.length > 0 ? md.join("\n") : null;
}
chunkGRNJVY7I_cjs.__name(innerRegisterTOCHelper, "innerRegisterTOCHelper");
Handlebars__namespace.registerHelper("toc", innerRegisterTOCHelper);
}
chunkGRNJVY7I_cjs.__name(registerTOCHelper, "registerTOCHelper");
function getPropertyType(property) {
if (property.getSignature) {
return property.getSignature.type;
}
if (property.setSignature) {
return property.setSignature.type;
}
return property.type ? property.type : property;
}
chunkGRNJVY7I_cjs.__name(getPropertyType, "getPropertyType");
var toc_default = registerTOCHelper;
exports.escapeChars = escapeChars;
exports.stripLineBreaks = stripLineBreaks;
exports.toc_default = toc_default;
;