-
Notifications
You must be signed in to change notification settings - Fork 89
/
Copy pathbuild-dialect.js
33 lines (26 loc) · 1002 Bytes
/
build-dialect.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/* eslint-disable @typescript-eslint/no-var-requires */
const fs = require("fs");
const path = require("path");
const showdown = require("showdown");
function build_dialect(dialectName) {
const dialectFolder = path.join(__dirname, "src", "drivers", dialectName);
const functionFolder = path.join(dialectFolder, "functions");
const functionFiles = fs.readdirSync(functionFolder);
const functions = {};
const mdConverter = new showdown.Converter({ tables: true });
for (const functionFile of functionFiles) {
const mdContent = fs
.readFileSync(path.join(functionFolder, functionFile))
.toString();
const mdContentLines = mdContent.split("\n");
functions[path.parse(functionFile).name] = {
syntax: mdContentLines[0],
description: mdConverter.makeHtml(mdContentLines.slice(2).join("\n")),
};
}
fs.writeFileSync(
path.join(dialectFolder, "function-tooltip.json"),
JSON.stringify(functions, undefined, 2)
);
}
build_dialect("sqlite");