Search code examples
javascriptyuidoc

How to document a namespace using yuidoc?


YUIDoc doesn't seem to be generating any documentation for my namespace. This project uses the Revealing Module design pattern

/*
 * Example namespace.
 *
 * @namespace MY_NAMESPACE
 */
var MY_NAMESPACE = (function() {
  /**
   * @property privateProperty1
   * @type {Number}
   * @private
   */
  var privateProperty1 = 1;

  /**
   * Logs the method name to the console.
   * @method privateMethod1
   * @private
   */
  var privateMethod1 = function() {
    console.log('In privateMethod1');
  };

  return {
    /**
     * @property publicProperty1
     * @type {Number}
     */
    publicProperty1: 2,

    /**
     * Logs a simple message to the console.
     *
     * @method publicMethod1
     * @param {String} aString A string to log. 
     */
    publicMethod1: function(aString) {
      console.log('In publicMethod1 and was passed: ' + aString);
    }
  }
})();

Solution

  • @namespace needs to contains a @class if you want to use @namespace as follows, but you may want to use a @class instead of @namespace.

    /**
    * Example namespace.
    * @namespace MY_NAMESPACE
    */
    
    /**
    * Example class.
    * @class MyClass
    */