SitePen / js-doc-parse

An experimental library for parsing JavaScript files and extracting inline documentation.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Dojo.declare()

aramk opened this issue · comments

If I use dojo.declare in place of declare when declaring modules, although my source works fine in the browser this docs parser sets my class to a "string" type in the api browser.

Also, I'm calling dojo.declare in a separate function and then returning the result. I then use this function in place of my imported declare and although I've verified this is working correctly this parser returns an "object" instead of a "class" unless I strictly use the same instance of the "declare" function which I import. Creating a new reference to this declare function also works, but calling it in a function does not.

// Works
define([
    'dojo/_base/declare'
], function (declare) {
    var declare2 = declare;
    return declare2(null, {
        // some stuff
    });
});


// Doesn't work
define([
    'dojo/_base/declare'
], function (declare) {
    var me = this;
    var declare3 = function () {
        // some stuff
        return declare.apply(me, arguments);
    };
    return declare3(null, {
        // some stuff
    })
});

Here's a more concrete example which I have verified works in practice but the api viewer shows the class as being a string.

define([
    'dojo/_base/declare'
], function (declare) {
    var oldDeclare = declare;
    declare = function () {
        // some stuff
        return oldDeclare.apply(this, arguments);
    };
    return declare(null, {
        // some stuff
    });
});

There aren't any errors during parsing.

Also the same issue here:

define([
    'dojo/_base/declare'
], function (declare) {
    var a = declare(null, {
        // some stuff
    });
    function test() {
        return a;
    }
    a = test();
    return a;
});

This only works if I remove a = test();, even though it is returning the same object... Replacing that line with a = a does work.