From 77bf2c106dde2a87110709d974dfafe15ede4fc6 Mon Sep 17 00:00:00 2001 From: Yolanda Date: Mon, 13 Feb 2023 08:05:21 +0100 Subject: [PATCH] fix toc --- dist/lib/resources/helpers/toc.js | 72 ++++++++++++++++++------------- src/lib/resources/helpers/toc.ts | 13 +++--- 2 files changed, 49 insertions(+), 36 deletions(-) diff --git a/dist/lib/resources/helpers/toc.js b/dist/lib/resources/helpers/toc.js index 2549f27..05f6907 100644 --- a/dist/lib/resources/helpers/toc.js +++ b/dist/lib/resources/helpers/toc.js @@ -24,44 +24,58 @@ var __importStar = (this && this.__importStar) || function (mod) { }; Object.defineProperty(exports, "__esModule", { value: true }); const Handlebars = __importStar(require("handlebars")); -const utils_1 = require("../../utils"); function displayChild(child, children) { - var _a, _b, _c; const md = []; // it is a module, print it - md.push(`### [${child.name}](${child.url})\n\n`); + md.push(`#### [${child.name}](${child.url})\n\n`); // now need to find the depending modules - const tables = []; - const methods = []; - const enums = []; - const filtered = children === null || children === void 0 ? void 0 : children.filter((x) => x.name.includes(child.name) && - (x.name.includes("entity") || x.name.includes("rpc"))); + /*const tables: DeclarationReflection[] = []; + const methods: DeclarationReflection[] = []; + const enums: DeclarationReflection[] = []; + + const filtered = children?.filter( + (x) => + x.name.includes(child.name) && + (x.name.includes("entity") || x.name.includes("rpc")) + ); + for (const filt of filtered) { - for (const item of (_a = filt.children) !== null && _a !== void 0 ? _a : []) { - if (item.kindString == "Class" && !((_b = item.url) === null || _b === void 0 ? void 0 : _b.includes("rpc"))) - tables.push(item); - if (item.kindString == "Class" && ((_c = item.url) === null || _c === void 0 ? void 0 : _c.includes("rpc"))) - methods.push(item); - if (item.kindString == "Enumeration") - enums.push(item); - } + for (const item of filt.children ?? []) { + if (item.kindString == "Class" && !item.url?.includes("rpc")) + tables.push(item); + if (item.kindString == "Class" && item.url?.includes("rpc")) + methods.push(item); + if (item.kindString == "Enumeration") enums.push(item); + } } + // display them - if (tables.length > 0) - md.push("  **Tables**\n"); + if (tables.length > 0) md.push("  **Tables**\n"); for (const child2 of tables) { - md.push(`      [${(0, utils_1.camelToSnakeCase)(child2.name)}](${child2.url})\n\n`); + md.push( + `      [${camelToSnakeCase(child2.name)}](${ + child2.url + })\n\n` + ); } - if (methods.length > 0) - md.push("  **Functions**\n"); + if (methods.length > 0) md.push("  **Functions**\n"); + for (const child2 of methods) { - md.push(`      [${(0, utils_1.camelToSnakeCase)(child2.name)}](${child2.url})\n\n`); + md.push( + `      [${camelToSnakeCase(child2.name)}](${ + child2.url + })\n\n` + ); } - if (enums.length > 0) - md.push("  **Enums**\n"); + if (enums.length > 0) md.push("  **Enums**\n"); + for (const child2 of enums) { - md.push(`      [${(0, utils_1.camelToSnakeCase)(child2.name)}](${child2.url})\n\n`); - } + md.push( + `      [${camelToSnakeCase(child2.name)}](${ + child2.url + })\n\n` + ); + }*/ return md; } function default_1(theme) { @@ -72,7 +86,7 @@ function default_1(theme) { const isVisible = (_a = this.groups) === null || _a === void 0 ? void 0 : _a.some((group) => group.allChildrenHaveOwnDocument()); if ((!hideInPageTOC && this.groups) || (isVisible && this.groups)) { if (!hideInPageTOC) { - md.push(`# Table of contents\n\n`); + md.push(`## Table of contents\n\n`); } // builtin const builtin = (_b = this.children) === null || _b === void 0 ? void 0 : _b.filter((child) => { @@ -81,7 +95,7 @@ function default_1(theme) { child.kind == 2 && ((_b = child.url) === null || _b === void 0 ? void 0 : _b.startsWith("builtin")); }); - md.push("## Builtin"); + md.push("### Builtin"); for (const child of builtin !== null && builtin !== void 0 ? builtin : []) { if (child.name == "iasql_functions") { const content = displayChild(child, builtin !== null && builtin !== void 0 ? builtin : []); @@ -95,7 +109,7 @@ function default_1(theme) { child.kind == 2 && ((_b = child.url) === null || _b === void 0 ? void 0 : _b.startsWith("aws")); }); - md.push("## AWS"); + md.push("### AWS"); for (const child of aws !== null && aws !== void 0 ? aws : []) { if (!child.name.includes("/")) { const content = displayChild(child, aws !== null && aws !== void 0 ? aws : []); diff --git a/src/lib/resources/helpers/toc.ts b/src/lib/resources/helpers/toc.ts index 1f53b57..7527c0a 100644 --- a/src/lib/resources/helpers/toc.ts +++ b/src/lib/resources/helpers/toc.ts @@ -1,7 +1,6 @@ import * as Handlebars from "handlebars"; import { DeclarationReflection, ProjectReflection } from "typedoc"; import { MarkdownTheme } from "../../theme"; -import { camelToSnakeCase } from "../../utils"; function displayChild( child: DeclarationReflection, @@ -10,10 +9,10 @@ function displayChild( const md: string[] = []; // it is a module, print it - md.push(`### [${child.name}](${child.url})\n\n`); + md.push(`#### [${child.name}](${child.url})\n\n`); // now need to find the depending modules - const tables: DeclarationReflection[] = []; + /*const tables: DeclarationReflection[] = []; const methods: DeclarationReflection[] = []; const enums: DeclarationReflection[] = []; @@ -59,7 +58,7 @@ function displayChild( child2.url })\n\n` ); - } + }*/ return md; } @@ -77,7 +76,7 @@ export default function (theme: MarkdownTheme) { if ((!hideInPageTOC && this.groups) || (isVisible && this.groups)) { if (!hideInPageTOC) { - md.push(`# Table of contents\n\n`); + md.push(`## Table of contents\n\n`); } // builtin @@ -88,7 +87,7 @@ export default function (theme: MarkdownTheme) { child.url?.startsWith("builtin") ); - md.push("## Builtin"); + md.push("### Builtin"); for (const child of builtin ?? []) { if (child.name == "iasql_functions") { @@ -104,7 +103,7 @@ export default function (theme: MarkdownTheme) { child.kind == 2 && child.url?.startsWith("aws") ); - md.push("## AWS"); + md.push("### AWS"); for (const child of aws ?? []) { if (!child.name.includes("/")) {