Skip to content

Commit 2c01219

Browse files
authored
Merge pull request #4 from iasql/issue-1821
updated plugin for top level module
2 parents a11be12 + ff63713 commit 2c01219

31 files changed

+340
-57
lines changed

dist/lib/render-utils.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ const if_is_reference_1 = __importDefault(require("./resources/helpers/if-is-ref
4040
const if_is_equal_1 = __importDefault(require("./resources/helpers/if-is-equal"));
4141
const if_is_table_1 = __importDefault(require("./resources/helpers/if-is-table"));
4242
const if_is_enum_1 = __importDefault(require("./resources/helpers/if-is-enum"));
43+
const if_is_module_1 = __importDefault(require("./resources/helpers/if-is-module"));
4344
const render_type_1 = __importDefault(require("./resources/helpers/render-type"));
45+
const render_components_1 = __importDefault(require("./resources/helpers/render-components"));
4446
const if_named_anchors_1 = __importDefault(require("./resources/helpers/if-named-anchors"));
4547
const if_show_breadcrumbs_1 = __importDefault(require("./resources/helpers/if-show-breadcrumbs"));
4648
const if_show_named_anchors_1 = __importDefault(require("./resources/helpers/if-show-named-anchors"));
@@ -86,8 +88,10 @@ function registerHelpers(theme) {
8688
(0, if_is_reference_1.default)();
8789
(0, if_is_equal_1.default)();
8890
(0, if_is_table_1.default)();
91+
(0, if_is_module_1.default)();
8992
(0, if_is_enum_1.default)();
9093
(0, render_type_1.default)(theme);
94+
(0, render_components_1.default)(theme);
9195
(0, if_named_anchors_1.default)(theme);
9296
(0, if_show_breadcrumbs_1.default)(theme);
9397
(0, if_show_named_anchors_1.default)(theme);
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
import { MarkdownTheme } from '../../theme';
22
export default function (theme: MarkdownTheme): void;
3+
/**
4+
* Load the given file and return its contents.
5+
*
6+
* @param file The path of the file to read.
7+
* @returns The files contents.
8+
*/
39
export declare function readFile(file: string): string;

dist/lib/resources/helpers/comment.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,12 @@ function parseMarkdown(text, theme) {
9999
}
100100
return text;
101101
}
102+
/**
103+
* Load the given file and return its contents.
104+
*
105+
* @param file The path of the file to read.
106+
* @returns The files contents.
107+
*/
102108
function readFile(file) {
103109
const buffer = fs.readFileSync(file);
104110
switch (buffer[0]) {

dist/lib/resources/helpers/declaration-title.js

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,12 @@ const typedoc_1 = require("typedoc");
2828
const utils_1 = require("../../utils");
2929
function default_1(theme) {
3030
Handlebars.registerHelper("declarationTitle", function () {
31-
const md = theme.hideMembersSymbol ? [] : [(0, utils_1.memberSymbol)(this)];
31+
var _a, _b;
32+
let md;
33+
if (((_a = this.parent) === null || _a === void 0 ? void 0 : _a.kindString) != "Module")
34+
md = theme.hideMembersSymbol ? [] : [(0, utils_1.memberSymbol)(this)];
35+
else
36+
md = [];
3237
function getType(reflection) {
3338
var _a, _b;
3439
const reflectionType = reflection.type;
@@ -38,20 +43,22 @@ function default_1(theme) {
3843
return ((((_b = reflection.parent) === null || _b === void 0 ? void 0 : _b.kindOf(typedoc_1.ReflectionKind.Enum)) ? " = " : ": ") +
3944
Handlebars.helpers.type.call(reflectionType ? reflectionType : reflection, "object"));
4045
}
41-
if (this.flags && this.flags.length > 0 && !this.flags.isRest) {
42-
md.push(" " + this.flags.map((flag) => `\`${flag}\``).join(" "));
43-
}
44-
md.push(`${this.flags.isRest ? "... " : ""} **${(0, utils_1.escapeChars)((0, utils_1.camelToSnakeCase)(this.name))}**`);
45-
if (this instanceof typedoc_1.DeclarationReflection && this.typeParameters) {
46-
md.push(`<${this.typeParameters
47-
.map((typeParameter) => `\`${(0, utils_1.camelToSnakeCase)(typeParameter.name)}\``)
48-
.join(", ")}\\>`);
49-
}
50-
md.push(getType(this));
51-
if (!(this.type instanceof typedoc_1.LiteralType) &&
52-
this.defaultValue &&
53-
this.defaultValue !== "...") {
54-
md.push(` = \`${(0, utils_1.stripLineBreaks)((0, utils_1.stripComments)(this.defaultValue))}\``);
46+
if (((_b = this.parent) === null || _b === void 0 ? void 0 : _b.kindString) != "Module") {
47+
if (this.flags && this.flags.length > 0 && !this.flags.isRest) {
48+
md.push(" " + this.flags.map((flag) => `\`${flag}\``).join(" "));
49+
}
50+
md.push(`${this.flags.isRest ? "... " : ""} **${(0, utils_1.escapeChars)((0, utils_1.camelToSnakeCase)(this.name))}**`);
51+
if (this instanceof typedoc_1.DeclarationReflection && this.typeParameters) {
52+
md.push(`<${this.typeParameters
53+
.map((typeParameter) => `\`${(0, utils_1.camelToSnakeCase)(typeParameter.name)}\``)
54+
.join(", ")}\\>`);
55+
}
56+
md.push(getType(this));
57+
if (!(this.type instanceof typedoc_1.LiteralType) &&
58+
this.defaultValue &&
59+
this.defaultValue !== "...") {
60+
md.push(` = \`${(0, utils_1.stripLineBreaks)((0, utils_1.stripComments)(this.defaultValue))}\``);
61+
}
5562
}
5663
return md.join("");
5764
});
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default function (): void;
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
"use strict";
2+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3+
if (k2 === undefined) k2 = k;
4+
var desc = Object.getOwnPropertyDescriptor(m, k);
5+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6+
desc = { enumerable: true, get: function() { return m[k]; } };
7+
}
8+
Object.defineProperty(o, k2, desc);
9+
}) : (function(o, m, k, k2) {
10+
if (k2 === undefined) k2 = k;
11+
o[k2] = m[k];
12+
}));
13+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14+
Object.defineProperty(o, "default", { enumerable: true, value: v });
15+
}) : function(o, v) {
16+
o["default"] = v;
17+
});
18+
var __importStar = (this && this.__importStar) || function (mod) {
19+
if (mod && mod.__esModule) return mod;
20+
var result = {};
21+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22+
__setModuleDefault(result, mod);
23+
return result;
24+
};
25+
Object.defineProperty(exports, "__esModule", { value: true });
26+
const Handlebars = __importStar(require("handlebars"));
27+
function default_1() {
28+
Handlebars.registerHelper("ifIsModule", function (arg1, options) {
29+
return arg1.kindString == "Module"
30+
? options.fn(this)
31+
: options.inverse(this);
32+
});
33+
}
34+
exports.default = default_1;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import { MarkdownTheme } from "../../theme";
2+
export default function (theme: MarkdownTheme): void;
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
"use strict";
2+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3+
if (k2 === undefined) k2 = k;
4+
var desc = Object.getOwnPropertyDescriptor(m, k);
5+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6+
desc = { enumerable: true, get: function() { return m[k]; } };
7+
}
8+
Object.defineProperty(o, k2, desc);
9+
}) : (function(o, m, k, k2) {
10+
if (k2 === undefined) k2 = k;
11+
o[k2] = m[k];
12+
}));
13+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14+
Object.defineProperty(o, "default", { enumerable: true, value: v });
15+
}) : function(o, v) {
16+
o["default"] = v;
17+
});
18+
var __importStar = (this && this.__importStar) || function (mod) {
19+
if (mod && mod.__esModule) return mod;
20+
var result = {};
21+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22+
__setModuleDefault(result, mod);
23+
return result;
24+
};
25+
Object.defineProperty(exports, "__esModule", { value: true });
26+
const typedoc_1 = require("typedoc");
27+
const Handlebars = __importStar(require("handlebars"));
28+
const utils_1 = require("../../utils");
29+
function default_1(theme) {
30+
Handlebars.registerHelper("renderComponents", function () {
31+
var _a, _b, _c, _d, _e, _f, _g;
32+
const items = [];
33+
(_a = this.parent) === null || _a === void 0 ? void 0 : _a.traverse((child) => {
34+
if (child instanceof typedoc_1.DeclarationReflection) {
35+
if (child.name.includes(this.name) &&
36+
(child.name.includes("entity") || child.name.includes("rpc"))) {
37+
items.push(child);
38+
}
39+
}
40+
});
41+
const md = [];
42+
// now need to find the depending modules
43+
const tables = [];
44+
const methods = [];
45+
const enums = [];
46+
for (const filt of items) {
47+
for (const item of (_b = filt.children) !== null && _b !== void 0 ? _b : []) {
48+
if (item.kindString == "Class" && !((_c = item.url) === null || _c === void 0 ? void 0 : _c.includes("rpc")))
49+
tables.push(item);
50+
if (item.kindString == "Class" && ((_d = item.url) === null || _d === void 0 ? void 0 : _d.includes("rpc")))
51+
methods.push(item);
52+
if (item.kindString == "Enumeration")
53+
enums.push(item);
54+
}
55+
}
56+
if (tables.length > 0 || methods.length > 0 || enums.length > 0)
57+
md.push("## Components\n\n");
58+
// display them
59+
if (tables.length > 0)
60+
md.push(`### Tables\n\n`);
61+
for (const child2 of tables) {
62+
md.push(`\u00a0\u00a0\u00a0\u00a0[${(0, utils_1.camelToSnakeCase)(child2.name)}](../../${(_e = child2.url) === null || _e === void 0 ? void 0 : _e.replace(".md", "")})\n\n`);
63+
}
64+
if (methods.length > 0)
65+
md.push(`### Functions\n`);
66+
for (const child2 of methods) {
67+
md.push(`\u00a0\u00a0\u00a0\u00a0[${(0, utils_1.camelToSnakeCase)(child2.name)}](../../${(_f = child2.url) === null || _f === void 0 ? void 0 : _f.replace(".md", "")})\n\n`);
68+
}
69+
if (enums.length > 0)
70+
md.push(`### Enums\n`);
71+
for (const child2 of enums) {
72+
md.push(`\u00a0\u00a0\u00a0\u00a0[${(0, utils_1.camelToSnakeCase)(child2.name)}](../../${(_g = child2.url) === null || _g === void 0 ? void 0 : _g.replace(".md", "")})\n\n`);
73+
}
74+
return md.join("");
75+
});
76+
}
77+
exports.default = default_1;

dist/lib/resources/helpers/render-type.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ const Handlebars = __importStar(require("handlebars"));
2727
function default_1(theme) {
2828
Handlebars.registerHelper("renderType", function () {
2929
var _a;
30+
// get type from url and class
3031
let type, color;
3132
if (this.kindString == "Class") {
3233
if ((_a = this.url) === null || _a === void 0 ? void 0 : _a.toLowerCase().includes("rpcs")) {
@@ -42,6 +43,10 @@ function default_1(theme) {
4243
type = "Enum";
4344
color = "CD3C94";
4445
}
46+
else if (this.kindString == "Module") {
47+
type = "module";
48+
color = "CE3D3D";
49+
}
4550
return `![${type}](https://img.shields.io/static/v1?label=&message=${type}&color=${color}&style=for-the-badge)`;
4651
});
4752
}

dist/lib/resources/helpers/toc.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ function default_1(theme) {
4343
? 1
4444
: 0;
4545
});
46+
// traverse all children with parent id = 0
4647
for (const child of sortedChildren) {
4748
if (((_c = child.parent) === null || _c === void 0 ? void 0 : _c.id) == 0 &&
4849
child.kind == 2 &&
@@ -51,7 +52,9 @@ function default_1(theme) {
5152
!child.name.includes("index") &&
5253
!child.name.includes("interfaces") &&
5354
!child.name.includes("subscribers")) {
54-
md.push(`### ${child.name}\n\n`);
55+
// it is a module, print it
56+
md.push(`### [${child.name}](${child.url})\n\n`);
57+
// now need to find the depending modules
5558
const tables = [];
5659
const methods = [];
5760
const enums = [];
@@ -67,6 +70,7 @@ function default_1(theme) {
6770
enums.push(item);
6871
}
6972
}
73+
// display them
7074
if (tables.length > 0)
7175
md.push("&nbsp;&nbsp;**Tables**\n");
7276
for (const child2 of tables) {

0 commit comments

Comments
 (0)