Merge pull request #1559 from vulvulune/dev

Complete "tsdocs" tasks to download plugins + improve ts doc + grunt:jsdoc
This commit is contained in:
Richard Davey 2015-02-03 21:04:30 +00:00
commit 0953e927b4
10 changed files with 45 additions and 62 deletions

View file

@ -1,3 +1,4 @@
/// <binding />
module.exports = function (grunt) {
var loadConfig = require('load-grunt-config');
@ -20,7 +21,7 @@ module.exports = function (grunt) {
grunt.registerTask('dist', ['replace:pixi', 'replace:p2', 'build', 'copy']);
grunt.registerTask('docs', [ 'clean:docs', 'pixidoc', 'builddoc', 'replace:docs', 'clean:out']);
grunt.registerTask('docs', [ 'clean:docs', 'pixidoc', 'jsdoc:html', 'replace:docs', 'clean:out']);
grunt.registerTask('tsdocs', ['pixidoc', 'exportdocjson', 'buildtsdoc:pixi', 'buildtsdoc:phaser', 'replace:phasertsdefheader', 'clean:out']);
grunt.registerTask('tsdocs', ['clean:out', 'pixidoc', 'gitclone:plugins', 'jsdoc:json', 'buildtsdoc:pixi', 'buildtsdoc:phaser', 'replace:phasertsdefheader', 'clean:out']);
};

View file

@ -43,7 +43,8 @@
"load-grunt-config": "~0.7.2",
"yuidocjs": "^0.3.50",
"jsdoc": "~3.3.0-alpha10",
"grunt-jsdoc": "~0.5.7",
"typescript-services": "~0.1.5"
"grunt-jsdoc": "~0.6.2-beta",
"typescript-services": "~0.1.5",
"grunt-git": "^0.3.3"
}
}

View file

@ -4,6 +4,8 @@
*/
'use strict';
var path = require('jsdoc/path');
function findClass(parentNode, className)
{
var elements =
@ -109,5 +111,5 @@ exports.publish = function (data, opts) {
graft2(root, data().get());
var fs = require('fs');
fs.writeFileSync(opts.destination, JSON.stringify(root), 'utf8');
fs.writeFileSync(path.join(env.opts.destination, 'docs.json'), JSON.stringify(root), 'utf8');
};

View file

@ -10158,7 +10158,7 @@ Capsule.prototype = new Shape();
* @method conputeMomentOfInertia
* @param {Number} mass
* @return {Number}
* @todo
* @todo !
*/
Capsule.prototype.computeMomentOfInertia = function(mass){
// Approximate with rectangle

View file

@ -1,27 +0,0 @@
/**
* A quick stub-task for running generating the JSDocs.
* This should probably be migrated to use grunt-jsdoc@beta (for jsdoc 3.x) or similar.
*/
'use strict';
module.exports = function (grunt) {
grunt.registerTask('builddoc', 'Builds the project documentation', function () {
var done = this.async();
grunt.util.spawn({
cmd: 'jsdoc',
args: ['-c', './tasks/jsdoc-conf.json', './README.md'],
}, function (error, result, code) {
if (error) {
grunt.fail.warn("" + result);
done(false);
} else {
done();
}
});
});
};

View file

@ -47,6 +47,9 @@ var TypeScriptDocGenerator = (function () {
}
return 0;
};
TypeScriptDocGenerator.prototype.extractPropertyName = function (pn) {
return pn.withLeadingTrivia().text().trim();
};
TypeScriptDocGenerator.prototype.insertComment = function (commentLines, position) {
if ((commentLines != null) && (commentLines.length > 0)) {
var nbChars = 0;
@ -207,10 +210,10 @@ var TypeScriptDocGenerator = (function () {
this.insertComment(this.generateConstructorComments(fullName), classPos + this.leadingWidth(elem));
break;
case ts.SyntaxKind.MemberVariableDeclaration:
this.insertComment(this.generateMemberComments(fullName, elem.variableDeclarator.propertyName.fullText().trim()), classPos + this.leadingWidth(elem));
this.insertComment(this.generateMemberComments(fullName, this.extractPropertyName(elem.variableDeclarator.propertyName)), classPos + this.leadingWidth(elem));
break;
case ts.SyntaxKind.MemberFunctionDeclaration:
this.insertComment(this.generateFunctionComments(fullName, elem.propertyName.fullText().trim()), classPos + this.leadingWidth(elem));
this.insertComment(this.generateFunctionComments(fullName, this.extractPropertyName(elem.propertyName)), classPos + this.leadingWidth(elem));
break;
}
if (elem.kind() !== ts.SyntaxKind.List) {

View file

@ -1,26 +0,0 @@
/**
* A quick stub-task for export the jsdoc in a JSON file
* This should probably be migrated to use grunt-jsdoc@beta (for jsdoc 3.x) or similar.
*/
'use strict';
module.exports = function (grunt) {
grunt.registerTask('exportdocjson', 'Export the project documentation in json format', function () {
var done = this.async();
grunt.util.spawn({
cmd: 'jsdoc',
args: ['-c', './tasks/jsdocexportjson-conf.json'],
}, function (error, result, code) {
if (error) {
//grunt.fail.warn("" + result);
done();
} else {
done();
}
});
});
};

View file

@ -21,7 +21,8 @@
"./src/tilemap/",
"./src/time/",
"./src/tween/",
"./src/utils/"
"./src/utils/",
"./out/plugins/"
],
"includePattern": ".+\\.js(doc)?$",
"excludePattern": "(^|\\/|\\\\)_"

View file

@ -0,0 +1,9 @@
module.exports = {
plugins: {
options: {
repository: "https://github.com/photonstorm/phaser-plugins",
branch: "master",
directory: "out/plugins"
}
}
};

19
tasks/options/jsdoc.js Normal file
View file

@ -0,0 +1,19 @@
module.exports = {
html: {
src: ['./README.md'],
options: {
configure: 'tasks/jsdoc-conf.json',
/* The destination and private options must be redefined event if there are always in the configure file otherwise, grunt-jsdoc overwrite it with its default values */
destination: 'docs',
private: false
}
},
json: {
src: [],
options: {
configure: 'tasks/jsdocexportjson-conf.json',
/* The destination optios must be redefined event if there is always in the configure file otherwise, grunt-jsdoc overwrite it with its default value */
destination: './out'
}
}
};