HelloYu / jsdoc-toolkit

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

Better support for factory pattern? #309

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Hi,
I've been using the factory pattern a lot recently and documenting it with 
jsdoc-toolkit even if feasible is not very convenient.

Let me explain.
I have a factory function that will return an object.
My code looks like this:

namespace.createMyClass() {
 (...)
 return {
   function1: function() {},
   function2: function() {}
   (...)
 }
}

The "prototype" of the class instance is what is returned by the factory 
function.

In order to generate doc for the class, I have to do the following:

/** class */
namespace.MyClass = {}; // dummy object so that jsdoc toolkit capture there is 
a class

And I need to add between the return statement and the object:
/** @lends namespace.MyClass.prototype */

Ideally, I would like to be able to annotate the createMyClass function so that:
- specify the name of the class the factory function creates
- functions / properties returned by the function are considered as the public 
method / properties of the class
- functions  inside the factory are considered as private method

What do you think?
regards
Jeff

Original issue reported on code.google.com by jeff.r...@gmail.com on 17 Dec 2010 at 1:34