-
Notifications
You must be signed in to change notification settings - Fork 12
/
stubify
70 lines (64 loc) · 1.69 KB
/
stubify
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
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env node
var util = require('util');
console.log('<?xml version="1.0" encoding="UTF-8"?>\n<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.2//EN" "http://www.netbeans.org/dtds/filesystem-1_2.dtd">\n<filesystem>');
var modules = [
'assert',
'buffer',
'child_process',
'cluster',
'console',
'constants',
'crypto',
'dgram',
'dns',
'domain',
'events',
'fs',
'http',
'https',
'module',
'net',
'os',
'path',
'punycode',
'querystring',
'readline',
'repl',
'stream',
'string_decoder',
'sys',
'timers',
'tls',
'tty',
'url',
'util',
'vm',
'zlib',
]
var version = process.version;
var verAttr = '<attr name="nodeversion" stringvalue="' + version + '"/>';
modules.forEach(function(module) {
var curr = require(module);
console.log('<file name="' + module + ".js" + '"><![CDATA[');
var lines = ['/* THIS IS A STUB FILE FOR CODE COMPLETION',
'Use Tools | Options | Miscellaneous | NodeJS to download the actual sources */\n'];
for (var key in curr) {
var item = curr[key];
if (key[0] === '_') {
continue;
}
// console.log('TYPEOF ' + key + " " + typeof item)
if (typeof item === 'function') {
var str = item + '';
var def = /.*function.*\((.*?)\)/.exec(str);
if (def) {
lines.push('exports.' + key + '=function(' + def[1] + '){}');
}
} else {
lines.push('exports.' + key + ' = ' + util.inspect(item));
}
}
lines.push(']]>\n' + verAttr + '\n</file>')
console.log(lines.join('\n'));
})
console.log('</filesystem>');