(dialectName)
| 4 | const showdown = require("showdown"); |
| 5 | |
| 6 | function build_dialect(dialectName) { |
| 7 | const dialectFolder = path.join(__dirname, "src", "drivers", dialectName); |
| 8 | const functionFolder = path.join(dialectFolder, "functions"); |
| 9 | const functionFiles = fs.readdirSync(functionFolder); |
| 10 | |
| 11 | const functions = {}; |
| 12 | |
| 13 | const mdConverter = new showdown.Converter({ tables: true }); |
| 14 | for (const functionFile of functionFiles) { |
| 15 | const mdContent = fs |
| 16 | .readFileSync(path.join(functionFolder, functionFile)) |
| 17 | .toString(); |
| 18 | |
| 19 | const mdContentLines = mdContent.split("\n"); |
| 20 | |
| 21 | functions[path.parse(functionFile).name] = { |
| 22 | syntax: mdContentLines[0], |
| 23 | description: mdConverter.makeHtml(mdContentLines.slice(2).join("\n")), |
| 24 | }; |
| 25 | } |
| 26 | |
| 27 | fs.writeFileSync( |
| 28 | path.join(dialectFolder, "function-tooltip.json"), |
| 29 | JSON.stringify(functions, undefined, 2) |
| 30 | ); |
| 31 | } |
| 32 | |
| 33 | build_dialect("sqlite"); |
no test coverage detected