sync fixes
authorAlan Knowles <alan@roojs.com>
Sun, 27 Nov 2011 14:56:42 +0000 (22:56 +0800)
committerAlan Knowles <alan@roojs.com>
Sun, 27 Nov 2011 14:56:42 +0000 (22:56 +0800)
18 files changed:
Date.js
JSDOC/BuildDocs.js
JSDOC/Collapse.js
JSDOC/CompressWhite.js
JSDOC/DocComment.js
JSDOC/DocTag.js
JSDOC/Identifier.js
JSDOC/Lang.js
JSDOC/Options.js
JSDOC/PrettyPrint.js
JSDOC/ScopeNamer.js
JSDOC/ScopeParser.js
JSDOC/Symbol.js
JSDOC/SymbolSet.js
JSDOC/Token.js
JSDOC/TokenReader.js
examples/jsdoc_templates/class.html
examples/jsdoc_templates/static/default.css

diff --git a/Date.js b/Date.js
index 1653823..78da992 100644 (file)
--- a/Date.js
+++ b/Date.js
@@ -662,7 +662,8 @@ XObject.extend(Date.prototype,
          * Get the number of days in the current month, adjusted for leap year.
          * @return {Number} The number of days in the month
          */
-        getDaysInMonth : function() {
+        getDaysInMonth : function()
+        {
             Date.daysInMonth[1] = this.isLeapYear() ? 29 : 28;
             return Date.daysInMonth[this.getMonth()];
         },
@@ -671,7 +672,8 @@ XObject.extend(Date.prototype,
          * Get the English ordinal suffix of the current day (equivalent to the format specifier 'S').
          * @return {String} 'st, 'nd', 'rd' or 'th'
          */
-        getSuffix : function() {
+        getSuffix : function()
+        {
             switch (this.getDate()) {
                 case 1:
                 case 21:
@@ -711,7 +713,8 @@ XObject.extend(Date.prototype,
         </code></pre>
          * @return {Date} The new Date instance
          */
-        clone : function() {
+        clone : function()
+        {
             return new Date(this.getTime());
         },
 
@@ -720,7 +723,8 @@ XObject.extend(Date.prototype,
          @param {Boolean} clone true to create a clone of this date, clear the time and return it
          @return {Date} this or the clone
          */
-        clearTime : function(clone){
+        clearTime : function(clone)
+        {
             if(clone){
                 return this.clone().clearTime();
             }
@@ -755,38 +759,46 @@ XObject.extend(Date.prototype,
          * @param {Number} value      The amount to add to the current date
          * @return {Date} The new Date instance
          */
-        add : function(interval, value){
-          var d = this.clone();
-          if (!interval || value === 0) return d;
-          switch(interval.toLowerCase()){
-            case Date.MILLI:
-              d.setMilliseconds(this.getMilliseconds() + value);
-              break;
-            case Date.SECOND:
-              d.setSeconds(this.getSeconds() + value);
-              break;
-            case Date.MINUTE:
-              d.setMinutes(this.getMinutes() + value);
-              break;
-            case Date.HOUR:
-              d.setHours(this.getHours() + value);
-              break;
-            case Date.DAY:
-              d.setDate(this.getDate() + value);
-              break;
-            case Date.MONTH:
-              var day = this.getDate();
-              if(day > 28){
-                  day = Math.min(day, this.getFirstDateOfMonth().add('mo', value).getLastDateOfMonth().getDate());
-              }
-              d.setDate(day);
-              d.setMonth(this.getMonth() + value);
-              break;
-            case Date.YEAR:
-              d.setFullYear(this.getFullYear() + value);
-              break;
-          }
-          return d;
+        add : function(interval, value)
+        {
+            var d = this.clone();
+            if (!interval || value === 0) return d;
+            switch(interval.toLowerCase()){
+                case Date.MILLI:
+                    d.setMilliseconds(this.getMilliseconds() + value);
+                    break;
+                
+                case Date.SECOND:
+                    d.setSeconds(this.getSeconds() + value);
+                    break;
+                
+                case Date.MINUTE:
+                    d.setMinutes(this.getMinutes() + value);
+                    break;
+                
+                case Date.HOUR:
+                    d.setHours(this.getHours() + value);
+                    break;
+                
+                case Date.DAY:
+                    d.setDate(this.getDate() + value);
+                    break;
+                
+                case Date.MONTH:
+                    var day = this.getDate();
+                    if(day > 28){
+                        day = Math.min(day, this.getFirstDateOfMonth().add('mo', value).getLastDateOfMonth().getDate());
+                    }
+                    d.setDate(day);
+                    d.setMonth(this.getMonth() + value);
+                    break;
+                
+                case Date.YEAR:
+                    d.setFullYear(this.getFullYear() + value);
+                    break;
+                
+            }
+            return d;
         }
 
 });
\ No newline at end of file
index 90c820c..a4f6bcf 100644 (file)
@@ -1,9 +1,21 @@
-//<script type="text/javascript">
+        
+Gio = imports.gi.Gio;
+
+XObject      = imports.XObject.XObject;
+File        = imports.File.File;
+
+
+
+Template     = imports.JsTemplate.Template.Template;
+Link        = imports.JsTemplate.Link.Link; // ?? fixme!??
+
+      
+   
 /**
- *
  * This is the main container for the JSDOC application.
  *
- *usage::
+ * <PRE>
+usage::
     
     BuildDocs = imports.JSDOC.BuildDocs.BuildDocs
     
     or command line:
     
     new ArgsParser(argv, imports.BuildDocs.BuildDocs )
+ * </PRE>
+ *
  *
+ * What it does..
+ *  - tokenizes, collapse, then runs each file through ScopeNamer.
+ *  - this is cached (so reparsing is not always needed)
+ *  This in turn builds 'symbolSet' - which
+ *  - after all symbols are read - symbolSet.relate(); is called.
+ *
  * @scope JSDOC
- */
-       
-        
-Gio = imports.gi.Gio;
-
-XObject      = imports.XObject.XObject;
-File        = imports.File.File;
-
-
-
-Template     = imports.JsTemplate.Template.Template;
-Link        = imports.JsTemplate.Link.Link; // ?? fixme!??
-
-      
-   
-/**
- * 
  * @class  BuildDocs
  *
  * Main class used to build documentation
@@ -52,7 +58,7 @@ BuildDocs = XObject.define(
 
         });
         */
-         
+        imports.ScopeNamer.ScopeNamer.builder = this;
         
         this.build();
     
@@ -132,10 +138,11 @@ BuildDocs = XObject.define(
          */
         ignoreNamespace : false,
         
-        
-        
-        
-        
+        /**
+         * @cfg {Boolean} treatUnderscoredAsPrivate automatically flag underscore prefixed properties as private.
+         */
+        treatUnderscoredAsPrivate : true,
+       
         /**
          * Full list of source files.
          * @private
@@ -331,9 +338,9 @@ BuildDocs = XObject.define(
             
             imports.ScopeNamer.ScopeNamer.symbols.relate();
             
-            //print(JSON.stringify(
-            //    XObject.keys(imports.ScopeNamer.ScopeNamer.symbols._index),
-            //null, 4));
+             print(JSON.stringify(
+                XObject.keys(imports.ScopeNamer.ScopeNamer.symbols._index),
+            null, 4));
             
              
              //print(JSON.stringify(imports.ScopeNamer.ScopeNamer.symbols._index, null,4));
@@ -447,12 +454,12 @@ BuildDocs = XObject.define(
                 
                 
                 //symbol.ignoreNamespace = this.ignoreNamespace;
-                
-                var ns = File.dirname(symbol.srcFile).replace(/\//g,'.');
-                if (symbol.alias.substring(0, ns.length) == ns) {
-                    ns = '';
-                }
-                ns += ns.length ? '.' : ''; 
+                var ns = '';
+                //var ns = File.dirname(symbol.srcFile).replace(/\//g,'.');
+                //if (symbol.alias.substring(0, ns.length) == ns) {
+                //    ns = '';
+               // }
+                //ns += ns.length ? '.' : ''; 
                 
                 
                 this.LOG.inform("classTemplate Process : " +
index cb937bf..c555600 100644 (file)
@@ -6,11 +6,7 @@ console     = imports.console.console;
 
 // make sure parent is loaded..
 TokenStream = imports.TokenStream.TokenStream;
-/**
- * 
- */
-
+  
 /**
  * @scope JSDOC
  * @class Collapse
@@ -316,9 +312,9 @@ Collapse = XObject.define(
         toProps : function(ar)
         {
             
-            var ret = { }
+            var ret = { };
                
-            var g = { key : '', val: [] }
+            var g = { key : '', val: [] };
                
             
             var k = '';
index 3c958b6..6a5d8f7 100644 (file)
@@ -1,17 +1,17 @@
  // <script type="text/javascript">
 /**
- * @scope JSDOC
- * @class CompressWhite
- *
+
  * FIXME = need to class'ify this..
  *
- *
- * 
  * pack a javascript file, and return a shorter version!
  * 
  * a bit picky at present with ; and crlf reading...
- * @arg ts {TokenStream} 
-   @arg packer {Packer} 
+ *
+ * 
+ * @scope JSDOC.CompressWhite
+ * @function
+ * @arg  {TokenStream} ts 
+ * @arg {Packer} packer
  */
  
 CompressWhite =  function (ts, packer, keepWhite)
index 97af318..8ba3674 100644 (file)
@@ -7,6 +7,57 @@ DocTag = imports.DocTag.DocTag;
 /**
  * Create a new DocComment. This takes a raw documentation comment,
  * and wraps it in useful accessors.
+ <PRE>
+Valid Comments are:
+
+Without arguments:
+    method
+    constant 
+    constructor
+    static
+    singleton
+    inner
+    field
+    function
+    event
+    private
+    ignore
+    public
+    
+With arguments:
+    author [name]
+    desc [description]
+    overview [description]
+    since [when]
+    version [name]
+    depricated [since]
+    example [followed by example..]
+    see [what]
+    class [description optional]
+    namespace [description optional]
+    param [{TYPE}] [name] [description]
+    name [name]
+    property [{type}] [name] description (i think)
+    cfg [{type}] [name] [description]
+    return [{type}] [description]
+    throws [{type}]
+    requires [what]
+    type [{type}] [description]
+    inherits [what]
+    augments [what]
+    default [value]
+    memberOf [what]
+    
+    
+  Notes:
+    a static class becomes a namespace..
+    for properties in the body of the class use type , rather than property,
+       property is normally used on the Class def header, rather than inline.
+    
+    ignore - will stop the parser if it's in the global scope.
+    
+ *
+ * 
  * @class Represents a documentation comment object.
  * @scope JSDOC
  */ 
index 077ba69..fffa782 100644 (file)
@@ -8,8 +8,11 @@ Options = imports.Options.Options;
  
 /**
  * DocTag - represents a single A=b tag.
+ *
+ * 
  * @class DocTag
  * @scope JSDOC
+ * 
  */
   
  
index f3ad09d..8560782 100644 (file)
@@ -1,10 +1,13 @@
 //<Script type="text/javascript">
 
 /**
- * @class  Identifier
  * holds details about identifiers and their replacement values
  * used by the packer..
- * @scope JSDOC 
+ * 
+ * @class  Identifier
+ * @scope JSDOC
+ * @param {String} name Name of the Identifier
+ * @param {JSDOC.Scope} scope The scope that the identifer is in.
  */
 
 
index 6297020..876fe70 100644 (file)
@@ -1,7 +1,11 @@
 //<script type="text/javscript">
 
 /**
-* @scope JSDOC 
+* Language related methods (eg. what's a token...)
+*
+* @scope JSDOC
+* @class Lang
+* @static
 */
 Lang = {
     
index 017758d..8854c0f 100644 (file)
@@ -1,15 +1,16 @@
-//<script type="text/javascript">
-/**
- * Options management...
- * @scope JSDOC 
 
- */
 XObject = imports.XObject.XObject;
 File = imports.File.File;
 
  /**
   * @class Options
   * @static
+  *  Options management...
+  * @scope JSDOC 
+  * @ignore
+  *
+  * Deprecated at present..
   */
 Options = {
 
index 89253ee..e98752a 100644 (file)
@@ -9,7 +9,7 @@ TextStream = imports.TextStream.TextStream;
  
 /**
  * @scope JSDOC.PrettyPrint
- * @function
+ * @static
  * escape HTML, very basically
  */
 function  escapeHTML(str) { 
@@ -19,7 +19,7 @@ function  escapeHTML(str) {
             replace(/"/g,'&quot;');
 };
 /**
- * @function
+ * @static
  * make a pretty HTML file out of a JS file, using the tokenizer.
  */
 function toPretty(str)
index 17d061c..97d1118 100644 (file)
@@ -7,7 +7,7 @@ Symbol = imports.Symbol.Symbol;
 
 /**
  * @class ScopeNamer
- * @extends Collapse
+ * @extends JSDOC.Collapse
  * @scope JSDOC
  * The point of this class is to iterate through the Collapsed tree
  * and add the property 'scopedName' to the tokens.
@@ -89,6 +89,7 @@ ScopeNamer = XObject.define(
         Symbol.srcFile = this.filename;
         this.createJSDOC = true;
         this.global = '_global_';
+        this.locals = this.locals || [];
        // console.dump(ar);
         
     }, 
@@ -104,7 +105,7 @@ ScopeNamer = XObject.define(
         debugCall : function(str)  {
             
             
-            //if (this.filename.match(/Scope\.js/)) return print(str);
+           // if (this.filename.match(/Date\.js/)) return print(str);
             return;
         }, 
         
@@ -116,7 +117,7 @@ ScopeNamer = XObject.define(
                 this.statements = this.collapse(this.tokens);
                 //print(JSON.stringify(this.s, null,4));
             }
-            
+            //if (this.filename.match(/Roo\.js/)) print(JSON.stringify(this.statements, null,4));
             //this.globalScope(this.statements);
             this.debugCall("build Symbols");
             //print (this.statements);
@@ -136,24 +137,28 @@ ScopeNamer = XObject.define(
         
         walkStatements: function(scope, statements)
         {
-            this.debugCall("walkStatements :" + scope ) ;            
+            this.debugCall("walkStatements :" + scope + '@' + statements[0][0].line) ;            
             var _this = this;
             var res = false;
             var isGlobal = scope == this.global;
            
+            
+           
             statements.some(function(st ) {
                 // handle change of scope..
                 if (isGlobal &&
                         st[0].jsdoc &&
                         st[0].jsdoc.getTag('scope').length
                    ) {
-                    //print(st[0].jsdoc.getTag('scope'));
+                    
+                    
                     scope = st[0].jsdoc.getTag('scope');
                     // might be an array..
                     if (typeof(scope) != 'String') {
                         scope = scope[0].desc;
                         
                     }
+                    print("SCOPE CHANGE TO:" + scope);
                     _this.global = scope;
                 }
                 
@@ -174,8 +179,9 @@ ScopeNamer = XObject.define(
              
             var name;
             var sn;
+            var token = false; 
             
-            var isGlobal = scope == this.global;
+            var isGlobal = scope ==   this.global;
             
             
             
@@ -195,6 +201,11 @@ ScopeNamer = XObject.define(
             
             while (null != (token = this.next())) {
                 
+                
+                // var xx =
+                 
+                
+                
                 //'function' 
                 //walkFunction(scope, name , args,  stmts  )
                 //
@@ -204,6 +215,9 @@ ScopeNamer = XObject.define(
                         name = isGlobal ? this.lookTok(1).data : '';
                         
                         this.walkFunctionDef(scope, name, this.lookTok(2).args, this.lookTok(3).items, token);
+                        this.next();
+                        this.next();
+                        this.next();
                         continue;
                     }
                      //a = function() { } << scope might be a  $this$={a}
@@ -229,6 +243,8 @@ ScopeNamer = XObject.define(
                         
                         
                         this.walkFunctionDef(scope, name, this.lookTok(1).args, this.lookTok(2).items, this.lookTok(-2));
+                        this.next();
+                        this.next();
                         continue;
                     }
                     
@@ -254,6 +270,8 @@ ScopeNamer = XObject.define(
                         jsdoc = jsdoc || this.lookTok(-2).jsdoc;
                     }
                     this.walkCall(scope, assign, token.data, this.lookTok(1).items, jsdoc);
+                    this.next();
+                        
                     continue;
                 }
                 
@@ -273,25 +291,40 @@ ScopeNamer = XObject.define(
                     // using @type {string} for example.
                     // FIXME - they should be registered as a property...
                     if (jd && jd.jsdoc && jd.jsdoc.getTag('type').length) {
-                        
                          
-                        name = false;
+                        //name = false;
+                        //continue;
+                        // wipe out the children..
+                        token.props = false;
                     }
-                    
-                     
-                        
+                    /*
+                    print(JSON.stringify({
+                        name : name,
+                        isGlobal : isGlobal,
+                        isVar : isVar
+                    }, null,4));
+                    */  
                         
                     if (!isGlobal) {
                         // not global.
                         if (isVar) {
+                            if (name && this.locals.indexOf(name) < 0) {
+                                this.locals.push(name);
+                            }
                             name = false;
+                            continue;
                         }
+                        if (this.locals.indexOf(name) > -1 ) {
+                            continue;
+                        }
+                        
+                        
                         if (name && !name.match(/^this\./)) {
                             name = false;
                         }
                         if (name && name.match(/^this\./) ) { 
                             // see if scope ends in prototype..
-                            print("SCOPE:" + JSON.stringify(scope));
+                            //print("q" + JSON.stringify(scope));
                             if (
                                 (scope.split('.').pop() == 'prototype') &&
                                 (name.split('.').length == 2)
@@ -311,12 +344,105 @@ ScopeNamer = XObject.define(
                     continue;
                 }
                  
-                // this.xxxx = (with jsdoc...)
                 
+                 //  'assignment..'
+                 // it's done on the third element to enable object assignment to work above..
+                //   a = .....
+                if (this.lookTok(-1).data == '=' && this.lookTok(-2).is('NAME')) {
+                    
+                    
+                    
+                    // could be var x = ..
+                    var jd = this.lookTok(-2).jsdoc ? this.lookTok(-2) : this.lookTok(-3);
+                    
+                    var isVar = this.lookTok(-3).name == 'VAR';
+                    
+                    // only register names of objects if 
+                    var name = this.lookTok(-2).data;
+                    
+                    // some a = {} can be hidden
+                    // using @type {string} for example.
+                    // FIXME - they should be registered as a property...
+                    if (jd && jd.jsdoc && jd.jsdoc.getTag('type').length) {
+                         
+                        //name = false;
+                        //continue;
+                        // wipe out the children..
+                        token.props = false;
+                    }
+                    /*
+                    print(JSON.stringify({
+                        name : name,
+                        isGlobal : isGlobal,
+                        isVar : isVar
+                    }, null,4));
+                    */
+                    
+                    // skip imports.
+                    if (token.data.match(/imports\./)) {
+                        name = false;
+                    }
+                    
+                        
+                    if (!isGlobal) {
+                        // not global.
+                        if (isVar) {
+                            if (name && this.locals.indexOf(name) < 0) {
+                                this.locals.push(name);
+                            }
+                            name = false;
+                            continue;
+                        }
+                        if (this.locals.indexOf(name) > -1 ) {
+                            continue;
+                        }
+                        
+                        if (name && !name.match(/^this\./)) {
+                            name = false; 
+                        }
+                        
+                        
+                        if (name && name.match(/^this\./) ) { 
+                            // see if scope ends in prototype..
+                            //print("SCOPE:" + JSON.stringify(scope));
+                            if (
+                                (scope.split('.').pop() == 'prototype') &&
+                                (name.split('.').length == 2)
+                            ){
+                                name = name.split('.').pop();
+                            } else {
+                                name = false;
+                            }
+                            
+                        }   
+                        
+                    } else {
+                        // should not happen...
+                        if (name && name.match(/^this\./)) {
+                            name = false; 
+                        }
+                    }
+                    
+
+                    if (name) {
+                        var symbol = new Symbol( scope +'.'+ name , false , "PROPERTY" ,  jd.jsdoc);
+                        symbol._token = this.lookTok(-2);
+                           
+                        this.addSymbol(symbol, jd.jsdoc);
+                        continue;
+                    }
+                    
+                    
+                     
+                }
                 
+                // TODO:
+                // this.xxxx = (with jsdoc...)
+
+                      
                 
                  
-                // standard flow....
+                // standard flow... - ignore opening {.
                 if (token.data == '{') { 
                     sn = new ScopeNamer(this);
                     //print("GOT { - walkings statuements;}");
@@ -324,10 +450,30 @@ ScopeNamer = XObject.define(
                         continue; // object..!?!?!? = ignore ???
                         print(JSON.stringify(token,null,4));
                     }
+                     
+                    
+                    //print ("GOT { = running walk statemengs on children?} @" + this.cursor);
                     sn.walkStatements(scope, token.items);
                     continue;
                 }
+                  if (this.filename.match(/Roo\.js/)   && token.data == '(')  {
+                    //print(JSON.stringify(token,null,4));
+                      
+                  }
+                // ( function() { 
+                if ((token.data == '(') && (token.items[0][0].data == 'function')) {
+                    sn = new ScopeNamer(this);
+                    sn.walkStatements('_private_', token.items[0][2].items);
+                    continue;
+                    
+                }
+                
+                
+                
             }
+            
+             this.debugCall("walkStatement (END):" + this.global +'/' +scope + '@' + this.tokens[0].line );
+           
         },
         
         walkFunctionDef : function (inscope, name, args, stmts, jsdocTok)
@@ -340,8 +486,9 @@ ScopeNamer = XObject.define(
                 this.addSymbol(symbol, jsdocTok.jsdoc);
             }
             var sn = new ScopeNamer(this);
-            sn.walkStatements(scope, stmts);
             
+            sn.walkStatements(scope, stmts);
+            this.debugCall("wallkFuncDef:  (END)" + inscope + '#' + name + '@' + this.look(0).line );
         },            
         
         
@@ -362,13 +509,22 @@ ScopeNamer = XObject.define(
                 // or... x = somecall(BASE, { ... object..})
                 case 'XObject.extend':
                 case 'Roo.apply':
+                case 'Roo.applyIf':
                     //print(JSON.stringify(items,null,4));
                     // SHOULD WE ADD SCOPE HERE???
+                    
+                    var arg0 = items[0][0].data;
+                    
                     var topscope = scope.split('.').pop();
                     
-                    scope = (topscope == items[0][0].data) ?
-                        items[0][0].data :
-                        scope + '.' + items[0][0].data;
+                    scope = (topscope == arg0) ? arg0 : scope + '.' + arg0;
+                    
+                    // see if arg0 is defined has a symbol..
+                    if (this.haveSymbol(arg0)) {
+                        scope = arg0;
+                    }
+                    
+                    
                     // 2nd arg is a object def
                     if (items[1][0].data != '{') {
                         return;
@@ -386,7 +542,8 @@ ScopeNamer = XObject.define(
                     
                     //print(JSON.stringify(items,null,4));
                     sn.walkObject(scope , false, items[1][0].props, jsdocTok );
-                    
+                    this.debugCall("walkCall(END): " + inscope  +':' + assign + '@' + this.look(0).line + ' ' + callname );
+           
                     return;
                 
                 
@@ -407,13 +564,16 @@ ScopeNamer = XObject.define(
                     
                     
                     sn.walkObject(scope + '.prototype', false, items[2][0].props );
+                    this.debugCall("walkCall(END): " + inscope  +':' + assign + '@' + this.look(0).line + ' ' + callname );
+           
                     return;
                 
                 
                 
             }
             
-            
+            this.debugCall("walkCall(END): " + inscope  +':' + assign + '@' + this.look(0).line + ' ' + callname );
+           
              
         },
                             
@@ -432,7 +592,13 @@ ScopeNamer = XObject.define(
             if (!items) {
                 return;
             }
-            print(typeof(items));
+            // our other scenario is where something is flagged as private, we will not investigate further
+            // we do add it however..
+            if (jsdocTok && jsdocTok.jsdoc && jsdocTok.jsdoc.getTag('private').length) {
+                return;
+            }
+            
+            //print(typeof(items));
             this.debugCall("wallkObject : " + scope + '#' + name + '@' + items[Object.keys(items)[0]].key.line);
             for( var k in items) {
                 var key = items[k].key;
@@ -516,9 +682,11 @@ ScopeNamer = XObject.define(
             //if (this.conf.treatUnderscoredAsPrivate && symbol.name.match(/[.#-]_[^.#-]+$/)) {
             //    symbol.isPrivate = true;
             //}
-            
+            if (ScopeNamer.builder.treatUnderscoredAsPrivate && symbol.name.match(/[.#-]_[^.#-]+$/)) {
+                symbol.isPrivate = true;
+            }
             // -p flag is required to document private things
-            if ((symbol.isInner || symbol.isPrivate) && !this.docPrivate) return;
+            //if ((symbol.isInner || symbol.isPrivate) && !this.docPrivate) return;
             
             // ignored things are not documented, this doesn't cascade
             if (symbol.isIgnored) return;
@@ -534,6 +702,13 @@ ScopeNamer = XObject.define(
             
             ScopeNamer.symbols.addSymbol(symbol);
         },
+        
+        haveSymbol: function(name)
+        {
+            return ScopeNamer.symbols.hasSymbol(name);
+             
+        },
+        
         addBuiltin : function(name) {
 
             var builtin = new Symbol(name, [], "CONSTRUCTOR", new imports.DocComment.DocComment(""));
index 84f8c43..23753dd 100644 (file)
@@ -3,12 +3,11 @@
 Scope = imports.Scope.Scope;
 TokenStream = imports.TokenStream.TokenStream;
 /**
-* This code now uses the collapsed tree
-* Used by packer to determine scope
+* This is the code that determines scope variables for the minifier.
+* it uses a collapsed tree.
 * 
 * @class ScopeParser
-* @scope JSDOC 
-* 
+* @scope JSDOC
 * 
 */
 
index 6bcddd9..2218897 100644 (file)
@@ -390,6 +390,9 @@ Symbol = XObject.define(
             if (namespaces.length) {
                 // scope for this file...
                 this.classDesc = namespaces[0].desc+"\n"+this.desc; // desc can't apply to the constructor as there is none.
+                if (!this.classDesc) {
+                    this.classDesc = this.desc;
+                }
                 this.isNamespace = true;
             }
             
@@ -481,7 +484,7 @@ Symbol = XObject.define(
             if (this.comment.getTag("singleton").length) {
                 this.isStatic = true;
                 if (this.isa == "CONSTRUCTOR") {
-                       this.isNamespace = true;
+                    this.isNamespace = true;
                 }
             }
             
@@ -733,10 +736,11 @@ Symbol = XObject.define(
 
         inherit : function(symbol) {
             if (!this.hasMember(symbol.name) && !symbol.isInner) {
-                if (symbol.is("FUNCTION"))
+                if (symbol.is("FUNCTION")) {
                     this.methods.push(symbol);
-                else if (symbol.is("OBJECT"))
+                } else if (symbol.is("OBJECT") || symbol.is("PROPERTY") ) {
                     this.properties.push(symbol);
+                }
             }
         },
 
@@ -745,7 +749,7 @@ Symbol = XObject.define(
         },
 
         addMember : function(symbol) {
-            //println("ADDMEMBER: " + this.name +  " ++ " + symbol.name);
+            //print("ADDMEMBER: " + this.name +  "  + " + symbol.name);
             if (this.is("FUNCTION")) {
                 this.isa = "OBJECT";
             }
@@ -759,10 +763,12 @@ Symbol = XObject.define(
                 this.addMethod(symbol);
                 return true;
             }
-            if (symbol.is("OBJECT")) {
+            if (symbol.is("OBJECT") || symbol.is("PROPERTY") ) {
                 this.addProperty(symbol);
                 return true;
             }
+            //print("addSomething?: " + JSON.stringify(symbol, null,4)); Seed.exit();
+            
             return false;
         },
 
@@ -797,6 +803,7 @@ Symbol = XObject.define(
         },
 
         addProperty : function(symbol) {
+            //print("addProperty: " + this.name +  "  + " + symbol.name);
             var propertyAlias = symbol.alias;
             var thisProperties = this.properties;
             for (var i = 0, l = thisProperties.length; i < l; i++) {
index 09c0cd4..377e391 100644 (file)
@@ -1,17 +1,14 @@
-//<script type="text/javascript">
-
  
 XObject         = imports.XObject.XObject;
 DocComment      = imports.DocComment.DocComment;
-// circular references..
-///Options         = imports.BuildDocs.Options;
-//Parser          = imports.Parser.Parser;
-//Symbol          = imports.Symbol.Symbol;
 
 /**
+ * The point of this class is to store and manage all the symbols
+ *
  * @scope JSDOC
  * @class ScopeSet
- * The point of this class is to store and manage all the symbols
+ * 
  *
  */ 
 
@@ -115,8 +112,13 @@ SymbolSet = XObject.define(
             this.resolveMemberOf();
             this.resolveAugments();
         },
-
-        resolveBorrows : function() {
+        /**
+         * Resolve borrows -
+         *  = it reads 'inherits' loops thorugh it.. not sure yet what it does..
+         *
+         */
+        resolveBorrows : function()
+        {
             for (p in this._index) {
                 var symbol = this._index[p];
                 
@@ -159,8 +161,13 @@ SymbolSet = XObject.define(
                 }
             }
         },
-
-        resolveMemberOf : function() {
+        /**
+         * puts all the properties, cfg, ??events and methods into the owning class.
+         *
+         *
+         */
+        resolveMemberOf : function()
+        {
             for (var p in this._index) {
                 var symbol = this.getSymbol(p);
                 
@@ -176,9 +183,9 @@ SymbolSet = XObject.define(
                     if (parts) {
                         symbol.memberOf = parts[1];
                         symbol.name = parts[2];
-                    }
-                    // like bar is a memberOf foo
-                    else {
+                   
+                        // like bar is a memberOf foo
+                     } else {
                         var joiner = symbol.memberOf.charAt(symbol.memberOf.length-1);
                         if (!/[.#-]/.test(joiner)) symbol.memberOf += ".";
                         
@@ -207,7 +214,7 @@ SymbolSet = XObject.define(
                             symbol.isInner = false;
                             break;
                             
-                        case '-' :
+                        case '-' :  // WTF is this about???
                             symbol.isStatic = false;
                             symbol.isInner = true;
                             break;
@@ -225,26 +232,32 @@ SymbolSet = XObject.define(
                     symbol.memberOf = symbol.memberOf.substr(0, symbol.memberOf.length-1);
                 }
                 
-                 //print("looking for memberOf: " + symbol.memberOf + " FOR " + symbol.alias);
+                //print("looking for memberOf: " + symbol.memberOf + " FOR " + symbol.alias);
                 // add to parent's methods or properties list
                 if (symbol.memberOf) {
+                    
                     var container = this.getSymbol(symbol.memberOf);
                     if (!container) {
                         if (SymbolSet.isBuiltin(symbol.memberOf)) {
                             container = imports.ScopeNamer.ScopeNamer.addBuiltin(symbol.memberOf);
                         }
                         else {
-                           // print("symbol NOT a BUILT IN - createing a container");
+                            print("symbol NOT a BUILT IN - createing a container " + symbol.memberOf);
                             // Eg. Ext.y.z (missing y)
                             // we need to add in the missing symbol...
-                            container = new imports.Symbol.Symbol(symbol.memberOf, [], "OBJECT", new DocComment(""));
-                            //container.isNamespace = true;
+                            container = new imports.Symbol.Symbol(symbol.memberOf, [], "OBJECT",
+                                                            new DocComment("@namespace " + symbol.memberOf));
+                            container.isNamespace = true;
                             this.addSymbol( container );
+                            if (container.addMember(symbol)) {
+                                //print("DELETE (added to container..): " + container.alias + ' => ' + symbol.alias);
+                                this.deleteSymbol(symbol.alias);
+                            }
                             // print(container.toSource());
                             //container = this.getSymbol(symbol.memberOf);
                             // fake container ... so dont ad symbols to it..
                             continue;
-                            container = false;
+                            //container = false;
                             //LOG.warn("Can't document "+symbol.name +" as a member of undocumented symbol "+symbol.memberOf+".");
                             //LOG.warn("We only have the following symbols: \n" + 
                             //    this.keys.toSource());
@@ -261,10 +274,23 @@ SymbolSet = XObject.define(
                             this.deleteSymbol(symbol.alias);
                         }
                     }
+                    continue;
                 }
+                
+                // not a member of.. let's log them...
+                print("NOT able to resolve memberOf: "  + symbol.alias);
+                
+                
             }
         },
 
+
+        /**
+         * sort out inhertied stuff...
+         * a) calls buildAugmentsList to find out what this class extends.
+         * b) adds to symbol.inheritsFrom.
+         * c) calls sybmol.inherit / symbol.addConfig to each of the child props..
+         */
         resolveAugments : function() {
             // does this sort out multiple extends???
             for (var p in this._index) {
@@ -272,6 +298,8 @@ SymbolSet = XObject.define(
                 this.buildAugmentsList(symbol); /// build heirachy of inheritance...
                 if (symbol.alias == "_global_" || symbol.is("FILE")) continue;
                 
+                //print(JSON.stringify(symbol.augments, null, 4));
+                
                 var augments = symbol.augments;
                 for(var ii = 0, il = augments.length; ii < il; ii++) {
                     var contributer = this.getSymbol(augments[ii]);
@@ -285,19 +313,20 @@ SymbolSet = XObject.define(
                         //    imports.BuildDocs.Options.LOG.warn("Can't resolve augments: Circular reference: "+symbol.alias+" inherits from "+contributer.alias+" more than once.");
                         //}
                         //else {
-                            var cmethods = contributer.methods;
-                            var cproperties = contributer.properties;
-                            var cfgs = contributer.cfgs;
-                            for (var ci = 0, cl = cmethods.length; ci < cl; ci++) {   
-                                symbol.inherit(cmethods[ci]);
-                            }
-                            for (var ci = 0, cl = cproperties.length; ci < cl; ci++) {
-                                symbol.inherit(cproperties[ci]);
-                            }
-                            for (var ci in cfgs) {
-                                symbol.addConfig(cfgs[ci]);
-                            }
-                            
+                        
+                        var cmethods = contributer.methods;
+                        var cproperties = contributer.properties;
+                        var cfgs = contributer.cfgs;
+                        for (var ci = 0, cl = cmethods.length; ci < cl; ci++) {   
+                            symbol.inherit(cmethods[ci]);
+                        }
+                        for (var ci = 0, cl = cproperties.length; ci < cl; ci++) {
+                            symbol.inherit(cproperties[ci]);
+                        }
+                        for (var ci in cfgs) {
+                            symbol.addConfig(cfgs[ci]);
+                        }
+                        
                                 
                         //}
                     }
@@ -362,14 +391,16 @@ SymbolSet = XObject.define(
 })
 
 SymbolSet.isBuiltin = function(name) {
-    return (SymbolSet.isBuiltin.coreObjects.indexOf(name) > -1);
+    return (SymbolSet.isBuiltin_coreObjects.indexOf(name) > -1);
 }
 // private
-SymbolSet.isBuiltin.coreObjects = [
+SymbolSet.isBuiltin_coreObjects = [
     
   //   '_global_',
     'Array', 'Boolean', 'Date', 'Function', 
     'Math', 'Number', 'Object', 'RegExp', 'String'
 ];
-
-SymbolSet.LOG = false;  // reference to parser ??? might not be needed..
\ No newline at end of file
+/**
+ * reference to parser ??? might not be needed..
+ */
+SymbolSet.LOG = false;  
\ No newline at end of file
index fe7de05..39313c1 100644 (file)
@@ -4,11 +4,12 @@ XObject = imports.XObject.XObject;
  
 console = imports.console.console;
 /**
- *     @class Token
- *  @scope JSDOC
 
- *  @prop data {String} raw value of token
- *  @prop type {String} type of token
+ *  
+ *  Token of a JS file eg. a keyword, identifier, punctionaion etc..
+ *  
+ * <PRE>
+ *  Token Types:
  *     TOKN  (unknown)          - name is UNKNOWN_TOKEN
  * 
  *     KEYW  (keyword)          - name is upper case version of keyword
@@ -19,9 +20,6 @@ console = imports.console.console;
  *     STRN  (string)           - name is DOBULE_QUOTE, SINGLE_QUOTE
  *     NUMB  (number)           - name is OCTAL,DECIMAL,HEC_DEC
  *     REGX   (reg.expression)  - name is REGX
- *  @prop name {String} see type details above
- *  @prop identifier {Identifier} identifier class if relivant
- * 
  * 
  * 
  * old mappings:
@@ -30,8 +28,14 @@ console = imports.console.console;
  * Script.TOKassign  = data == '='
  * Script.TOKsemicolon data == '';
  * 
+ * </PRE>
  * 
- * 
+ *  @scope JSDOC 
+ *  @class Token
+ *  @param {String} data  raw value of token
+ *  @param {String} type  type of token
+ *  @param {String} name  see type details above
+ *  @param {JSDOC.Identifier} identifier  identifier class if relivant
 */
 
 Token = XObject.define(
@@ -49,6 +53,27 @@ Token = XObject.define(
     }, 
     Object, 
     {
+        /** @type {String} The raw text of the token */
+        data : false,
+        /** @type {String} The type of the token */
+        type : false,
+        /** @type {String} name of the token (eg. "MULTI_LINE_COMM" ) - see table above */
+        name : false,
+        /** @type {Number} line the token occurs on. */
+        line : false,
+        /** @type {String} white or comment prefix for rebuilding source*/
+        prefix : false,
+        /** @type {String} used by packer/ scopeparser to store what is actually output for this */
+        outData : false,// used by packer/scopeparser
+        /** @type {String} the identifier refered to (mangled by packer) */
+        identifier : false, // used by scope
+        /** @type {Number} numberic identifier for token */
+        id : false,
+        /** @type {String} the comments that come before the token? (TBC) */
+        comment : false,
+        /** @type {JSDOC.DocTag} assigned in JSDOC.Compiler that relates to this token. */
+        jsdoc : false,
+        
          toString: function()
         {
             return 'line:' + this.line + ', type:' + this.type + 
index 4d12fe2..9b7f386 100644 (file)
@@ -191,7 +191,7 @@ TokenReader = XObject.define(
                     //Seed.print('(@' + n);
                     
                     var lt = this.lastSym(tokens, n);
-                   Seed.print(JSON.stringify(lt));
+                   //Seed.print(JSON.stringify(lt));
                     if (lt.type != 'KEYW' || ['IF', 'WHILE'].indexOf(lt.name) < -1) {
                         if (!this.ignoreBadGrammer) {
                             throw {
index 3ca57ac..c2344a0 100644 (file)
        
        <for each="dtag" in="cfgProperties">
        
-               <tr class="config-row expandable config-row-alt{+$dtag_i % 2+}{+ ((dtag.memberOf == data.alias) ?   " notInherited" : "") +}">
+               <tr class="config-row expandable config-row-alt{+$dtag_i % 2+}{+ ((dtag.memberOf == data.alias) ?   " not-inherited" : "") +}">
                   <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>
                    <td class="sig">
 
                                /* if ( !$.isNamespace || (($.memberOf != data.alias) && $.isStatic)) {
                                        if ($.isStatic)  ownProperties.push($);
                                } */
+                                /* config should not be listed in properties */
+                                if (typeof(data.cfgs[$.name]) != 'undefined') {
+                                    return false;
+                                }
+                                
                                 ownProperties.push($);
                                return true;
                
          
        <for each="member" in="ownProperties">   
         
-       
-       
+        
+         
           <tr class="property-row config-row-alt{+$member_i % 2+}{!
 
                if (member.memberOf == data.alias) {
-                       output += " notInherited";
-                }
-                 
-                !}">
+                       output += " not-inherited";
+               }
+                if (member.isPrivate) {
+                    output += " is-private";
+                }
+           !}">
             <td class="micon">
                 <a class="exi" href="#expand">&nbsp;</a>
             </td>
                  
                  
                if (!member.isInherited) {
-                       output += " notInherited";
+                       output += " not-inherited";
                 }
-                 
+                 if (member.isPrivate) {
+                    output += " is-private";
+                }
                 !}">
             <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>
           
           <tr class="method-row expandable config-row-alt{+$member_i % 2+}{!
 
                if (member.memberOf == data.alias) {
-                       output += " notInherited";
+                       output += " not-inherited";
                 }
                  
                 !}">
index 04ce73f..c80a53e 100644 (file)
@@ -332,6 +332,12 @@ div.hr {
     margin-left: 10px;
 }
 
+.is-private {
+    opacity: 0.5;
+    filter:alpha(opacity=50); /* For IE8 and earlier */
+
+}
+
 .expandable td.micon a {
     background:transparent url(http://devel.akbkhome.com/extjs/resources/images/default/tree/elbow-plus-nl.gif) no-repeat scroll 0px 0px;
     cursor:pointer}
@@ -402,8 +408,8 @@ caption.Empty
 .config-row-alt0 {
     background-color : #f8f8f8;
 }
-.notInherited td.micon,
-.notInherited td.msource
+.not-inherited td.micon,
+.not-inherited td.msource
 {
     
     background-color: #fcc;