yui/yuidoc — pull request #222 by limikael (2014-03-12 17:10:44+00:00)
Title: preprocessor config

Hi,

Here is a fix for https://github.com/yui/yuidoc/issues/212.

As I wrote in the comments there, it is possible to set a preprocessor directive in the options. The preprocessor is a node module which will be called to allow modifications of the data before rendering. The module is searched for relative to the current working directory.

Example `yuidoc.json`:

{
"options": {
"preprocessor": "internal_doc_preprocessor.js"
}
}

Then, the file `internal_doc_preprocessor.js` would look like the following. In this case it is a preprocessor which removes all classes and class items which has the `@internal` tag:

module.exports=function(data) {
var keepClasses={};

for (var c in data.classes) {
if (!data.classes[c].hasOwnProperty("internal"))
keepClasses[c]=data.classes[c];
}

data.classes=keepClasses;

var keepItems=[];

for (var i in data.classitems) {
if (!data.classitems[i].hasOwnProperty("internal"))
keepItems.push(data.classitems[i])
}

data.classitems=keepItems;
}

I also added a test suite which tests the functionality, with respect to single or multiple processors being used, correct path resolution in case the preprocessor use absolute or relative path, etc.

Please take a look!