Skip to content

Commit 42ad2e6

Browse files
committed
require --documentation flag to include text in idefs
1 parent 401414a commit 42ad2e6

File tree

2 files changed

+47
-1
lines changed

2 files changed

+47
-1
lines changed

generate/setup.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,5 +121,9 @@ output.forEach(function (def) {
121121
});
122122
});
123123

124+
if (process.argv[2] != "--documentation") {
125+
utils.filterDocumentation(output);
126+
}
127+
124128
fs.writeFileSync(path.join(__dirname, "idefs.json"),
125129
JSON.stringify(output, null, 2));

generate/utils.js

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ var Utils = {
125125
_.merge(field, callbackDefs[field.type]);
126126
}
127127
else {
128-
console.log("WARNGING: Couldn't find callback definition for " + field.type);
128+
console.log("WARNING: Couldn't find callback definition for " + field.type);
129129
}
130130
},
131131

@@ -319,6 +319,48 @@ var Utils = {
319319
}
320320

321321
_.merge(fnDef, _.omit(fnOverrides, "args", "return"));
322+
},
323+
324+
filterIgnored: function (arr, callback) {
325+
for (var i = arr.length - 1; i >= 0; i--) {
326+
if (arr[i].ignore) {
327+
arr.splice(i, 1);
328+
}
329+
else if (callback) {
330+
callback(arr[i]);
331+
}
332+
}
333+
},
334+
335+
deleteProperties: function(obj) {
336+
delete obj.line;
337+
delete obj.lineto;
338+
delete obj.block;
339+
delete obj.description;
340+
delete obj.comments;
341+
delete obj.tdef;
342+
delete obj.decl;
343+
delete obj.comments;
344+
delete obj.argline;
345+
delete obj.sig;
346+
},
347+
348+
filterDocumentation: function(idefs) {
349+
Utils.filterIgnored(idefs, function (idef) {
350+
Utils.deleteProperties(idef);
351+
352+
Utils.filterIgnored(idef.fields, Utils.deleteProperties);
353+
354+
355+
Utils.filterIgnored(idef.functions, function (fn) {
356+
Utils.deleteProperties(fn);
357+
358+
Utils.filterIgnored(fn.args, function(arg) {
359+
Utils.deleteProperties(arg);
360+
delete arg.functions;
361+
});
362+
});
363+
});
322364
}
323365
};
324366

0 commit comments

Comments
 (0)