I'm new to attempting to use JSDocs, and I've recently just learnt about closures, modules in javascript.
I'm trying to document my js file that has the following basic structure (there are actually many more parameters and methods). I've tried several ways to document using JSDocs without much success.
/**
* 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
}
If anyone can shed some light on the proper way to document this using JSDocs that would be amazing as I'm just about ready to throw in the towel on using it. Thanks!