Documenting a Backbone constructor with JSDoc?

I've got a base view method for my application that has a close method. It works great up until the point where I have to document it; basically I'm putting in a needless function call in order to properly document it. As Backbone already has an initialize function, it makes no sense to call it again here, taking up lines of code.. but if I drop this function from the code then the documentation for the view isn't generated. My code looks like this:

/**
 * @exports BaseView
 */
define(['backbone'], function( Backbone ) {
    'use strict';
    return Backbone.View.extend( /** @lends BaseView.prototype */ {
        /**
         * Base view with close method
         * @exports BaseView
         * @augments Backbone.View
         * @constructor
         */
        initialize: function() {
            Backbone.View.prototype.initialize.call(this);
        },
        /**
         * Removes the view from the DOM and unbinds all events.
         */
        close: function() {
            this.remove();
            this.unbind();
            if (this.onClose) {
                // Optionally, run additional cleanup methods.
                this.onClose();
            }
        }
    });
});

This question got me on the right track with documenting, but now I'd like to know if it's possible in JSDoc to document that the initialize method is inherited from Backbone.View instead of writing the function call.

Would be grateful if anyone can point me in the right direction. Thanks.


Does the following do what you want? I've just removed the initialize function, added @name BaseView to the doclet that was in front of it and removed the @exports ... that was in the same doclet because it seemed incorrect there.

/**
 * @exports BaseView
 */
define(['backbone'], function( Backbone ) {
    'use strict';
    return Backbone.View.extend( /** @lends BaseView.prototype */ {
        /**
         * Base view with close method
         * @augments Backbone.View
         * @constructor
         * @name BaseView
         */

        /**
         * Removes the view from the DOM and unbinds all events.
         */
        close: function() {
            this.remove();
            this.unbind();
            if (this.onClose) {
                // Optionally, run additional cleanup methods.
                this.onClose();
            }
        }
    });
});
链接地址: http://www.djcxy.com/p/70416.html

上一篇: 用RequireJS和JSDoc3记录一个Marionette模块

下一篇: 用JSDoc记录一个Backbone构造函数?