[ 3 posts ]

J D

  • Username: jdunning
  • Joined: Fri Feb 06, 2009 1:23 pm
  • Posts: 2
  • Offline
  • Profile

Attaching functions to a container class from multiple files

Post Posted: Fri Feb 06, 2009 3:08 pm
+0-
I’m trying to document functions that are defined in different files and that sit on the same level of the namespace as some classes. Something roughly like:

Code:
[source1.js]

global = { myapp: {} };

/**
  @class global.myapp.class1 
*/
global.myapp.class1 = { };

/**
  @class global.myapp
  @static
*/

/**
  @method func1
  @static
*/
global.myapp.func1 = function() { };


[source2.js]

/**
  @class global.myapp
  @static
*/

/**
  @method func2
  @static
*/
global.myapp.func2 = function() { };

/**
  @method func3
  @static
*/
global.myapp.func3 = function() { };



What I’d like is to see global.myapp in the class list and see func1, func2 and func3 listed as its methods. I can sort of achieve that by doing the above, but global.myapp appears twice in the class list (pointing to the same page) and yuidoc complains about the global.myapp class getting redefined.

Is there no way to attach functions from different source files to the same container class? I tried specifying the full path in the @method definition outside of a class and that didn’t work either (the functions didn’t show up anywhere).

Thanks,

John

Adam Moore

YUI Contributor

  • Username: adam
  • Joined: Wed Sep 03, 2008 11:16 am
  • Posts: 356
  • GitHub: apm
  • Gists: apm
  • Offline
  • Profile
Tags:

Re: Attaching functions to a container class from multiple files

Post Posted: Fri Feb 06, 2009 3:14 pm
+0-
You can use @for for this:

@for class.defined.elsewhere
// all subsequent items are applied to class.defined.elsewhere until another @class or @for is discovered.

-Adam

J D

  • Username: jdunning
  • Joined: Fri Feb 06, 2009 1:23 pm
  • Posts: 2
  • Offline
  • Profile
Tags:

Re: Attaching functions to a container class from multiple files

Post Posted: Fri Feb 06, 2009 6:08 pm
+0-
Thanks. The documentation for @for seemed to imply it was only for creating inner classes. It does work, though the parser still complains that the class is being redefined even after I removed the extra definition.
  [ 3 posts ]
Display posts from previous:  Sort by  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum