This repository was archived by the owner on Jul 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparse-jsdoc.js
More file actions
59 lines (43 loc) · 1.33 KB
/
Copy pathparse-jsdoc.js
File metadata and controls
59 lines (43 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env node --harmony
'use strict';
const program = require('commander');
const fs = require('fs');
const path = require('path');
const parse = require("jsdoc-parse");
const dust = require('dustjs-helpers');
program
.arguments('<input>', 'The input js file')
.arguments('<output>', 'The output apib file')
.parse(process.argv);
if(program.args.length < 2) {
program.help();
// exits automatically
}
let input = program.args[0];
let output = program.args[1];
dust.config.whitespace = true;
dust.compileFn(fs.readFileSync(__dirname + path.sep + 'templates' + path.sep + 'function.tmpl', "utf-8"), 'function');
dust.helpers.formatType = function (chunk, context, bodies, params) {
var param = params.type;
if(typeof(param) == 'string') {
return chunk.write(type);
}
if(param.length === 1) {
return chunk.write(param[0]);
}
return chunk.write('(' + param.join('|') + ')');
};
const stream = parse({ src: input });
stream.on('data', (data) => {
data = JSON.parse(data);
let context = {
host: '### HOST ###',
title: 'Asil API',
data: data
};
dust.render('function', context, (err, out) => {
fs.writeFileSync(output, out);
});
// const apib = "pre = 1\n----\n" + JSON.stringify(data, null, 3);
});
// console.log(parsed);