groc icon indicating copy to clipboard operation
groc copied to clipboard

Fails to parse

Open dudewad opened this issue 10 years ago • 1 comments

When I use the example from the repo to run groc, it works fine. However, I use load-grunt-tasks to load my task configurations from a separate file and when I define it there, I get errors.

Here is the trace:

! Failed to parse doc tags C:\dev\server\wamp\www\testApp\app\scripts\app.js: Cannot read property '1' of null TypeError: Cannot read property '1' of null at Object.module.exports.DOC_TAGS.param.parseValue (C:\dev\server\wamp\www\testApp\node_modules\grunt-groc\node_modules\groc\lib\doc_tags.coffee:124:7) at Object.module.exports.Utils.parseDocTags (C:\dev\server\wamp\www\testApp\node_modules\grunt-groc\node_modules\groc\lib\utils.coffee:637:39) at Default.module.exports.Base.renderFile (C:\dev\server\wamp\www\testApp\node_modules\grunt-groc\node_modules\groc\lib\styles\base.coffee:27:11) at C:\dev\server\wamp\www\testApp\node_modules\grunt-groc\node_modules\groc\lib\project.coffee:83:15 at fs.js:271:14 at Object.oncomplete (fs.js:107:15)

Here is my task config:

module.exports = {
    javascript: {
        files: {src: ["<%=pkg.directories.dev_root %><%=pkg.directories.js %>*.js"]},
        options: {
            "out": "<%=pkg.directories.doc_root %>"
        }
    }
};

This is not an issue with configuration, but rather an issue that I see as a Groc flaw. If a doc comment does not contain a data type along with the parameter descriptions, this error is thrown. For example, the following doc comment will cause the error above to be thrown:

/**
 * @param e Some event object
 */
someFunc: function (e) {
    .....code.....
}

Since "e" here is not assigned a data type, I get the ! Failed to parse.... error, with no details on where/why/what this error is.

This should be reduced to a WARNING severity level and continue on in my opinion. Or, at the very least, a descriptive error message should explain where the error occurred because right now "property 1 of null" inside some obscure loop in the Groc inner-workings is not troubleshootable. Though it looks to me like there's just no catch for a possible check against null, so try-catch might be the intended solution here, just not implemented yet. Hope this helps!

dudewad avatar Jan 30 '15 16:01 dudewad

I can confirm this error, in my code any of these @param will let groc fail:

/**
 * @param anything
 */

with:

  Generating documentation...
! Failed to parse doc tags /home/julius/server/lib/Auth/Protocol.js: Cannot read property '1' of null
   TypeError: Cannot read property '1' of null
    at Object.module.exports.DOC_TAGS.param.parseValue (/usr/lib/node_modules/groc/lib/doc_tags.coffee:124:7)
    at Object.module.exports.Utils.parseDocTags (/usr/lib/node_modules/groc/lib/utils.coffee:641:39)
    at Default.module.exports.Base.renderFile (/usr/lib/node_modules/groc/lib/styles/base.coffee:28:11)
    at /usr/lib/node_modules/groc/lib/project.coffee:103:15
    at fs.js:272:14
    at Object.oncomplete (fs.js:108:15)

h4cc avatar Feb 09 '15 13:02 h4cc