forked from kamicane/art
-
Notifications
You must be signed in to change notification settings - Fork 101
/
Copy pathapidump.js
86 lines (69 loc) · 2.09 KB
/
apidump.js
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
var otherModes = [
require('../../modes/vml'),
require('../../modes/svg'),
// require('../../modes/script'),
require('../../modes/canvas')
];
var ART = require('../../index');
var result = [];
function log(){
result.push.apply(result, arguments);
result.push('\n');
}
function isMethodInAllTheModes(name, prop){
return !otherModes.some(function(mode){
return mode[name] && !mode[name].prototype[prop];
});
}
function getArgumentNames(fn){
var code = fn.toString(),
startOfParam = code.indexOf('(') + 1,
endOfParam = code.indexOf(')');
if (startOfParam == endOfParam) return '';
return code.substring(startOfParam, endOfParam);
}
function logPrototypeProperty(obj, key){
if (key.indexOf('_') > -1) return;
var v = obj[key];
if (key == 'draw') v = obj._draw_function || v;
if (typeof v == 'function'){
log(': ', key, '(', getArgumentNames(v), ')');
} else {
log(': ', key);
}
}
function logInstanceProperty(obj, key){
if (key.indexOf('_') > -1) return;
var v = obj[key];
if (typeof v == 'function'){
log('. ', key, '(', getArgumentNames(v), ')');
} else {
log('. ', key);
}
}
for (var name in ART){
var v = ART[name].prototype._draw_function || ART[name].prototype.initialize;
if (typeof v !== 'function')
v = ART[name];
log(name, '(', getArgumentNames(v), ')');
Object.keys(ART[name]).sort().forEach(function(key){
logInstanceProperty(ART[name], key);
});
var prototype = ART[name].prototype;
Object.keys(prototype).sort().forEach(function(key){
if (key == 'initialize' || key == 'constructor' || key == '_draw_function')
return;
if (name !== 'Transform' && ART.Transform.prototype[key] === prototype[key])
return;
if (name !== 'Transform' && name !== 'Shape' && name !== 'Group' && name !== 'Text' && ART.Shape.prototype[key] === prototype[key])
return;
if (isMethodInAllTheModes(name, key) || key == 'blend' || key == 'eject' || key == 'inject')
logPrototypeProperty(prototype, key);
});
log('');
}
var ta = document.createElement('textarea');
ta.style.width = '500px';
ta.style.height = '500px';
ta.value = result.join('');
document.body.appendChild(ta);