JSDOC/TokenReader.js
[gnome.introspection-doc-generator] / JSDOC / Parser.js
index d7c34ce..80ffd93 100644 (file)
@@ -1,9 +1,10 @@
 //<script type="text/javascript">
 
-Walker      = imports.Walker2.Walker2;
-Symbol      = imports.Symbol.Symbol;
-DocComment  = imports.DocComment.DocComment;
-Options = imports.BuildDocs.Options;
+const Walker2      = imports.Walker2.Walker2;
+const Symbol      = imports.Symbol.Symbol;
+const SymbolSet      = imports.SymbolSet.SymbolSet;
+const DocComment  = imports.DocComment.DocComment;
+const Options     = imports.Options.Options;
 /**
  * Parser is a static  instance..
  * 
@@ -11,7 +12,7 @@ Options = imports.BuildDocs.Options;
  */
  
  
-Parser = {
+const Parser = {
        conf: { 
         loaded: false 
     },
@@ -30,10 +31,10 @@ Parser = {
         if (this.conf.loaded) {
             return;
         }
-        print("init parser conf!?");
+        //print("init parser conf!?");
         this.conf = {
             loaded : true,
-            ignoreCode:                 Options.n,
+            //ignoreCode:                 Options.n,
             ignoreAnonymous:           true, // factory: true
             treatUnderscoredAsPrivate: true, // factory: true
             explain:                   false // factory: false
@@ -70,25 +71,36 @@ Parser = {
         
         this.filesSymbols[Symbol.srcFile] = new SymbolSet();
         
+        //Options.LOG.inform("Parser - run walker");
         this.walker = new  Walker2(ts);
-        this.walker.buildSymbolTree()
+        this.walker.buildSymbolTree();
+        
+        
+        
         //this.walker.walk(ts); // adds to our symbols
        // throw "done sym tree";
-        
+        //Options.LOG.inform("Parser - checking symbols");
         // filter symbols by option
         for (p in this.symbols._index) {
             var symbol = this.symbols.getSymbol(p);
             
+           // print(JSON.stringify(symbol, null,4));
+            
             if (!symbol) continue;
             
+            if (symbol.isPrivate) {
+                this.symbols.deleteSymbol(symbol.alias);
+                continue;
+            }
+            
             if (symbol.is("FILE") || symbol.is("GLOBAL")) {
                 continue;
             }
-            else if (!Options.a && !symbol.comment.isUserComment) {
+            //else if (!Options.a && !symbol.comment.isUserComment) {
                 //print("Deleting Symbols (no a / user comment): " + symbol.alias);
                 //this.symbols.deleteSymbol(symbol.alias);
                 //this.filesSymbols[Symbol.srcFile].deleteSymbol(symbol.alias);
-            }
+            //}
             
             if (/#$/.test(symbol.alias)) { // we don't document prototypes - this should not happen..
                 // rename the symbol ??
@@ -116,7 +128,7 @@ Parser = {
        
        addSymbol: function(symbol) 
     {
-         print("PARSER addSYMBOL : " + symbol.alias);
+        //print("PARSER addSYMBOL : " + symbol.alias);
         
                // if a symbol alias is documented more than once the last one with the user docs wins
                if (this.symbols.hasSymbol(symbol.alias)) {
@@ -181,9 +193,16 @@ Parser = {
                        }
                        print("-------------------\n");
                }
-       }
-    
-    
-    
+       },
+    /**
+     * return symbols so they can be serialized.
+     */
+    symbolsToObject : function(srcFile)
+    {
+        //this.filesSymbols[srcFile] is a symbolset..
+        return this.filesSymbols[srcFile];
+        
+            //    Parser.filesSymbols[srcFile]._index
+    }
 
 }
\ No newline at end of file