sync
authorAlan Knowles <alan@roojs.com>
Thu, 13 Oct 2011 13:54:10 +0000 (21:54 +0800)
committerAlan Knowles <alan@roojs.com>
Thu, 13 Oct 2011 13:54:10 +0000 (21:54 +0800)
JSDOC/BuildDocs.js
JSDOC/DocTag.js
JSDOC/PrettyPrint.js
JSDOC/ScopeNamer.js
JSDOC/Symbol.js
JSDOC/SymbolSet.js
JSDOC/Token.js
README.txt
examples/jsdoc_templates/index.html

index f71607c..3607aa0 100644 (file)
@@ -448,7 +448,7 @@ BuildDocs = XObject.define(
                 
                 
                 
-                symbol.ignoreNamespace = this.ignoreNamespace;
+                //symbol.ignoreNamespace = this.ignoreNamespace;
                 
                 var ns = File.dirname(symbol.srcFile).replace(/\//g,'.');
                 if (symbol.alias.substring(0, ns.length) == ns) {
@@ -604,7 +604,7 @@ BuildDocs = XObject.define(
             // this stuff works...
          
             
-            var name = this.srcFileFlatName(sourceFile);
+            var name = this.srcFileFlatName(this.srcFileRelName(sourceFile)) ;
             
             this.LOG.inform("Write Source file : " + this.target+"/symbols/src/" + name + " FROM: "  + sourceFile);
             
index 4b1ac90..c4792da 100644 (file)
@@ -9,7 +9,6 @@ Options = imports.Options.Options;
 /**
  * DocTag - represents a single A=b tag.
  * @class DocTag
- * @namespace JSDOC
  */
   
  
@@ -85,8 +84,7 @@ DocTag = XObject.define(
                 // only some tags are allowed to have names.
                 if (this.title == "param" ||
                     this.title == "property" ||
-                    this.title == "cfg" ||
-                    this.title == "namespace") {
+                    this.title == "cfg") {
                     // @config is deprecated
                     
                     src = this.nibbleName(src);
index 40ed54a..9bee781 100644 (file)
@@ -1,22 +1,29 @@
 
 // <script type="text/javascript">
-/**
- * @namespace JSDOC.PrettyPrint
- */
 
 TokenReader = imports.TokenReader.TokenReader;
 ScopeParser= imports.ScopeParser.ScopeParser;
 Collapse = imports.Collapse.Collapse;
 TextStream = imports.TextStream.TextStream;
  
-
+/**
+ * @namespace
+ * @scope PrettyPrint
+ * @function
+ * escape HTML, very basically
+ */
 function  escapeHTML(str) { 
     return str.replace(/&/g,'&amp;').
             replace(/>/g,'&gt;'). 
             replace(/</g,'&lt;'). 
             replace(/"/g,'&quot;');
 };
-
+/**
+ * @scope PrettyPrint
+ * @function
+ * make a pretty HTML file out of a JS file, using the tokenizer.
+ */
 function toPretty(str)
 {
     
index f4e5ff4..a1eb87d 100644 (file)
@@ -10,26 +10,11 @@ Symbol = imports.Symbol.Symbol;
  * @namespace JSDOC
  * The point of this class is to iterate through the Collapsed tree
  * and add the property 'scopedName' to the tokens.
- * 
- *  
- * First task is to work out how to handle the recusive nature of the tree.
- * - tokenstream has tok() tokNext() etc...
  *
- * parsing basically should work like this..
- * -- walk the tree, with each iteration
- * -- increment the scope name ('|' seperated..)
- * -- pass any args that might be irrelivant to the next layer..
- * -----
- *
- * Currently bugs out as our statements are parsed on different scopes...
- *
- *
- * -- next step register doc comments..
- *
- *  Standard doc-comment - should be attached to the NAME token..
- *  --- let's start there...
- *
- * 
+ * @param {Array} tokens array of tokens (from collapse)
+ * @param {String} srcFile the original file
+ * @param {String} pscope Parent scope for all tokens (default $global$)
+ * @param {Array} args Local variables which do not need to be added to scope.
  */ 
  
 ScopeNamer = XObject.define(
@@ -103,6 +88,10 @@ ScopeNamer = XObject.define(
             }
             var r = ret.join(isStatic ? '.' : '#');
             
+            if (r.split('#').length > 1 ) {
+                return false;
+            }
+            
              print("ADD:" + scope + ' => ' + r);
             //print("CANON:"  + r);
             
@@ -110,6 +99,30 @@ ScopeNamer = XObject.define(
             
         },
         
+        pscope  : '$global$',
+        /**
+         * When parser comes across a change in scope,
+         * it get's added to the current scope name here
+         *
+         *
+         * 
+         *
+         * 
+         * @param {String} n the name
+         */
+        addScopeName: function (n)
+        {
+            var ar = this.pscope.split('|');
+            if (ar[0] == '$global$') {
+                ar.shift();
+            }
+            ar.push(n);
+            this.pscope = ar.join('|');
+            return this.pscope;
+            
+            
+        },
+        
         /**
          * same as symbol ctr...
          */
@@ -168,13 +181,14 @@ ScopeNamer = XObject.define(
                     if (token.comment) {
                         token.jsdoc = new imports.DocComment.DocComment(token.comment);
                         
-                        if (!token.depth && token.jsdoc.getTag('ignore').length) {
+                        // ignore can ingore a whole stream of statements..
+                        if (token.jsdoc.getTag('ignore').length) {
                             this.ignore = true;
                             return;
                         }
                         // allows @scope to force scope change.
                         if (token.jsdoc.getTag('scope').length) {
-                            pscope = this.pscope = token.jsdoc.getTag('scope')[0].desc;
+                            pscope = this.addScopeName(token.jsdoc.getTag('scope')[0].desc);
                         }
                         
                         
@@ -203,7 +217,7 @@ ScopeNamer = XObject.define(
                     }
                     //print("check =");
                     if (this.lookTok(1).data == '=') {
-                        print("GOT =");
+                        //print("GOT =");
                         if (this.lookTok(2).data.match(/^imports\./)) {
                             if (token.data.indexOf('.') < 0) { 
                                 skip.push(token.data);
@@ -213,13 +227,16 @@ ScopeNamer = XObject.define(
                         
                         
                         
-                        this.pscope = this.bscope + '|' + token.data;
+                        this.pscope = this.bscope
+                        this.addScopeName( token.data );
                         print("new pscope?" + this.pscope);
                         token.scopeName = this.canonize(this.pscope);
                         continue;    
                     }
                     if (this.lookTok(-1).name == 'FUNCTION') {
-                        this.pscope = this.bscope + '|' + token.data;
+                        this.pscope = this.bscope
+                        this.addScopeName( token.data );
+                        
                         token.scopeName =  this.canonize(this.pscope);;
                         //print(this.pscope);
                         continue;    
@@ -240,7 +257,7 @@ ScopeNamer = XObject.define(
                             (this.lookTok(-2).name == 'FUNCTION') || 
                             (this.lookTok(-3).name == 'FUNCTION')
                         )) {
-                         pscope +='|FUNCTION(';
+                         //pscope +='|FUNCTION(';
                     }
                     
                     if (token.items) {
@@ -278,7 +295,10 @@ ScopeNamer = XObject.define(
                                 }
                                 // allows @scope to force scope change.
                                 if (t.key.jsdoc.getTag('scope').length) {
-                                    pscope = this.pscope = t.key.jsdoc.getTag('scope')[0].desc;
+                                    this.pscope =  this.addScopeName( t.key.jsdoc.getTag('scope')[0].desc );
+                                }
+                                if (t.key.jsdoc.getTag('ignore').length) {
+                                    break;
                                 }
                                 
                             }
@@ -325,12 +345,14 @@ ScopeNamer = XObject.define(
                         token.args = [];
                     }
                     
+                    // argument list...
                     
                     
                     if (token.items) {
                         // a function call?? could be a apply or extend...
                         // 
-                        pscope += '|'+ (addargs ? 'FUNCTION' : '') + token.data;
+                        // pscope += '|'+ (addargs ? 'FUNCTION' : '') + token.data;
+                        
                         
                         token.items.forEach(function(tar) {
                             if (addargs && tar[0].data != ')') {
@@ -344,6 +366,28 @@ ScopeNamer = XObject.define(
                         });
                          
                     }
+                    
+                    // ctors..
+                    // ( function() { .... } , )
+                    
+                    if ( token.data == '(' && 
+                        (this.lookTok(-1).name == 'FUNCTION') &&
+                         this.lookTok(-1).comment.length &&
+                        (this.cursor == 2) ) {
+                        token.jsdoc = new imports.DocComment.DocComment(this.lookTok(-1).comment);
+                        var symbol = new Symbol( this.pscope, token.args || [] , "FUNCTION",
+                                    token.jsdoc || false);
+                        symbol._token = token;
+                        ScopeNamer.addSymbol(symbol, token.jsdoc);
+                        
+                    }
+                         
+                    
+                    
+                    
+                    
+                    
+                    
                     if (addargs) {
                          //print(JSON.stringify(args));
                     }
@@ -351,6 +395,9 @@ ScopeNamer = XObject.define(
                 }
                 // list in function call or argument..
                 
+                // function is the first argument
+                 
+                
                 
                 // each argument shold not inherit sope like this does...
                 
index a9c1119..313f9b9 100644 (file)
@@ -43,7 +43,7 @@ Symbol = XObject.define(
         isConstant : false,
         isIgnored : false,
         isInner : false,
-        isNamespace : false, // depreciated.
+        isNamespace : false, 
         isPrivate : false,
         isStatic : false,
         memberOf : "",
@@ -385,11 +385,9 @@ Symbol = XObject.define(
             // @namespace
             var namespaces = this.comment.getTag("namespace");
             if (namespaces.length) {
-                this.namespace = namespaces[0].name;
                 // scope for this file...
-                Symbol.namespace =  namespaces[0].name + '.';
-                //this.classDesc = namespaces[0].desc+"\n"+this.desc; // desc can't apply to the constructor as there is none.
-                //this.isNamespace = true;
+                this.classDesc = namespaces[0].desc+"\n"+this.desc; // desc can't apply to the constructor as there is none.
+                this.isNamespace = true;
             }
             
             /*~t
@@ -471,17 +469,17 @@ Symbol = XObject.define(
                 this._name = this.name
                 this.alias = this.name;
                 
-                //if (this.isa == "CONSTRUCTOR") {
-                //    this.isNamespace = true;
-                //}
+                if (this.isa == "CONSTRUCTOR") {
+                    this.isNamespace = true;
+                }
             }
             
                 // @static
             if (this.comment.getTag("singleton").length) {
                 this.isStatic = true;
-                //if (this.isa == "CONSTRUCTOR") {
-                //     this.isNamespace = true;
-                //}
+                if (this.isa == "CONSTRUCTOR") {
+                       this.isNamespace = true;
+                }
             }
             
             
index 0aad4ce..effbda1 100644 (file)
@@ -8,15 +8,23 @@ DocComment      = imports.DocComment.DocComment;
 //Parser          = imports.Parser.Parser;
 //Symbol          = imports.Symbol.Symbol;
 
-
+/**
+ * @class ScopeSet
+ * The point of this class is to store and manage all the symbols
+ *
+ */ 
 
 SymbolSet = XObject.define(
-    function(opts) {
+    function() {
         this.init();
     },
     Object,
     {
-        
+        /**
+         * @type {Object}
+         * Key:value map of alias=>sybmol.
+         */
         _index : false,
         
         
@@ -354,7 +362,9 @@ SymbolSet = XObject.define(
 SymbolSet.isBuiltin = function(name) {
     return (SymbolSet.isBuiltin.coreObjects.indexOf(name) > -1);
 }
+// private
 SymbolSet.isBuiltin.coreObjects = [
+    
   //   '_global_',
     'Array', 'Boolean', 'Date', 'Function', 
     'Math', 'Number', 'Object', 'RegExp', 'String'
index 7c15b20..264d3cc 100644 (file)
@@ -43,6 +43,8 @@ Token = XObject.define(
         this.outData = false; // used by packer/scopeparser
         this.identifier = false; // used by scope
         this.id = Token.id++;
+        this.comment = '',
+        this.jsdoc = false
     }, 
     Object, 
     {
index 57d98bd..bb01ecf 100644 (file)
@@ -10,11 +10,23 @@ Testing with RooJS:
 
 file preview is using full path?
 
-
-
-
-
-
+--------------------------------------------------
+
+Scope namer issue still:
+ - basically it's trying to guess the scope name.
+ - it's doing a so-so job of it..
+ ** It's not pretty though...
+ Classic example:
+    Date.monthNames = {
+       Jan : ....
+    }
+
+This could be an object.. so it get's put in the tree as available to document.
+  We could solve this in a number of ways
+    a) a tag on the code to indicate that it's not to be documented..
+    b) ?? how else ?? - we can not determine it simply..
 
 
 
index 35d9a73..1b1b2a0 100644 (file)
@@ -48,11 +48,19 @@ Roo.BLANK_IMAGE_URL =  "http://roojs.com/roojs1/images/gray/s.gif";
              dirname => [ array of classes..]
           
         */
+        
+        
             var dircls = { '' : [] };
+            
             data.forEach(function(cls) {
+                output += cls.alias + "\n";
+                if (!cls.is("CONSTRUCTOR") && !cls.is("OBJECT")) {
+                    return;
+                }
                 var dir = imports.File.File.dirname(cls.srcFile).replace(/\//,'.');
-                if (dir == cls.alias.substring(0,dir.length)) {
-                    // add it to the top level..
+                
+                var cdir = cls.alias.substring(0,dir.length);
+                if (dir != cdir || cls.alias == cdir) {
                     dircls[''].push(cls);
                     return;
                 }
@@ -67,38 +75,30 @@ Roo.BLANK_IMAGE_URL =  "http://roojs.com/roojs1/images/gray/s.gif";
                 dirs.shift();
                 dirs.push('');
             }
-     
-        !}
-        
-        
+            dirs.forEach(function(dir) { 
             
-       <for each="dir" in="dirs">
-       
+                if (dir.length) {
                 
-            {!
-            
-            if (dir.length) {
-            
-            !}<li>
-            <div roo:isc="no" roo:isns="yes">{+dir+}</div>
-            </li>{!
-            
-            }
-            var classes = dircls[dir].sort(makeSortby('name'));
-            
-            classes.forEach(function(cls) { 
-            !}
-                <li>
-                <div roo:isc="yes" roo:isns="no">{+
-                    (dir.length ? (dir + '.') : '') + cls.alias +}</div>
-                </li>
-            {!
-               });
-              
+                !}<li>
+                <div roo:isc="yes" roo:isns="yes">{+dir+}</div>
+                </li>{!
+                
+                }
+                var classes = dircls[dir].sort(makeSortby('name'));
+                
+                classes.forEach(function(cls) { 
+                
+                    !}<li>
+                    <div roo:isc="yes" roo:isns="no">{+
+                            (dir.length ? (dir + '.') : '') +
+                            cls.alias.substring(dir.length ? dir.length + 1 : 0)
+                        +}</div>
+                    </li> {!
+                });
+            });
             !}
                 
-            
-       </for>  
+             
        </ul>   
 </div>