"jshERP-web/vscode:/vscode.git/clone" did not exist on "c1cfeadf17ab6fb8109e8eab011019edbe403510"
Commit 9b09539b authored by Dave Machado's avatar Dave Machado Committed by GitHub
Browse files

Merge pull request #441 from davemachado/update-json-structure

Update JSON to set Section as attribute
parents 1ac92f2d d24ca12c
......@@ -12,3 +12,4 @@ script:
after_success:
- ./build.sh
- ./deploy.sh
\ No newline at end of file
......@@ -198,7 +198,7 @@ API | Description | Auth | HTTPS | Link |
| Verse | Check what's the latest version of your favorite open-source project | No | Yes | [Go!](https://verse.pawelad.xyz/) |
### Documents & Productivity
API | Description | Auth | HTTPS |Link |
API | Description | Auth | HTTPS | Link |
|---|---|---|---|---|
| File.io | File Sharing | No | Yes | [Go!](https://www.file.io) |
| pdflayer API | HTML/URL to PDF | No | Yes | [Go!](https://pdflayer.com) |
......@@ -547,4 +547,4 @@ API | Description | Auth | HTTPS | Link |
| OpenWeatherMap | Weather | `apiKey` | No | [Go!](http://openweathermap.org/api) |
| Weatherbit | Weather | `apiKey` | Yes | [Go!](https://www.weatherbit.io/api) |
| Wunderground | Weather | `apiKey` | Yes | [Go!](https://www.wunderground.com/weather/api/) |
| Yahoo! Weather | Weather | No | Yes | [Go!](https://developer.yahoo.com/weather/) |
| Yahoo! Weather | Weather | No | Yes | [Go!](https://developer.yahoo.com/weather/) |
\ No newline at end of file
......@@ -3,6 +3,7 @@
# create json directory if not already present
mkdir -p ../json
# parse API README and print (minified) JSON to stdout, redirect to /json
node md2json.js ../README.md > ../json/entries.min.json
node condenseMd.js ../README.md > single_table.md
node md2json.js single_table.md > ../json/entries.min.json
# beautify the previously created JSON file, redirect to /json
python -m json.tool ../json/entries.min.json > ../json/entries.json
fs = require('fs')
function setupMd(filename, anchor) {
fs.readFile(filename, 'utf8', function (err,text) {
if (err) {
return console.log(err);
}
var lines = text.split("\n"),
cur_line = 0,
line = "",
table_name = "",
col_num = 0,
cols = [],
rows = [],
arr = [];
function read_line() {
return lines[cur_line++];
}
while (true) {
var cols = [];
var rows = [];
while (line.indexOf(anchor) == -1 && cur_line != lines.length) {
line = read_line();
}
if (cur_line == lines.length) {
break;
}
table_name = line.split(anchor)[1];
read_line()
read_line()
while (true) {
line = read_line()
if (line.length < 2 || cur_line == lines.length) {
break
}
if (line.startsWith("|")) {
arr.push(line + table_name)
}
}
}
console.log(anchor + " entries")
console.log("API | Description | Auth | HTTPS | Link | Section")
console.log("|---|---|---|---|---|---|")
for (i = 0; i < arr.length; i++) {
console.log(arr[i])
}
});
}
if (process.argv.length < 3) {
console.log("No .md file passed!");
return;
}
if (process.argv.length < 4) {
anchorText = "###";
} else {
anchorText = process.argv[3];
}
setupMd(process.argv[2].toString(), anchorText);
\ No newline at end of file
......@@ -37,6 +37,7 @@ function handle(filename, anchor) {
var col_num = 0;
var cols = [];
var rows = [];
var entry_count = 0;
function read_line() {
return lines[cur_line++];
......@@ -100,6 +101,7 @@ function handle(filename, anchor) {
}
rows.push(row);
entry_count++;
line = read_line()
}
......@@ -113,6 +115,7 @@ function handle(filename, anchor) {
data.push(ele);
}
}
root["count"] = entry_count;
root[table_name] = data;
}
console.log(JSON.stringify(root));
......
This diff is collapsed.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment