Using @enum with @lends

196 views
Skip to first unread message

Konstantin Pozin

unread,
Jul 11, 2012, 4:52:28 PM7/11/12
to jsdoc...@googlegroups.com
Should it be possible to use @enum with @lends? My use case is a custom Enum constructor that does some extra initialization. However, it looks like JSDoc 3 is treating the object literal as a separate, undocumented node, so its members aren't added to the other node that has the same alias. Both have global scope.

define(function (require) {
    "use strict";

    var Enum = require("Enum");

    /**
     * Enum for visibility values
     * @enum {string}
     * @alias EVisibility
     */
    var EVisibility = new Enum(
        /** @lends EVisibility */
        {
            /**
             * Visible on screen
             */
            VISIBLE: "visible",

            /**
             * Invisible
             */
            INVISIBLE: "invisible"
        }
    );

    return EVisibility;
});

Michael Mathews

unread,
Jul 11, 2012, 5:20:54 PM7/11/12
to Konstantin Pozin, jsdoc...@googlegroups.com
Hello,

Enum suport is new and isn't fully featured yet. It's only tested to work with simple object literal assignments to variables. You can work around this with a minor refactor, similar to this example...

```javascript
define(function (require) {
"use strict";

var Enum = require("Enum");

/**
* Enum for visibility values
* @global
* @enum {string}
*/
var EVisibility = {
/**
* Visible on screen
*/
VISIBLE: "visible",

/**
* Invisible
*/
INVISIBLE: "invisible"
};

return new Enum(EVisibility);
});
````

Michael Mathews
mic...@gmail.com

Reply all
Reply to author
Forward
0 new messages