phaser/tasks/pixidoc.js
Paul ce02d3402f PIXI-in-Docs - Initial
- Initial support for generating PIXI-combined documentation
- Includes yuidoc-to-jsdoc for generating pixi-jsdoc.js
- Creates doc (using pixidoc + builddoc) tasks
- Adds sourceproxy JSDoc plugin to map in corrected file/line meta
- Added yuidocjs as a dev-dependency
2014-11-03 11:05:00 -08:00

58 lines
No EOL
1.4 KiB
JavaScript

/**
* Generates the appropriate JSDoc from some (PIXI) YUIDoc.
* This could be turned into a more general pacakge.
*
* Requires: yuidocjs
*/
'use strict';
function generateYuiDoc (sourcePaths, grunt) {
var Y = require('yuidocjs');
var options = {
parseOnly: true,
quiet: true,
paths: sourcePaths
};
return (new Y.YUIDoc(options)).run();
}
module.exports = function (grunt) {
grunt.registerTask('pixidoc', 'Generates JSDoc from the PIXI YUIdocs', function () {
var sources = ['C:/code/ph/phaser/src/pixi'];
var output = 'docs/pixi-jsdoc.js';
var yui2jsdoc = require('./yuidoc-to-jsdoc/converter');
var fs = require('fs');
var path = require('path');
// Right now yuidocsjs requires an absolute path so it emits an
// absolute path in the jsdoc (or the JSDoc will error on missing files)
sources = sources.map(function (source) {
return path.resolve(source);
});
var data = generateYuiDoc(sources);
if (!data) {
grunt.fail.warn("PIXI YUIDoc not generated - nothing to do")
return;
}
// Fake in namespace (current limitation)
var header =
"/**\n" +
"* @namespace PIXI\n" +
"*/";
var res = yui2jsdoc.convert(data);
var flat = res.join("\n");
fs.writeFileSync(output, header + "\n" + flat);
});
};