make-events-files.js 865 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. const fs = require("fs");
  2. const process = require("process")
  3. const phaser_path = process.env.PHASER_PATH;
  4. const phaser_json_path = phaser_path + "/phaser3-docs/json/phaser.json";
  5. const content = fs.readFileSync(phaser_json_path);
  6. const data = JSON.parse(content.toString());
  7. const docsMap = {};
  8. let i = 1;
  9. for (const item of data.docs) {
  10. if (item.kind !== "event") {
  11. continue;
  12. }
  13. let { name, memberof } = item;
  14. const fullName = `${memberof}.${name}`;
  15. docsMap[fullName] = item.description || item.classdesc;
  16. console.log(`${i++} Processing event fullName`);
  17. }
  18. const output = JSON.stringify(docsMap, null, 2);
  19. console.log("---");
  20. console.log("Writing to file events.json...");
  21. fs.writeFileSync("../source/editor/plugins/phasereditor2d.resources/_res/phasereditor2d.scene/docs/events.json", output);
  22. console.log("Done.");