使用JSDocs记录嵌套在另一个函数中的显示模式

时间:2016-06-14 20:18:29

标签: javascript jsdoc3 revealing-module-pattern

我是尝试使用JSDocs的新手,我最近刚刚了解了javascript中的闭包,模块。

我试图记录具有以下基本结构的js文件(实际上有更多的参数和方法)。我已经尝试了几种方法来使用JSDocs进行记录,但没有取得多大成功。

/**
 * saveRecord is a client script function for a save event
 * @param {string} type - Mode the record is in (edit, copy, create)
 * @returns {boolean}
 */
function saveRecord(type) {
    /**
     * myRepChanger()
     * This function encapsulates all variables and methods used withing myRepChanger
     * @returns {Object} object containing public api methods
     * @namespace myRepChanger
     */
    var myRepChanger = (function() {

        // private parameters
        var _salesRepID;

        // I tried several methods to document this

        // private methods
        var _getSaleTeamCount = function() {
            // some code
        }

        // public methods
        /**
         * addSalesRep()
         * addSalesRep is a function that adds a sales rep
         * @param {String} newRepID - The ID of the new sales rep to add
         * @returns {} returns nothing
         */
        var addSaleRep = function(newRepID) {
            // some code
        }
        var changeRep = function(options) {
            // some more code including options object
        }

        // API methods
        return {
            'addSalesRep' : addSalesRep,
            'changeRep' : changeRep
        }
    })();
  // more code including returning the boolean
}

如果有人能够透露使用JSDocs记录这个问题的正确方法,那就太棒了,因为我只是准备好使用它。谢谢!

0 个答案:

没有答案