Skip to content

Commit ca7d377

Browse files
authored
Add support for 'ssh_' modules (#12)
* Add support for 'ssh_' modules * Also include the dist files * Add some more info to the error * Explicitly skip the 'index' file * Add all of the non-module files in the 'src/modules' path * Fix index TOC output
1 parent 68e8b8d commit ca7d377

File tree

4 files changed

+43
-4
lines changed

4 files changed

+43
-4
lines changed

dist/lib/resources/helpers/toc.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
2424
};
2525
Object.defineProperty(exports, "__esModule", { value: true });
2626
const Handlebars = __importStar(require("handlebars"));
27-
function displayChild(child, children) {
27+
function displayChild(child, _children) {
2828
const md = [];
2929
// it is a module, print it
3030
md.push(`#### [${child.name}](${child.url})\n\n`);
@@ -80,7 +80,7 @@ function displayChild(child, children) {
8080
}
8181
function default_1(theme) {
8282
Handlebars.registerHelper("toc", function () {
83-
var _a, _b, _c;
83+
var _a, _b, _c, _d;
8484
const md = [];
8585
const { hideInPageTOC } = theme;
8686
const isVisible = (_a = this.groups) === null || _a === void 0 ? void 0 : _a.some((group) => group.allChildrenHaveOwnDocument());
@@ -117,6 +117,20 @@ function default_1(theme) {
117117
md.push(...content);
118118
}
119119
}
120+
// ssh
121+
const ssh = (_d = this.children) === null || _d === void 0 ? void 0 : _d.filter((child) => {
122+
var _a, _b;
123+
return ((_a = child.parent) === null || _a === void 0 ? void 0 : _a.id) == 0 &&
124+
child.kind == 2 &&
125+
((_b = child.url) === null || _b === void 0 ? void 0 : _b.startsWith("ssh"));
126+
});
127+
md.push("### Server (via SSH)");
128+
for (const child of ssh !== null && ssh !== void 0 ? ssh : []) {
129+
if (!child.name.includes("/")) {
130+
const content = displayChild(child, ssh !== null && ssh !== void 0 ? ssh : []);
131+
md.push(...content);
132+
}
133+
}
120134
}
121135
return md.length > 0 ? md.join("\n") : null;
122136
});

dist/lib/theme.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,12 @@ class MarkdownTheme extends typedoc_1.Theme {
112112
fragment = fragment + "aws";
113113
else if (url.startsWith("iasql"))
114114
fragment = fragment + "builtin";
115+
else if (url.startsWith("ssh"))
116+
fragment = fragment + "ssh";
117+
else if (['index', 'interfaces', 'subscribers',].includes(url))
118+
fragment = fragment; // Known static elements to skip
119+
else
120+
throw new Error(`Unsupported module type ${url}, please update the docusaurus plugin!`);
115121
if (mapping.directory == "enums")
116122
fragment = fragment + "/enums";
117123
else if (mapping.directory == "classes")
@@ -292,5 +298,5 @@ class MarkdownTheme extends typedoc_1.Theme {
292298
return "sql.md";
293299
}
294300
}
295-
exports.MarkdownTheme = MarkdownTheme;
296301
MarkdownTheme.URL_PREFIX = /^(http|ftp)s?:\/\//;
302+
exports.MarkdownTheme = MarkdownTheme;

src/lib/resources/helpers/toc.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { MarkdownTheme } from "../../theme";
44

55
function displayChild(
66
child: DeclarationReflection,
7-
children: DeclarationReflection[]
7+
_children: DeclarationReflection[]
88
) {
99
const md: string[] = [];
1010

@@ -114,6 +114,22 @@ export default function (theme: MarkdownTheme) {
114114
md.push(...content);
115115
}
116116
}
117+
118+
// ssh
119+
const ssh = this.children?.filter(
120+
(child) =>
121+
child.parent?.id == 0 &&
122+
child.kind == 2 &&
123+
child.url?.startsWith("ssh")
124+
);
125+
md.push("### Server (via SSH)");
126+
127+
for (const child of ssh ?? []) {
128+
if (!child.name.includes("/")) {
129+
const content = displayChild(child, ssh ?? []);
130+
md.push(...content);
131+
}
132+
}
117133
}
118134
return md.length > 0 ? md.join("\n") : null;
119135
}

src/lib/theme.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,9 @@ export class MarkdownTheme extends Theme {
145145
let fragment = "";
146146
if (url.startsWith("aws")) fragment = fragment + "aws";
147147
else if (url.startsWith("iasql")) fragment = fragment + "builtin";
148+
else if (url.startsWith("ssh")) fragment = fragment + "ssh";
149+
else if (['index', 'interfaces', 'subscribers', ].includes(url)) fragment = fragment; // Known static elements to skip
150+
else throw new Error(`Unsupported module type ${url}, please update the docusaurus plugin!`);
148151

149152
if (mapping.directory == "enums") fragment = fragment + "/enums";
150153
else if (mapping.directory == "classes") fragment = fragment + "/tables";

0 commit comments

Comments
 (0)