Spiral999 / jsdoc-toolkit

Automatically exported from code.google.com/p/jsdoc-toolkit
0 stars 0 forks source link

" round and : inside user variables don't work #281

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Using JsDoc-Toolkit 2.3.2:

1. add a colon to a user defined variabe on the command line: -Dvar:xyz:abc
=> only xyz (but not xyz:abc) will be passed to the template
2. surround a user defined variable by double quotes like the JsDoc Toolkit
Ant Task 1.0.1 is doing: -D"var:xyz" => inside the template the variable is
called '"var' instead of 'var'

Fix could be to replace in trunk/jsdoc-toolkit/app/lib/JSDOC/JsDoc.js lines
39 to 47 by:

// the -D option: define user variables
var D = {};
if (JSDOC.opt.D) {
    for (var i = 0; i < JSDOC.opt.D.length; i++) {
        var param = JSDOC.opt.D[i];
        // remove first and last character if both == "
        if( param.length > 1 
            && param.charAt(0) == '"' 
            && param.charAt(param.length-1) == '"' ) {
                param = param.substr(1, param.length-2);
            }
        var defineParts = param.split(":");
        if (defineParts && defineParts.length > 2) {
                for( var dpIdx = 2; dpIdx < defineParts.length; dpIdx++ ) {
                    defineParts[1] += ':' + defineParts[dpIdx];
                }
                D[defineParts[0]] = defineParts[1];
            }
    }
}
JSDOC.opt.D = D;

Original issue reported on code.google.com by brownsea42@googlemail.com on 26 Jan 2010 at 11:32

GoogleCodeExporter commented 9 years ago
Oops, found an index issue in the proposed solution:

if (defineParts && defineParts.length > 2) {

should be

if (defineParts && defineParts.length > 1) {

Original comment by brownsea42@googlemail.com on 8 Mar 2010 at 8:22

GoogleCodeExporter commented 9 years ago
Thank you for the patch. Your code was committed in revision 831, and will be 
in the next release: 2.4.0

Original comment by micmath on 9 Mar 2010 at 3:59