Skip to content

Instantly share code, notes, and snippets.

@leonardreidy
Created October 8, 2016 20:27
Show Gist options
  • Save leonardreidy/ab8f1767eb336c174f633270319301c2 to your computer and use it in GitHub Desktop.
Save leonardreidy/ab8f1767eb336c174f633270319301c2 to your computer and use it in GitHub Desktop.
How to use JSDoc 3 to document a class (as IIFE) inside a module (as IIFE)
/**
* The JSDoc module tag identifies the file as a module. JSDoc
* assumes all symbols in the file belong to the module, unless
* otherwise specified.
*
* @module DummyModule
*/
var DummyModule = (function() {
// The constructs tag and the memberof tag on the constructor function
// seal the deal.
// The former ensures that the associated function is treated
// as if it constructs instances of the class.
// Not to be confused with the constructor tag, which is
// not synonymous! The latter associates a member symbol with a parent
// symbol, or, for our purposes, the Stack or Set with our dummy module.
var Stack = (function(){
/**
* @classdesc This is the Stack class
* @constructs Stack
* @memberof module:DummyModule
*/
function Stack(){
//do some constructing
}
/**
* @description This is the put method
* @param {String} key for key/val pair
* @param {*} val for key/val pair
*/
Stack.prototype.put = function(key,val) {
// do some putting
};
return Stack;
})();
// Dictionary class
var Dictionary = (function() {
/**
* @classdesc This is the Dictionary class
* @constructs Dictionary
* @memberof module:DummyModule
*/
function Dictionary() {
//do stuff
}
/**
* @description This is the clear method
*/
Dictionary.prototype.clear = function() {
// do some clearing
};
/**
* @description This is the get method
* @param {String|Number}
* @return {String|Number}
*/
Dictionary.prototype.get = function(key) {
// do some getting
};
return Dictionary;
})();
// expose a public API on the module
return {
Dictionary: Dictionary,
Stack: Stack
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment