noogle/scripts/prepare.js
2022-12-09 16:41:59 +01:00

23 lines
603 B
JavaScript

const builtins = require("./data/builtins.json");
const types = require("./data/builtins.types.json");
const fs = require("fs");
const info = Object.entries(builtins).map(([name, meta]) => {
const fn_type = types[name]?.fn_type || null;
const { args, arity, doc } = meta;
return {
category: "builtins",
fn_type,
name,
description: [
`takes ${arity} arguments: __\`${args.join("` `")}\`__ \n`,
`${doc}\n`,
],
};
});
fs.writeFile("./models/builtins.json", JSON.stringify(info), (err) => {
if (err) {
console.error(err);
}
// file written successfully
});