diff options
Diffstat (limited to 'node_modules/@terwer/typedoc-plugin-markdown/dist/resources/partials/toc.js')
-rw-r--r-- | node_modules/@terwer/typedoc-plugin-markdown/dist/resources/partials/toc.js | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/node_modules/@terwer/typedoc-plugin-markdown/dist/resources/partials/toc.js b/node_modules/@terwer/typedoc-plugin-markdown/dist/resources/partials/toc.js new file mode 100644 index 0000000..19d315e --- /dev/null +++ b/node_modules/@terwer/typedoc-plugin-markdown/dist/resources/partials/toc.js @@ -0,0 +1,76 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.toc = void 0; +const typedoc_1 = require("typedoc"); +const els_1 = require("../../support/els"); +const utils_1 = require("../../support/utils"); +function toc(context, reflection) { + var _a, _b, _c; + const md = []; + const hideInPageTOC = context.getOption('hideInPageTOC'); + const isVisible = (_a = reflection.groups) === null || _a === void 0 ? void 0 : _a.some((group) => group.allChildrenHaveOwnDocument()); + if ((!hideInPageTOC && reflection.groups) || + (isVisible && reflection.groups)) { + const headingLevel = getIndexHeadingLevel(reflection); + const subHeadingLevel = headingLevel + 1; + md.push((0, els_1.heading)(headingLevel, 'Index\n')); + if ((_b = reflection.categories) === null || _b === void 0 ? void 0 : _b.length) { + reflection.categories.forEach((item) => { + md.push((0, els_1.heading)(subHeadingLevel, item.title) + '\n'); + md.push(getGroup(context, item) + '\n'); + }); + } + else { + if (context.getOption('excludeGroups') && reflection.children) { + md.push(reflection.children + .map((child) => { + return getTocItem(context, child); + }) + .join('\n')); + } + else { + (_c = reflection.groups) === null || _c === void 0 ? void 0 : _c.forEach((reflectionGroup) => { + if (reflectionGroup.categories) { + md.push((0, els_1.heading)(subHeadingLevel, reflectionGroup.title) + '\n'); + reflectionGroup.categories.forEach((item2) => { + md.push((0, els_1.heading)(subHeadingLevel + 1, item2.title) + '\n'); + md.push(getGroup(context, reflectionGroup) + '\n'); + }); + } + else { + if (!hideInPageTOC || + reflectionGroup.allChildrenHaveOwnDocument()) { + md.push((0, els_1.heading)(subHeadingLevel, reflectionGroup.title) + '\n'); + md.push(getGroup(context, reflectionGroup) + '\n'); + } + } + }); + } + } + } + return md.length > 0 ? md.join('\n') : ''; +} +exports.toc = toc; +function getGroup(context, group) { + const children = group.children.map((child) => getTocItem(context, child)); + return children.join('\n'); +} +function getTocItem(context, reflection) { + const showKindTag = !reflection.kindOf(typedoc_1.ReflectionKind.Module) && + !context.getOption('hideKindTag') && + context.getOption('excludeGroups'); + return `- ${showKindTag + ? (0, els_1.backTicks)(Array.from(typedoc_1.ReflectionKind.singularString(reflection.kind))[0]) + ' ' + : ''}[${(0, utils_1.escapeChars)(reflection.name)}](${context.relativeURL(reflection.url)})`; +} +function getIndexHeadingLevel(reflection) { + if (reflection.kindOf([ + typedoc_1.ReflectionKind.Project, + typedoc_1.ReflectionKind.Module, + typedoc_1.ReflectionKind.Namespace, + ]) || + reflection.hasOwnDocument) { + return 2; + } + return 4; +} |