5

ミックスインまたは多重継承を文書化するにはどうすればよいですか?

/**
 * @class Parent
 */
function Parent() {
}

Parent.prototype.parentTest = 5;

/**
 * @class Mixin
 */
function Mixin() {
}

Mixin.prototype.mixinTest = 5;

/**
 * @class Child
 * @augments Parent
 * @mixin Mixin
 */
function Child() {
}

JsDocの公式なものはありますか? そうでない場合、どのように書くのが望ましいですか?

4

2 に答える 2

3

@augmentsJsDoc ツールキットでは複数が実際にサポートされています (試したことはありませんが、単体テストではそう示唆されています。「複数」を検索してください)。

@lendsとを利用できる Mixins@borrowsについては、次の例を参照してください: http://code.google.com/p/jsdoc-toolkit/wiki/CookBook

于 2011-01-30T17:41:38.847 に答える
3

どうですか:

@mixin [<MixinName>]

以下に混ざるオブジェクトに追加します。

@mixes <OtherObjectPath>

ドキュメントリンクから引っ張ってきました:

/**
 * This provides methods used for event handling. It's not meant to
 * be used directly.
 *
 * @mixin
 */
var Eventful = {
    /**
     * Register a handler function to be called whenever this event is fired.
     * @param {string} eventName - Name of the event.
     * @param {function(Object)} handler - The handler to call.
     */
    on: function(eventName, handler) {
        // code...
    },

    /**
     * Fire an event, causing all handlers for that event name to run.
     * @param {string} eventName - Name of the event.
     * @param {Object} eventData - The data provided to each handler.
     */
    fire: function(eventName, eventData) {
        // code...
    }
};


/**
 * @constructor FormButton
 * @mixes Eventful
 */
var FormButton = function() {
    // code...
};
FormButton.prototype.press = function() {
  this.fire('press', {});
}
mix(Eventful).into(FormButton.prototype);

于 2015-04-22T05:58:46.207 に答える