wingedfox / dgeni-alive

Live docs on top of dgeni documentation generator
MIT License
26 stars 14 forks source link

HELP! Unrecognised node type: LogicalExpression #10

Closed BadIdeaException closed 8 years ago

BadIdeaException commented 8 years ago

With this code

/**
 * @ngdoc method
 * @name foo#bar
 * @description
 * Does important bar stuff on foo and will only be present if `readOnly` flag isn't set
**/

foo.bar = !options.readOnly && function() {
    // blabla
}

I get the following output when running the grunt task:

warn:    HELP! Unrecognised node type: LogicalExpression
warn:     type=LogicalExpression, operator=&&, type=UnaryExpression, operator=!, type=MemberExpression, computed=false, type=Identifier, name=options, range=[1438, 1445], line=51, column=15, line=51, column=22, type=Identifier, name=readOnly, range=[1446, 1454], line=51, column=23, line=51, column=31, range=[1438, 1454], line=51, column=15, line=51, column=31, prefix=true, range=[1437, 1454], line=51, column=14, line=51, column=31, type=FunctionExpression, id=null, params=[], type=BlockStatement, body=[], range=[1469, 1494], line=51, column=46, line=53, column=5, trailingComments=[type=Line, value= blabla, range=[1479, 1488], line=52, column=8, line=52, column=17], generator=false, expression=false, range=[1458, 1494], line=51, column=35, line=53, column=5, range=[1437, 1494], line=51, column=14, line=53, column=5

If I replace the assignment with if (!options.readOnly) foo.bar = ..., I instead get

warn:    HELP! Unrecognised node type: IfStatement
warn:     type=IfStatement, type=UnaryExpression, operator=!, type=MemberExpression, computed=false, type=Identifier, name=options, range=[1432, 1439], line=51, column=9, line=51, column=16, type=Identifier, name=readOnly, range=[1440, 1448], line=51, column=17, line=51, column=25, range=[1432, 1448], line=51, column=9, line=51, column=25, prefix=true, range=[1431, 1448], line=51, column=8, line=51, column=25, type=ExpressionStatement, type=AssignmentExpression, operator==, type=MemberExpression, computed=false, type=Identifier, name=foo, range=[1450, 1453], line=51, column=27, line=51, column=30, type=Identifier, name=bar, range=[1454, 1457], line=51, column=31, line=51, column=34, range=[1450, 1457], line=51, column=27, line=51, column=34, type=FunctionExpression, id=null, params=[], type=BlockStatement, body=[], range=[1471, 1496], line=51, column=48, line=53, column=5, trailingComments=[type=Line, value= blabla, range=[1481, 1490], line=52, column=8, line=52, column=17], generator=false, expression=false, range=[1460, 1496], line=51, column=37, line=53, column=5, range=[1450, 1496], line=51, column=27, line=53, column=5, range=[1450, 1497], line=51, column=27, line=53, column=6, alternate=null, range=[1427, 1497], line=51, column=4, line=53, column=6, leadingComments=[type=Block, value=*
     * @ngdoc method
     * @name foo#bar
     * Does important bar stuff on foo and will only be present if `readOnly` flag isn't set.
     , range=[1274, 1421], line=45, column=4, line=49, column=7]

I've been able to trace it to function findCodeName in packages/jsdoc-ext/services/code-name.js.

wingedfox commented 8 years ago

Hi,

I've added a FAQ entry on this issue.

You've either change your code as follows

/**
 * @ngdoc method
 * @name foo#bar
 * @description
 * Does important bar stuff on foo and will only be present if `readOnly` flag isn't set
**/
function foorBar() {
    // blabla
}
foo.bar = !options.readOnly && fooBar;

or add matcher for LogicaExpression or IfExpression' to handle this issue,dgeni-packages/jsdoc` module assumes that there's a formal API and tries to match 'subjective' codepoints.