Update md script and readme

This commit is contained in:
Valtteri Karesto
2022-03-08 09:55:40 +02:00
parent e4b10d12c2
commit daee9de96c
2 changed files with 17 additions and 3 deletions

View File

@@ -1,10 +1,10 @@
# How to generate markdown from language server rst-files
# How to generate json file from markdown files
Go to xrpl-hooks-docs folder
`cd xrpl-hooks-docs`
Then run the `convert-to-md.js` script in that folder:
`node convert-to-md.js`
Then run the `makeJson.js` script in that folder:
`node makeJson.js`
If everything goes well this should output `xrpl-hooks-docs-files.json` file which contains array of the error codes and markdown related to that.

View File

@@ -0,0 +1,14 @@
const fs = require("fs");
// Read all md files from md folders
const files = fs.readdirSync("./md");
const mdFiles = [];
files.forEach((file) => {
const fileName = file.split(".")[0];
const md = fs.readFileSync(`./md/${fileName}.md`).toString();
mdFiles.push({ code: fileName, markdown: md });
});
fs.writeFileSync("xrpl-hooks-docs-files.json", JSON.stringify(mdFiles));