Generates a Markdown
friendly output similar to the one showed here.
(function show(object, name, all) {
var f, k, later = [], list = ['### ' + name, '```javascript'];
all.push(object);
Object.getOwnPropertyNames(object).forEach(function(name) {
list.push(name);
if (/^[A-Z]/.test(name) && object[name] instanceof Object) {
later.push([object, name]);
}
});
list.push('```', '');
while(later.length) {
f = later.shift();
k = f[1];
f = f[0];
if (all.indexOf(f[k]) < 0) {
list.push(
show(f[k], k, all)
);
if (typeof f[k] == 'function' && f[k].hasOwnProperty('prototype')) {
list.push(
show(f[k].prototype, k + '.prototype', all)
);
}
}
}
return list.join('\n');
}(global, 'global', []));
one line version: