Skip to content

Commit

Permalink
Merge pull request #9 from iasql/fix-urls
Browse files Browse the repository at this point in the history
fix toc
  • Loading branch information
yrobla authored Feb 13, 2023
2 parents 5aff39f + 77bf2c1 commit 3a008d6
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 36 deletions.
72 changes: 43 additions & 29 deletions dist/lib/resources/helpers/toc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) => {
Expand All @@ -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 : []);
Expand All @@ -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 : []);
Expand Down
13 changes: 6 additions & 7 deletions src/lib/resources/helpers/toc.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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[] = [];
Expand Down Expand Up @@ -59,7 +58,7 @@ function displayChild(
child2.url
})\n\n`
);
}
}*/
return md;
}

Expand All @@ -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
Expand All @@ -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") {
Expand All @@ -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("/")) {
Expand Down

0 comments on commit 3a008d6

Please sign in to comment.