1

I have the following JavaScript.

It is a RequireJS module that has its functions namespaced into an object literal. I referred to: How do I JSDoc A Nested Object's Methods? to find out how to mark up the JSDoc notations.

I run JSDocs 3.3.0-beta3 with private: true in a grunt task but on the modules page there are no private methods or arguments for the publich method.

/**
 * A module doing a lot of Foo.
 * @module Foo
 * @requires jquery
 * @author Markus Falk
 */
define(['jquery'], function($) {

  'use strict';

  /**
   * @property {Object} Container
   */
  var Foo = {
    /**
     * Caches all jQuery Objects for later use
     * @function
     * @private
     */
    _cacheElements: function() {
      this.$foo = $('.foo');
    },
    /**
     * inits the app and returns the Message Text
     * @function
     * @public
     * @param {Object} msg - The message.
     * @param {string} msg.text - The message's Text.
     * @param {string} msg.author - The message's author.
     * @returns {String} Sentence with given message.text
     */
    init: function(msg) {
      this._cacheElements();
      return "Say " + msg.text;
    }
  };

  return /** @alias module:Foo */ {
    /** init */
    init: Foo.init
  };
});

Here is the output of this JSDoc code:

JSDocs

Community
  • 1
  • 1
Markus
  • 2,016
  • 2
  • 15
  • 26

1 Answers1

1

Try @function init and @function _cacheElements

/**
 * A module representing a Foo.
 * @module Foo
 * @requires jquery
 * @author Markus Falk
 */
define(['jquery'], function($) {

  'use strict';

  /**
   * @property {Object} Container
   */
  var Foo = {
    /**
     * Caches all jQuery Objects for later use
     * @function _cacheElements
     * @private
     */
    _cacheElements: function() {
      this.$foo = $('.foo');
    },
    /**
     * inits the app and returns the Message Text
     * @function init
     * @public
     * @param {Object} msg - The message.
     * @param {string} msg.text - The message's Text.
     * @param {string} msg.author - The message's author.
     * @returns {String} Sentence with given message.text
     */
    init: function(msg) {
      this._cacheElements();
      return "Say " + msg.text;
    }
  };

  return /** @alias module:Foo */ {
    /** init */
    init: Foo.init
  };
});

enter image description here

dting
  • 35,904
  • 9
  • 89
  • 112
  • I'm using 3.3.0-beta3 and grunt in which private functions are shown by default. However it still won't show up the way you have it. – Markus Apr 21 '15 at 12:00
  • now I see what you did. This is the namespace-page. What if I want all this to show up in the modules part? – Markus Apr 21 '15 at 13:19