How to jsdoc annotate BackboneJS code?

后端 未结 2 1594
粉色の甜心
粉色の甜心 2020-12-13 05:33

Has anyone ever documented BackboneJS code with JSDoc?

I\'m having problems annotating Backbone constructs such as:



        
2条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-13 06:18

    chris_b's answer helped me a lot, the sample as well as the link. I had to drop the @class annotation, though, or it would generate two entries for the class. Furthermore, I'm adding this answer to show how to annotate static class members (class level constants).

    (We use require.js.)

    define([
        'jquery', 'lodash', 'backbone'
    ], function($, _, Backbone) {
        "use strict";
    
        /**
         * Enumeration of constants that represent the different types of Hedgehogs.
         * @memberof models/Hedgehog
         * @enum {string}
         * @readonly
         */
        var types = { 'type1': 'Type 1', 'type2': 'Type 2' };
    
        var Hedgehog = Backbone.Model.extend(
        /** @lends models/Hedgehog.prototype */
        {
            /**
             * This is the model for Hedgehogs.
             *
             * @augments external:Backbone.Model
             * @constructs
             */
            initialize: function() {
                // your code
            },
    
            // some more methods
        }, {
            // static class members
            "types": types
        });
        return Hedgehog;
    });
    

提交回复
热议问题