diff --git a/Jake/articles/howto-commonjs-modules b/Jake/articles/howto-commonjs-modules index 09370041..fd00ee94 100644 --- a/Jake/articles/howto-commonjs-modules +++ b/Jake/articles/howto-commonjs-modules @@ -92,6 +92,53 @@ define('my/shirt', function () { }); {{/example}} +

Document an IIFE which exposes local functions (Revealing Module Pattern)

+ +

The Revealing Module Pattern requires that you mark each method as a memberOf the module.

+ +{{#example}}The getColor method is documented as a member of the "shirt" module. +/** A module representing a shirt. + * @module shirt + */ +var shirt = (function() { + + var color = 'black'; + + /** Gets the color of the shirt. + * @memberOf module:shirt# + */ + function getColor() { + return color; + } + + return { + getColor: getColor + } + +})(); +define('shirt', function () { + /** + * A module representing a shirt. + * @exports my/shirt + * @version 1.0 + */ + var shirt = { + + /** A property of the module. */ + color: "black", + + /** @constructor */ + Turtleneck: function(size) { + /** A property of the class. */ + this.size = size; + } + }; + + return shirt; +}); +{{/example}} + +

Document a Module as a Constructor