Skip to content

Commit ce02d34

Browse files
committed
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
1 parent 96915e1 commit ce02d34

6 files changed

Lines changed: 431 additions & 2 deletions

File tree

docs/build/conf.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
},
55
"source": {
66
"include": [
7+
"../pixi-jsdoc.js",
78
"../../src/Phaser.js",
89
"../../src/animation/",
910
"../../src/core/",
@@ -30,6 +31,7 @@
3031
},
3132
"plugins" : [
3233
"local-plugins/proptomember",
34+
"local-plugins/sourceproxy",
3335
"plugins/markdown"
3436
],
3537
"templates": {
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/**
2+
* For use with custom `@sourcepath`, `@sourceline`, `@nosource` properties
3+
* (which are used in YUIDoc-to-JSDoc to supply source documentation)
4+
*/
5+
6+
var path = require('path');
7+
8+
exports.defineTags = function(dictionary) {
9+
10+
dictionary.defineTag('nosource', {
11+
onTagged: function (doclet, tag) {
12+
doclet.meta.nosource = true;
13+
//doclet.meta.path = '';
14+
//doclet.meta.filename = '';
15+
}
16+
});
17+
18+
dictionary.defineTag('sourcefile', {
19+
onTagged: function (doclet, tag) {
20+
var filename = tag.value;
21+
doclet.meta.path = path.dirname(filename);
22+
doclet.meta.filename = path.basename(filename);
23+
}
24+
});
25+
26+
dictionary.defineTag('sourceline', {
27+
onTagged: function (doclet, tag) {
28+
var lineno = tag.value;
29+
doclet.meta.lineno = lineno;
30+
}
31+
});
32+
33+
}
34+
35+
exports.handlers = {};
36+
exports.handlers.newDoclet = function (e) {
37+
38+
};

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
"grunt-contrib-uglify": "^0.4.0",
4141
"grunt-notify": "^0.3.0",
4242
"grunt-text-replace": "^0.3.11",
43-
"load-grunt-config": "~0.7.2"
43+
"load-grunt-config": "~0.7.2",
44+
"yuidocjs": "^0.3.50"
4445
}
45-
}
46+
}

tasks/builddoc.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/**
2+
* A quick stub-task for running generating the JSDocs.
3+
* This should probably be migrated to use grunt-jsdoc@beta (for jsdoc 3.x) or similar.
4+
*/
5+
'use strict';
6+
7+
module.exports = function (grunt) {
8+
9+
grunt.registerTask('builddoc', 'Builds the project documentation', function () {
10+
11+
var done = this.async();
12+
13+
grunt.util.spawn({
14+
cmd: 'jsdoc',
15+
args: ['-c', 'conf.json', '../../README.md'],
16+
opts: {
17+
cwd: 'docs/build'
18+
}
19+
}, function (error, result, code) {
20+
if (error) {
21+
grunt.fail.warn("" + result);
22+
done(false);
23+
} else {
24+
done();
25+
}
26+
});
27+
28+
});
29+
30+
};

tasks/pixidoc.js

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/**
2+
* Generates the appropriate JSDoc from some (PIXI) YUIDoc.
3+
* This could be turned into a more general pacakge.
4+
*
5+
* Requires: yuidocjs
6+
*/
7+
'use strict';
8+
9+
function generateYuiDoc (sourcePaths, grunt) {
10+
11+
var Y = require('yuidocjs');
12+
13+
var options = {
14+
parseOnly: true,
15+
quiet: true,
16+
paths: sourcePaths
17+
};
18+
19+
return (new Y.YUIDoc(options)).run();
20+
}
21+
22+
module.exports = function (grunt) {
23+
24+
grunt.registerTask('pixidoc', 'Generates JSDoc from the PIXI YUIdocs', function () {
25+
26+
var sources = ['C:/code/ph/phaser/src/pixi'];
27+
var output = 'docs/pixi-jsdoc.js';
28+
29+
var yui2jsdoc = require('./yuidoc-to-jsdoc/converter');
30+
var fs = require('fs');
31+
var path = require('path');
32+
33+
// Right now yuidocsjs requires an absolute path so it emits an
34+
// absolute path in the jsdoc (or the JSDoc will error on missing files)
35+
sources = sources.map(function (source) {
36+
return path.resolve(source);
37+
});
38+
39+
var data = generateYuiDoc(sources);
40+
41+
if (!data) {
42+
grunt.fail.warn("PIXI YUIDoc not generated - nothing to do")
43+
return;
44+
}
45+
46+
// Fake in namespace (current limitation)
47+
var header =
48+
"/**\n" +
49+
"* @namespace PIXI\n" +
50+
"*/";
51+
52+
var res = yui2jsdoc.convert(data);
53+
var flat = res.join("\n");
54+
fs.writeFileSync(output, header + "\n" + flat);
55+
56+
});
57+
58+
};

0 commit comments

Comments
 (0)