JSDOC/Symbol.js
[gnome.introspection-doc-generator] / JSDOC / Symbol.js
1 //<script type="text/javascript">
2
3 XObject         = imports.XObject.XObject;
4
5 SymbolSet       = imports.SymbolSet.SymbolSet;
6 //Parser          = imports.Parser.Parser;
7 DocComment      = imports.DocComment.DocComment;
8 DocTag          = imports.DocTag.DocTag;
9 /**
10         Create a new Symbol.
11         @class Represents a symbol in the source code.
12  */
13 Symbol = XObject.define(
14     function() {
15         this.init();
16         if (arguments.length) this.populate.apply(this, arguments);
17         
18     },
19     Object,
20     {
21         
22         
23         name : "",
24         defaultValue : "",
25         params : [],
26         $args : [], // original arguments used when constructing.
27         addOn : "",
28         alias : "",
29         augments : [], // Doctag[]
30         author : "",
31         classDesc : "",
32         comment : {},
33         deprecated : "",
34         desc : "",
35         //events : false,
36         example : "",
37         exceptions : [],  // Doctag[]
38         inherits : [],  // Doctag[]
39         //inheritsFrom : [],
40         isa : "OBJECT", // OBJECT//FUNCTION
41         isEvent : false,
42         isConstant : false,
43         isIgnored : false,
44         isInner : false,
45         isNamespace : false,
46         isPrivate : false,
47         isStatic : false,
48         memberOf : "",
49         methods : [], // Symbol[]
50         _name : "",
51         _params : [], //Doctag[]
52         properties : [], //Doctag[]
53         requires : [],
54         returns : [],
55         see : [],
56         since : "",
57         srcFile : {},
58         type : "",
59         version : "",
60         childClasses : [],
61         cfgs : {},
62         
63         
64             
65         
66         toObject : function()
67         {
68             
69             function array2object(a)
70             {
71                 
72                 var r = [];
73                 a.forEach(function(e) {
74                     r.push(e.toObject());
75                 });
76                 return r;
77             }
78             
79             var ret = { };
80             for (var i in this) {
81                 if (Symbol.hide.indexOf(i) > -1) {
82                     continue;
83                 }
84                 switch (typeof(this[i])) {
85                     case 'function':
86                         continue;
87                     case 'object':
88                         switch(i) {
89                             //arrays..
90                             case 'params' : 
91                             case 'augments' :                             
92                             case 'exceptions' :  
93                             case 'inherits' :
94                             case 'methods' :
95                             case '_params': 
96                             case 'properties': 
97                                 ret[i] = array2object(this[i],true); 
98                                 continue;
99                                 
100                             //objects..
101                             
102                             case 'comment' :
103                                 print(JSON.stringify(this[i]));
104                                 ret[i] = this[i].toObject();
105                                 continue;
106                                 
107                             default:
108                                 print("object? :" + i);
109                                 Seed.quit();
110                         }
111                         
112                         
113                     case 'string':
114                     case 'number':
115                         ret[i] = this[i]; continue;
116                     default:
117                         print("unknown type:" + typeof(this[i]));
118                         Seed.quit();
119                    }
120             }
121             return ret;
122             
123         },
124         
125         init : function() 
126         {
127             // only initialize arrays / objects..
128             this.params = [];
129             this.$args = [];
130             
131             //this.events = [];
132             this.exceptions = [];
133             this.inherits = [];
134             //this.inheritsFrom = [];
135             this.isa = "OBJECT"; // OBJECT//FUNCTION
136             this.methods = [];
137             this._params = [];
138             this.properties = [];
139             this.requires = [];
140             this.returns = [];
141             this.see = [];
142             this.srcFile = {};
143             this.childClasses = [];
144             this.cfgs = {};
145             
146             this.comment = new DocComment();
147             this.comment.isUserComment =  false;
148             
149                
150         },
151
152         serialize : function() {
153             var keys = [];
154             for (var p in this) {
155                 keys.push (p);
156             }
157             keys = keys.sort();
158             
159             var out = "";
160             for (var i in keys) {
161                 if (typeof this[keys[i]] == "function") continue;
162                 out += "     " +keys[i]+" => "+
163                     (   
164                         (typeof(this[keys[i]]) != "object") ?  
165                             this[keys[i]] :
166                             "[" +typeof(this[keys[i]])+"]"
167                     ) + 
168                     ",\n";
169             }
170             return "\n{\n" + out + "}\n";
171         },
172
173         clone : function() {
174             var clone = new Symbol();
175             clone.populate.apply(clone, this.$args); // repopulate using the original arguments
176             clone.srcFile = this.srcFile; // not the current srcFile, the one when the original was made
177             return clone;
178         },
179
180
181
182
183         //__defineSetter__("name",
184         setName  : function(n) { 
185                 n = n.replace(/^_global_[.#-]/, ""); 
186                 n = n.replace(/\.prototype\.?/g, '#'); 
187                  n = n.replace(/#$/g, ''); 
188                 this._name = n;
189                 this.name = n; // real!
190             },
191         //);
192         //__defineGetter__("name",
193         getName : function() { return this._name; },
194         //);
195         //__defineSetter__("params", 
196         setParams  :function(v) {
197                 for (var i = 0, l = v.length; i < l; i++) {
198                     if (v[i].constructor != DocTag) { // may be a generic object parsed from signature, like {type:..., name:...}
199                         var ty = v[i].hasOwnProperty('type') ? v[i].type : '';
200                         this._params[i] = new DocTag(
201                             "param"+((ty)?" {"+ty+"}":"")+" "+v[i].name);
202                     }
203                     else {
204                         this._params[i] = v[i];
205                     }
206                 }
207                 this.params = this._params;
208             },
209         //);
210
211
212         //__defineGetter__("params",
213         getParams : function() { return this._params; },
214         //);
215
216         populate : function(
217                 /** String */ name,
218                 /** Object[] */ params,
219                 /** String */ isa,
220                 /** DocComment */ comment
221         ) {
222             this.$args = arguments;
223             //println("Symbol created: " + isa + ":" + name);
224             this.setName(name);
225             this.alias = this.getName();
226             this.setParams(params);
227             this.isa = (isa == "VIRTUAL")? "OBJECT":isa;
228             this.comment = comment || new DocComment("");
229             this.srcFile = Symbol.srcFile;
230             
231            
232             
233             if (this.is("FILE") && !this.alias) this.alias = this.srcFile;
234
235             this.setTags();
236             
237             //if (typeof PluginManager != "undefined") {
238             //    PluginManager.run("onSymbol", this);
239             //}
240         },
241
242         setTags : function() {
243             // @author
244             var authors = this.comment.getTag("author");
245             if (authors.length) {
246                 this.author = authors.map(function($){return $.desc;}).join(", ");
247             }
248             
249             /*~t
250                 assert("testing Symbol");
251                 
252                 requires("../lib/JSDOC/DocComment.js");
253                 requires("../frame/String.js");
254                 requires("../lib/JSDOC/DocTag.js");
255
256                 var sym = new Symbol("foo", [], "OBJECT", new DocComment("/**@author Joe Smith*"+"/"));
257                 assertEqual(sym.author, "Joe Smith", "@author tag, author is found.");
258             */
259             // @desc
260             var mth = this.comment.getTag("method");
261             if (mth.length) {
262                 this.isa = "FUNCTION";
263             }
264             // @desc
265             var descs = this.comment.getTag("desc");
266             if (descs.length) {
267                 this.desc = descs.map(function($){return $.desc;}).join("\n"); // multiple descriptions are concatenated into one
268             }
269             
270             /*~t
271                 var sym = new Symbol("foo", [], "OBJECT", new DocComment("/**@desc This is a description.*"+"/"));
272                 assertEqual(sym.desc, "This is a description.", "@desc tag, description is found.");
273             */
274             
275             // @overview
276             if (this.is("FILE")) {
277                 if (!this.alias) this.alias = this.srcFile;
278                 
279                 var overviews = this.comment.getTag("overview");
280                 if (overviews.length) {
281                     this.desc = [this.desc].concat(overviews.map(function($){return $.desc;})).join("\n");
282                 }
283             }
284             
285             /*~t
286                 var sym = new Symbol("foo", [], "FILE", new DocComment("/**@overview This is an overview.*"+"/"));
287                 assertEqual(sym.desc, "\nThis is an overview.", "@overview tag, description is found.");
288             */
289             
290             // @since
291             var sinces = this.comment.getTag("since");
292             if (sinces.length) {
293                 this.since = sinces.map(function($){return $.desc;}).join(", ");
294             }
295             
296             /*~t
297                 var sym = new Symbol("foo", [], "FILE", new DocComment("/**@since 1.01*"+"/"));
298                 assertEqual(sym.since, "1.01", "@since tag, description is found.");
299             */
300             
301             // @constant
302             if (this.comment.getTag("constant").length) {
303                 this.isConstant = true;
304                 this.isa = 'OBJECT';
305             }
306             
307             /*~t
308                 var sym = new Symbol("foo", [], "FILE", new DocComment("/**@constant*"+"/"));
309                 assertEqual(sym.isConstant, true, "@constant tag, isConstant set.");
310             */
311             
312             // @version
313             var versions = this.comment.getTag("version");
314             if (versions.length) {
315                 this.version = versions.map(function($){return $.desc;}).join(", ");
316             }
317             
318             /*~t
319                 var sym = new Symbol("foo", [], "FILE", new DocComment("/**@version 2.0x*"+"/"));
320                 assertEqual(sym.version, "2.0x", "@version tag, version is found.");
321             */
322             
323             // @deprecated
324             var deprecateds = this.comment.getTag("deprecated");
325             if (deprecateds.length) {
326                 this.deprecated = deprecateds.map(function($){return $.desc;}).join("\n");
327             }
328             
329             /*~t
330                 var sym = new Symbol("foo", [], "FILE", new DocComment("/**@deprecated Use other method.*"+"/"));
331                 assertEqual(sym.deprecated, "Use other method.", "@deprecated tag, desc is found.");
332             */
333             
334             // @example
335             var examples = this.comment.getTag("example");
336             if (examples.length) {
337                 this.example = examples[0];
338             }
339             
340             /*~t
341                 var sym = new Symbol("foo", [], "FILE", new DocComment("/**@example This\n  is an example.*"+"/"));
342                 assertEqual(sym.example, "This\n  is an example.", "@deprecated tag, desc is found.");
343             */
344             
345             // @see
346             var sees = this.comment.getTag("see");
347             if (sees.length) {
348                 var thisSee = this.see;
349                 sees.map(function($){thisSee.push($.desc);});
350             }
351             
352             /*~t
353                 var sym = new Symbol("foo", [], "FILE", new DocComment("/**@see The other thing.*"+"/"));
354                 assertEqual(sym.see, "The other thing.", "@see tag, desc is found.");
355             */
356             
357             // @class
358             var classes = this.comment.getTag("class");
359             if (classes.length) {
360                 this.isa = "CONSTRUCTOR";
361                 this.classDesc = classes[0].desc; // desc can't apply to the constructor as there is none.
362                 if (!this.classDesc) {
363                     this.classDesc = this.desc;
364                    }
365                 
366                 
367             }
368             
369             /*~t
370                 var sym = new Symbol("foo", [], "OBJECT", new DocComment("/**@class This describes the class.*"+"/"));
371                 assertEqual(sym.isa, "CONSTRUCTOR", "@class tag, makes symbol a constructor.");
372                 assertEqual(sym.classDesc, "This describes the class.", "@class tag, class description is found.");
373             */
374             
375             // @namespace
376             var namespaces = this.comment.getTag("namespace");
377             if (namespaces.length) {
378                 this.classDesc = namespaces[0].desc+"\n"+this.desc; // desc can't apply to the constructor as there is none.
379                 this.isNamespace = true;
380             }
381             
382             /*~t
383                 var sym = new Symbol("foo", [], "OBJECT", new DocComment("/**@namespace This describes the namespace.*"+"/"));
384                 assertEqual(sym.classDesc, "This describes the namespace.\n", "@namespace tag, class description is found.");
385             */
386             
387             // @param
388             var params = this.comment.getTag("param");
389             if (params.length) {
390                 // user-defined params overwrite those with same name defined by the parser
391                 var thisParams = this.getParams();
392
393                 if (thisParams.length == 0) { // none exist yet, so just bung all these user-defined params straight in
394                     this.setParams(params);
395                 }
396                 else { // need to overlay these user-defined params on to existing parser-defined params
397                     for (var i = 0, l = params.length; i < l; i++) {
398                         if (thisParams[i]) {
399                             if (params[i].type) thisParams[i].type = params[i].type;
400                             thisParams[i].name = params[i].name;
401                             thisParams[i].desc = params[i].desc;
402                             thisParams[i].isOptional = params[i].isOptional;
403                             thisParams[i].defaultValue = params[i].defaultValue;
404                         }
405                         else thisParams[i] = params[i];
406                     }
407                 }
408             }
409             
410             /*~t
411                 var sym = new Symbol("foo", [{type: "array", name: "pages"}], "FUNCTION", new DocComment("/**Description.*"+"/"));
412                 assertEqual(sym.params.length, 1, "parser defined param is found.");
413                 
414                 sym = new Symbol("foo", [], "FUNCTION", new DocComment("/**Description.\n@param {array} pages*"+"/"));
415                 assertEqual(sym.params.length, 1, "user defined param is found.");
416                 assertEqual(sym.params[0].type, "array", "user defined param type is found.");
417                 assertEqual(sym.params[0].name, "pages", "user defined param name is found.");
418                 
419                 sym = new Symbol("foo", [{type: "array", name: "pages"}], "FUNCTION", new DocComment("/**Description.\n@param {string} uid*"+"/"));
420                 assertEqual(sym.params.length, 1, "user defined param overwrites parser defined param.");
421                 assertEqual(sym.params[0].type, "string", "user defined param type overwrites parser defined param type.");
422                 assertEqual(sym.params[0].name, "uid", "user defined param name overwrites parser defined param name.");
423             
424                 sym = new Symbol("foo", [{type: "array", name: "pages"}, {type: "number", name: "count"}], "FUNCTION", new DocComment("/**Description.\n@param {string} uid*"+"/"));
425                 assertEqual(sym.params.length, 2, "user defined params  overlay parser defined params.");
426                 assertEqual(sym.params[1].type, "number", "user defined param type overlays parser defined param type.");
427                 assertEqual(sym.params[1].name, "count", "user defined param name overlays parser defined param name.");
428
429                 sym = new Symbol("foo", [], "FUNCTION", new DocComment("/**Description.\n@param {array} pages The pages description.*"+"/"));
430                 assertEqual(sym.params.length, 1, "user defined param with description is found.");
431                 assertEqual(sym.params[0].desc, "The pages description.", "user defined param description is found.");
432             */
433             
434             // @constructor
435             if (this.comment.getTag("constructor").length) {
436                 this.isa = "CONSTRUCTOR";
437             }
438             
439             /*~t
440                 var sym = new Symbol("foo", [], "OBJECT", new DocComment("/**@constructor*"+"/"));
441                 assertEqual(sym.isa, "CONSTRUCTOR", "@constructor tag, makes symbol a constructor.");
442             */
443             
444             // @static
445             if (this.comment.getTag("static").length) {
446                 this.isStatic = true;
447                 if (this.isa == "CONSTRUCTOR") {
448                     this.isNamespace = true;
449                 }
450             }
451             
452                 // @static
453             if (this.comment.getTag("singleton").length) {
454                 this.isStatic = true;
455                 //if (this.isa == "CONSTRUCTOR") {
456                 //      this.isNamespace = true;
457                 //}
458             }
459             
460             
461             
462             /*~t
463                 var sym = new Symbol("foo", [], "OBJECT", new DocComment("/**@static\n@constructor*"+"/"));
464                 assertEqual(sym.isStatic, true, "@static tag, makes isStatic true.");
465                 assertEqual(sym.isNamespace, true, "@static and @constructor tag, makes isNamespace true.");
466             */
467             
468             // @inner
469             if (this.comment.getTag("inner").length) {
470                 this.isInner = true;
471                 this.isStatic = false;
472             }
473             
474             /*~t
475                 var sym = new Symbol("foo", [], "OBJECT", new DocComment("/**@inner*"+"/"));
476                 assertEqual(sym.isStatic, false, "@inner tag, makes isStatic false.");
477                 assertEqual(sym.isInner, true, "@inner makes isInner true.");
478             */
479             
480             // @field
481             if (this.comment.getTag("field").length) {
482                 this.isa = "OBJECT";
483             }
484             
485             /*~t
486                 var sym = new Symbol("foo", [], "FUNCTION", new DocComment("/**@field*"+"/"));
487                 assertEqual(sym.isa, "OBJECT", "@field tag, makes symbol an object.");
488             */
489             
490             // @function
491             if (this.comment.getTag("function").length) {
492                 this.isa = "FUNCTION";
493             }
494             
495             // @param
496             if (this.comment.getTag("param").length && this.isa == "OBJECT" ) {
497                 // change a property to a function..
498                 this.isa = "FUNCTION";
499             }
500             
501             
502             /*~t
503                 var sym = new Symbol("foo", [], "OBJECT", new DocComment("/**@function*"+"/"));
504                 assertEqual(sym.isa, "FUNCTION", "@function tag, makes symbol a function.");
505             */
506             
507             // @event
508             var events = this.comment.getTag("event");
509             if (events.length) {
510                 this.isa = "FUNCTION";
511                 this.isEvent = true;
512             }
513             
514             /*~t
515                 var sym = new Symbol("foo", [], "OBJECT", new DocComment("/**@event*"+"/"));
516                 assertEqual(sym.isa, "FUNCTION", "@event tag, makes symbol a function.");
517                 assertEqual(sym.isEvent, true, "@event makes isEvent true.");
518             */
519             
520             // @name
521             var names = this.comment.getTag("name");
522             if (names.length) {
523                 this.setName(names[0].desc);
524             }
525             
526             /*~t
527                 // todo
528             */
529             
530             // @property
531             var properties = this.comment.getTag("property");
532             if (properties.length) {
533                 thisProperties = this.properties;
534                 for (var i = 0; i < properties.length; i++) {
535                     var property = new Symbol(this.alias+"#"+properties[i].name, [], "OBJECT", new DocComment("/**"+properties[i].desc+"\n@name "+properties[i].name+"\n@memberOf "+this.alias+"#*/"));
536                     // TODO: shouldn't the following happen in the addProperty method of Symbol?
537                     property.name = properties[i].name;
538                     property.memberOf = this.alias;
539                     if (properties[i].type) property.type = properties[i].type;
540                     if (properties[i].defaultValue) property.defaultValue = properties[i].defaultValue;
541                     this.addProperty(property);
542                     imports.Parser.Parser.addSymbol(property);
543                 }
544             }
545             
546             // config..
547             var conf = this.comment.getTag("cfg");
548             if (conf.length) {
549                 for (var i = 0; i < conf.length; i++) {
550                     this.addConfig(conf[i]);
551                 }
552             }
553             
554             /*~t
555                 // todo
556             */
557
558             // @return
559             var returns = this.comment.getTag("return");
560             if (returns.length) { // there can be many return tags in a single doclet
561                 this.returns = returns;
562                 this.type = returns.map(function($){return $.type}).join(", ");
563             }
564             
565             /*~t
566                 // todo
567             */
568             
569             // @exception
570             this.exceptions = this.comment.getTag("throws");
571             
572             /*~t
573                 // todo
574             */
575             
576             // @requires
577             var requires = this.comment.getTag("requires");
578             if (requires.length) {
579                 this.requires = requires.map(function($){return $.desc});
580             }
581             
582             /*~t
583                 // todo
584             */
585             
586             // @type
587             var types = this.comment.getTag("type");
588             if (types.length) {
589                 this.type = types[0].desc; //multiple type tags are ignored
590             }
591             
592             /*~t
593                 // todo
594             */
595             
596             // @private
597             if (this.comment.getTag("private").length || this.isInner) {
598                 this.isPrivate = true;
599             }
600             
601             // @ignore
602             if (this.comment.getTag("ignore").length) {
603                 this.isIgnored = true;
604             }
605             
606             /*~t
607                 // todo
608             */
609             
610             // @inherits ... as ...
611             var inherits = this.comment.getTag("inherits");
612             if (inherits.length) {
613                 for (var i = 0; i < inherits.length; i++) {
614                     if (/^\s*([a-z$0-9_.#-]+)(?:\s+as\s+([a-z$0-9_.#]+))?/i.test(inherits[i].desc)) {
615                         var inAlias = RegExp.$1;
616                         var inAs = RegExp.$2 || inAlias;
617
618                         if (inAlias) inAlias = inAlias.replace(/\.prototype\.?/g, "#");
619                         
620                         if (inAs) {
621                             inAs = inAs.replace(/\.prototype\.?/g, "#");
622                             inAs = inAs.replace(/^this\.?/, "#");
623                         }
624
625                         if (inAs.indexOf(inAlias) != 0) { //not a full namepath
626                             var joiner = ".";
627                             if (this.alias.charAt(this.alias.length-1) == "#" || inAs.charAt(0) == "#") {
628                                 joiner = "";
629                             }
630                             inAs = this.alias + joiner + inAs;
631                         }
632                     }
633                     this.inherits.push({alias: inAlias, as: inAs});
634                 }
635             }
636             
637             /*~t
638                 // todo
639             */
640
641             // @augments
642             this.augments = this.comment.getTag("augments");
643             
644             //@extends - Ext
645             if (this.comment.getTag("extends")) {   
646                 this.augments = this.comment.getTag("extends");
647             }
648             
649             
650             // @default
651             var defaults = this.comment.getTag("default");
652             if (defaults.length) {
653                 if (this.is("OBJECT")) {
654                     this.defaultValue = defaults[0].desc;
655                 }
656             }
657             
658             /*~t
659                 // todo
660             */
661             
662             // @memberOf
663             var memberOfs = this.comment.getTag("memberOf");
664             if (memberOfs.length) {
665                 this.memberOf = memberOfs[0].desc;
666                 this.memberOf = this.memberOf.replace(/\.prototype\.?/g, "#");
667             }
668
669             /*~t
670                 // todo
671             */
672             
673             // @public
674             if (this.comment.getTag("public").length) {
675                 this.isPrivate = false;
676             }
677             
678             /*~t
679                 // todo
680             */
681         },
682
683         is : function(what) {
684             return this.isa === what;
685         },
686
687         isBuiltin : function() {
688             return SymbolSet.isBuiltin(this.alias);
689         },
690
691         setType : function(/**String*/comment, /**Boolean*/overwrite) {
692             if (!overwrite && this.type) return;
693             var typeComment = DocComment.unwrapComment(comment);
694             this.type = typeComment;
695         },
696
697         inherit : function(symbol) {
698             if (!this.hasMember(symbol.name) && !symbol.isInner) {
699                 if (symbol.is("FUNCTION"))
700                     this.methods.push(symbol);
701                 else if (symbol.is("OBJECT"))
702                     this.properties.push(symbol);
703             }
704         },
705
706         hasMember : function(name) {
707             return (this.hasMethod(name) || this.hasProperty(name));
708         },
709
710         addMember : function(symbol) {
711             //println("ADDMEMBER: " + this.name +  " ++ " + symbol.name);
712             
713             if (symbol.comment.getTag("cfg").length == 1) { 
714                 symbol.comment.getTag("cfg")[0].memberOf = this.alias;
715                 this.addConfig(symbol.comment.getTag("cfg")[0]);
716                 return;
717             }
718             
719             if (symbol.is("FUNCTION")) { this.addMethod(symbol); }
720             else if (symbol.is("OBJECT")) { this.addProperty(symbol); }
721         },
722
723         hasMethod : function(name) {
724             var thisMethods = this.methods;
725             for (var i = 0, l = thisMethods.length; i < l; i++) {
726                 if (thisMethods[i].name == name) return true;
727                 if (thisMethods[i].alias == name) return true;
728             }
729             return false;
730         },
731
732         addMethod : function(symbol) {
733             var methodAlias = symbol.alias;
734             var thisMethods = this.methods;
735             for (var i = 0, l = thisMethods.length; i < l; i++) {
736                 if (thisMethods[i].alias == methodAlias) {
737                     thisMethods[i] = symbol; // overwriting previous method
738                     return;
739                 }
740             }
741             thisMethods.push(symbol); // new method with this alias
742         },
743
744         hasProperty : function(name) {
745             var thisProperties = this.properties;
746             for (var i = 0, l = thisProperties.length; i < l; i++) {
747                 if (thisProperties[i].name == name) return true;
748                 if (thisProperties[i].alias == name) return true;
749             }
750             return false;
751         },
752
753         addProperty : function(symbol) {
754             var propertyAlias = symbol.alias;
755             var thisProperties = this.properties;
756             for (var i = 0, l = thisProperties.length; i < l; i++) {
757                 if (thisProperties[i].alias == propertyAlias) {
758                     thisProperties[i] = symbol; // overwriting previous property
759                     return;
760                 }
761             }
762
763             thisProperties.push(symbol); // new property with this alias
764         },
765         
766         addDocTag : function(docTag)
767         {
768             this.comment.tags.push(docTag);
769             if (docTag.title == 'cfg') {
770                 this.addConfig(docTag);
771             }
772             
773         },
774         
775         addConfig : function(docTag)
776         {
777             if (typeof(docTag['memberOf']) == 'undefined') {
778                 // remove prototype data...
779                 //var a = this.alias.split('#')[0];
780                 //docTag.memberOf = a;
781                 docTag.memberOf = this.alias;
782             }
783             if (typeof(this.cfgs[docTag.name]) == 'undefined') {
784                 this.cfgs[docTag.name] = docTag;
785             }
786             
787         },
788         configToArray: function()
789         {
790             var r = [];
791             for(var ci in this.cfgs) {
792                 // dont show hidden!!
793                 if (this.cfgs[ci].desc.match(/@hide/)) {
794                     continue;
795                 }
796                 r.push(this.cfgs[ci]); 
797                
798             }
799             return r;
800         }
801 });
802
803 /**
804  * Elements that are not serialized
805  * 
806  */
807 Symbol.hide = [ 
808     '$args' // not needed AFAIK
809 ]
810
811 Symbol.srcFile = ""; //running reference to the current file being parsed
812
813
814 Symbol.fromDump = function(t)
815 {
816     var ns = new Symbol();
817     for (var i in t) {
818         if (typeof(ns[i]) == "undefined") {
819             println("ERR:no default for Symbol:"+ i);
820         }
821         ns[i] = t[i];
822     }
823     return ns;
824 }