csnover / js-doc-parse

An experimental library for parsing JavaScript files and extracting inline documentation.
31 stars 7 forks source link

fragile regex for union types #67

Closed wkeese closed 11 years ago

wkeese commented 11 years ago

See dojo codebase at http://bugs.dojotoolkit.org/changeset/29378/dojo. width is specified as a String or Number, but shows up as undefined in details.xml:

    g.createSurface = function(parentNode, width, height){
         // summary:
         //     creates a surface
         // parentNode: Node
         //     a parent node
         // width: String | Number
         //     width of surface, e.g., "100px" or 100
         // height: String | NUmber
         //     height of surface, e.g., "100px" or 100
         // returns: dojox/gfx/shape.Surface
         //     newly created surface
     };

The problem is the spaces around the vertical bar; they confuse the parser. Ideally it would allow for them.

I updated the code to use no spaces, so it's not an urgent issue.

csnover commented 11 years ago

I prefer to think of it as “strict” rather than “fragile”. For the sake of consistency I would prefer to keep it the way it is, unless there is some mass uprising against such a decision. These union types are not actually documented anywhere in the dojodoc guides and in jsdoc they are whitespace-free.