UNPKG

@storm-stack/core

Version:

A build toolkit and runtime used by Storm Software in TypeScript applications

226 lines (216 loc) 6.82 kB
'use strict'; var chunk3ONWID2V_cjs = require('./chunk-3ONWID2V.cjs'); var typedoc = require('typedoc'); var theme = require('typedoc-plugin-markdown/dist/theme'); var Handlebars = require('handlebars'); 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 registerCommentHelper() { Handlebars__namespace.registerHelper("comment", (parts) => { const result = []; for (const part of parts) { switch (part.kind) { case "text": case "code": result.push(part.text); break; case "inline-tag": switch (part.tag) { case "@label": case "@inheritdoc": break; case "@link": case "@linkcode": case "@linkplain": { if (part.target) { const url = typeof part.target === "string" ? part.target : Handlebars__namespace.helpers.relativeURL ? Handlebars__namespace.helpers.relativeURL(part.target.url) : ""; const wrap = part.tag === "@linkcode" ? "`" : ""; result.push(url ? `[${wrap}${part.text}${wrap}](${url})` : part.text); } else { result.push(part.text); } break; } default: result.push(`{${part.tag} ${part.text}}`); break; } break; default: result.push(""); } } return result.join("").split("\n").filter((line) => !line.startsWith("@note")).join("\n"); }); } chunk3ONWID2V_cjs.__name(registerCommentHelper, "registerCommentHelper"); var comment_default = registerCommentHelper; function escapeChars(str) { return str.replace(/>/g, "\\>").replace(/_/g, "\\_").replace(/`/g, "\\`").replace(/\|/g, "\\|"); } chunk3ONWID2V_cjs.__name(escapeChars, "escapeChars"); 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")); } chunk3ONWID2V_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; } chunk3ONWID2V_cjs.__name(innerRegisterTOCHelper, "innerRegisterTOCHelper"); Handlebars__namespace.registerHelper("toc", innerRegisterTOCHelper); } chunk3ONWID2V_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; } chunk3ONWID2V_cjs.__name(getPropertyType, "getPropertyType"); var toc_default = registerTOCHelper; // src/lib/typedoc/helpers/theme.ts var StormStackMarkdownTheme = class extends theme.MarkdownTheme { static { chunk3ONWID2V_cjs.__name(this, "StormStackMarkdownTheme"); } constructor(renderer) { super(renderer); toc_default(this); comment_default(); } render(page, template) { return super.render(page, template).replace(/\.md/gi, "").replace(/\/devkit\//gi, "/devkit/documents/"); } get mappings() { return [ { kind: [ typedoc.ReflectionKind.Module ], isLeaf: true, directory: ".", template: this.getReflectionTemplate() }, { kind: [ typedoc.ReflectionKind.Enum ], isLeaf: false, directory: ".", template: this.getReflectionTemplate() }, { kind: [ typedoc.ReflectionKind.Class ], isLeaf: false, directory: ".", template: this.getReflectionTemplate() }, { kind: [ typedoc.ReflectionKind.Interface ], isLeaf: false, directory: ".", template: this.getReflectionTemplate() }, ...this.allReflectionsHaveOwnDocument ? [ { kind: [ typedoc.ReflectionKind.TypeAlias ], isLeaf: true, directory: ".", template: this.getReflectionMemberTemplate() }, { kind: [ typedoc.ReflectionKind.Variable ], isLeaf: true, directory: ".", template: this.getReflectionMemberTemplate() }, { kind: [ typedoc.ReflectionKind.Function ], isLeaf: true, directory: ".", template: this.getReflectionMemberTemplate() } ] : [] ]; } /** * Returns the full url of a given mapping and reflection * * @param mapping - The mapping object * @param reflection - The reflection object */ toUrl(mapping, reflection) { return `${(mapping.directory === "." ? "" : `${mapping.directory}/`) + this.getUrl(reflection)}.md`; } }; // src/lib/typedoc/index.ts function load(app) { app.renderer.defineTheme("storm-stack", StormStackMarkdownTheme); } chunk3ONWID2V_cjs.__name(load, "load"); exports.load = load; //# sourceMappingURL=chunk-J6AF5QZA.cjs.map //# sourceMappingURL=chunk-J6AF5QZA.cjs.map