0

How do I document functions inside of a return? In this example, I need then() documented. I have tried adding @memberOf and @name to get it to generate. Nothing seems to work for me.

/**
 * The description for the outer function 
 * @param {string} test Example argument
 * @return {Object}
 */
example.func = function(test) {
   return {
       /**
        * The description for the inner "then" function
        * @param {Function} cb The callback function
        */
       then: function(cb) { }
   }
}

Update Added JSDoc comments to the top to prevent confusion.

Eric Harms
  • 827
  • 1
  • 7
  • 13
  • Possible duplicate of [JSDoc: Return object structure](http://stackoverflow.com/questions/28763257/jsdoc-return-object-structure) – Hitmands Dec 09 '16 at 21:57

1 Answers1

1

JSDoc comments must be above the declaration, the return statement must be declared with @returns {type} value (note that @return is a synonyms)

/**
 * Returns the sum of a and b
 *
 * @param {Number} a
 * @param {Number} [b = 0]
 * @returns {Number}
 */
function sum(a, b = 0) {
    return a + b;
}
Hitmands
  • 13,491
  • 4
  • 34
  • 69