Created
October 31, 2011 23:28
-
-
Save micmath/1329394 to your computer and use it in GitHub Desktop.
Ways of documenting inner symbols inside anonymous functions that later get promoted to global
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Be explicit - provide names for everything. | |
(function(window) { | |
/** | |
* The ToolBox | |
* | |
* @class ToolBox | |
*/ | |
var ToolBox = {}; | |
/** | |
* The module | |
* | |
* @namespace ToolBox.Module | |
*/ | |
ToolBox.Module = | |
{ | |
/** | |
* Third tool | |
* @method ToolBox.Module.tool | |
* @return {string} The hello message | |
*/ | |
tool: function() | |
{ | |
return "Hello World"; | |
} | |
}; | |
// Expose ToolBox | |
window.ToolBox = ToolBox; | |
})(window); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Be obvious - format your code in a way that is friendly to static analysis | |
(function(window) { | |
/** | |
* The ToolBox | |
* | |
* @namespace | |
* @global | |
*/ | |
var ToolBox = { | |
/** | |
* The module | |
* | |
* @namespace | |
*/ | |
Module: { | |
/** | |
* The tool | |
* | |
* @return {string} The hello message | |
*/ | |
tool: function() | |
{ | |
return "Hello World"; | |
} | |
} | |
}; | |
// Expose ToolBox | |
window.ToolBox = ToolBox; | |
})(window); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Be a wizard - use obscure JSDoc 3 tags to say what you mean | |
(function(window) { | |
/** | |
* The ToolBox | |
* | |
* @namespace | |
* @global | |
*/ | |
var ToolBox = {}; | |
/** | |
* The module | |
* | |
* @namespace | |
* @alias Module | |
* @memberof Toolbox | |
*/ | |
ToolBox.Module = | |
{ | |
/** | |
* The tool | |
* | |
* @return {string} The hello message | |
*/ | |
tool: function() | |
{ | |
return "Hello World"; | |
} | |
}; | |
// Expose ToolBox | |
window.ToolBox = ToolBox; | |
})(window); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Be blunt - document everything inside the anonymous function as global | |
(/** @alias <global> */function(window) { | |
/** | |
* The ToolBox | |
* | |
* @namespace | |
*/ | |
var ToolBox = {}; | |
/** | |
* The module | |
* | |
* @namespace | |
*/ | |
ToolBox.Module = | |
{ | |
/** | |
* The tool | |
* | |
* @return {string} The hello message | |
*/ | |
tool: function() | |
{ | |
return "Hello World"; | |
} | |
}; | |
// Expose ToolBox | |
window.ToolBox = ToolBox; | |
})(window); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment