cancerberoSgx / short-jsdoc

jsdoc implementation with flexible and shorter syntax, written from scratch, with emphasis in rich type support
http://cancerberosgx.github.io/short-jsdoc/doc/guide/
ISC License
19 stars 1 forks source link

File list for parsing gets object properties appended as if they were files. #3

Open bptremblay opened 8 years ago

bptremblay commented 8 years ago

shortjsdoc.js

In the code below, up to this point, the array of file names is correct.

    //@method execute MAIN method to parse the parsed folder's javascript files recursively and return the AST of the jsdoc. 
    //@param {JsDocOptions}options meta information about the project like title, url, license, etc. Hsa the same format as package.json file
    //@return {Object} the jsdoc AST object of all the parsed files. 
,   execute: function(options)
    {
        var self=this; 

        this.computeVendorDirs(options);

        console.log("options.inputDirs: ", _(options.inputDirs));
        _(options.inputDirs).each(function(inputDir)
        {
          console.log("inputDir: ", inputDir);
            _(self.sources).extend(self.buildSources(inputDir)); 
        }); 

        this.parsedSources = null;

        try
        {
            parsedSources = this.parseSources();
        }

However, this block: _(self.sources).extend(self.buildSources(inputDir)); seems to confuse object properties for array elements.

this.sources contains an extra element, beget and the function representing Object.beget.

This is an example of why .each() can be tricky to use, because it iterates over objects and arrays the same way, and when looping through object properties we don't bother to check via Object.hasOwnProperty().

This is a severe bug. I can't use short-jsdoc without modifying this block of code.

Thanks!

Ben

cancerberoSgx commented 8 years ago

Thanks! I'm on it. Sorry for the delay in the response - I was on vacations with limited internet access.

cancerberoSgx commented 8 years ago

I'm not able to reproduce this issue and after reading / testing I don't understand it. ._each() is iterating an array not an object. this.sources is an object which keys are the file name and the value is a string. Could you please provide an example of how are you calling the tool ? command line example or APi example ? thanks