cwilson1031 / jsdoc-toolkit

Automatically exported from code.google.com/p/jsdoc-toolkit
0 stars 0 forks source link

Provide support for singleton classes #284

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a simply singleton class as follows:

/**
 * A simple class that has no constructor (its constructed one time only).
 *
 * @final
 * @class
 * @name MyClass
*/

MyClass = (function()
{
   /** 
    * A reflective pointer since this is a singleton, used to save space
    * when using dojo or yui compression, since keyword this points to 
    * SELF, and SELF since its private can convert to a single character 
    *
    * @property {MyClass} MyClass-SELF
    * @private
   */

    var SELF  = this;

    var echo = function() { alert("hi"); };

    SELF.echo = echo;

})();

2. Run jsdoc
3.

What is the expected output? What do you see instead?
echo should be a member of MyClass, also you will see constructor
documentation implying that this class can be constructed when
infact it cannot.  MyClass becomes like its static in this case.
Hoever, if you add @static, then you loose any documentation preceding
the "@class" tag, and MyClass is treated as a namespace.

What version of the product are you using? On what operating system?
Windows XP Pro, jsdoctoolkit 2.3.2

Please provide any additional information below.

Original issue reported on code.google.com by sean...@gmail.com on 4 Mar 2010 at 6:38

GoogleCodeExporter commented 9 years ago
The @namespace and  @name tags are your friends.

/**
 * A simple class that has no constructor (its constructed one time only).
 * @name MyClass
 * @namespace
 */

MyClass = (function()
{

   var SELF  = this;

  /**
   * Bla bla
   * @name MyClass.echo
   * @function
   */
   var echo = function() { alert("hi"); };

   SELF.echo = echo;

})();

Original comment by micmath on 14 Mar 2010 at 8:15

GoogleCodeExporter commented 9 years ago
A class is not a namespace. How silly to suggest to treat it like one.

Original comment by pstic...@gmail.com on 13 Nov 2014 at 4:06