sync
authorAlan Knowles <alan@roojs.com>
Mon, 26 Jun 2017 04:38:13 +0000 (12:38 +0800)
committerAlan Knowles <alan@roojs.com>
Mon, 26 Jun 2017 04:38:13 +0000 (12:38 +0800)
config1.builder
src/DocComment.vala [deleted file]
src/jsdoc/DocBuilder.vala
src/jsdoc/PackerRun.vala

index 03adafd..c478042 100644 (file)
@@ -45,4 +45,4 @@
             "json-glib-1.0"
         ]
     }
-]
\ No newline at end of file
+]
diff --git a/src/DocComment.vala b/src/DocComment.vala
deleted file mode 100644 (file)
index a029c5d..0000000
+++ /dev/null
@@ -1,232 +0,0 @@
-/**
- * Create a new DocComment. This takes a raw documentation comment,
- * and wraps it in useful accessors.
- * @class Represents a documentation comment object.
- * 
- */ 
-namespace JSDOC 
-       {
-       public class DocComment : Object
-       {
-
-               bool isUserComment  = true;
-               bool hasTags            = false;
-               string src          = "";
-               //string meta       =  "";
-               //Gee.ArrayList<string> tagTexts;
-               Gee.ArrayList<DocTag>    tags;
-       
-               GLib.Regex hastag_regex;
-               GLib.Regex tag_regex;
-               
-               static bool done_init = false;
-       
-               static void initRegex()
-               {
-                       if (DocComment.done_init) {
-                               return;
-                       }
-                       DocComment.hastag_regex = new GLib.Regex("^\s*@\s*\S+"); // multiline?
-                       DocComment.tag_regex = new GLib.Regex("(^|[\r\n])\s*@"); // empty line, then @ or starting with @?
-                       DocComment.done_init = true;
-               }
-        
-               public DocComment (string comment) 
-               {
-                   
-                   DocComment.initRegex();
-                    
-                   this.tags          = Gee.ArrayList<DocTag>();
-                       this.parse(comment);
-                   
-               
-                   /**
-                    * serialize..
-                    */
-                    /*
-                   toJSON :function(t)
-                   {
-                       
-                       var ret = { '*object' : 'DocComment' };
-                       
-                       var _this = this;
-                       ['isUserComment','src', 'meta',  'tags'].forEach(function(k) {
-                           ret[k] = _this[k];
-                       })
-                       
-                       return ret;
-                   }, 
-                   */   
-                   /**
-                   * @requires JSDOC.DocTag
-                   */
-                   void parse( string comment) {
-                       if (comment.strip() == "") {
-                           comment = "/** @desc */";
-                           this.isUserComment = false;
-                       }
-                       
-                       this.src = DocComment.unwrapComment(comment);
-                       
-                       //println(this.src);
-                       
-                       // looks like #+ support???
-                       /*
-                       this.meta = "";
-                       if (this.src.indexOf("#") == 0) {
-                           this.src.match(/#(.+[+-])([\s\S]*)$/);
-                           if (RegExp.$1) this.meta = RegExp.$1;
-                           if (RegExp.$2) this.src = RegExp.$2;
-                       }
-                       */
-                       
-
-                       if (!DocComment.hastag_regex.match(this.src)) {
-
-                           this.hasTags = false;
-                           
-                           //return;
-                       }
-                       this.fixDesc();
-                       
-                       //if (typeof JSDOC.PluginManager != "undefined") {
-                       //    JSDOC.PluginManager.run("onDocCommentSrc", this);
-                       //}
-                       
-                       this.src = DocComment.shared+"\n"+this.src;
-                               //var tagTexts      = new Gee.ArrayList<string>();
-                       GLib.MatchInfo mi;
-                       
-                       if (DocComment.tag_regex.match_all.match(this.src, 0, mi) {
-                                       while(mi.next()) {
-                                               var sa = mi.fetch(0);
-                                               if (sa.strip().length >0) {
-                                                       this.tags.add(new DocTag(sa));
-                                                       // tagTexts.add(sa); // ?? strip again?
-                                               }
-                                       }
-                               }
-                                               
-                       
-                   },
-                    
-
-                   /**
-                       If no @desc tag is provided, this function will add it.
-                    */
-                   fixDesc : function() {
-                       if (this.meta && this.meta != "@+") return;
-                       
-                       
-                       
-                       // does not have any @ lines..
-                       // -- skip comments without @!!
-                       if (!/^\s*@\s*\S+/.test(this.src)) {
-                           this.src = "@desc "+this.src;
-                           // TAGS that are not \n prefixed!! ...
-                           this.src = this.src.replace(/@\s*type/g, '\n@type'); 
-                       
-                           return;
-                       }
-                       // kdludge for stuff...
-                       //this.src = this.src.replace(/@\s*type/g, '\n@type'); 
-                       
-                       // only apply @desc fix to classes..
-                       if (!/\s*@(class|event|property)/m.test(this.src) ) {
-                           return;
-                       }
-                       // if no desc - add it on the first line that is not a @
-                       var lines = this.src.split("\n");
-                       var nsrc = '';
-                       var gotf = false;
-                       
-                       for(var i =0; i < lines.length;i++) {
-                           var line = lines[i];
-                           if (gotf) {
-                               nsrc += line + "\n";
-                               continue;
-                           }
-                           if (/^\s*[@\s]/.test(line)) { // line with @
-                               nsrc += line + "\n";
-                               continue;
-                           }
-                           gotf = true;
-                           nsrc += '@desc ' + line + "\n";
-                           
-                       }
-                        
-                       this.src = nsrc;
-                       
-                       
-                       
-                   },
-                 
-               /**
-                   Provides a printable version of the comment.
-                   @type String
-                */
-                   toString : function() {
-                       return this.src;
-                   },
-
-               /*~t
-                   assert("testing JSDOC.DocComment#fixDesc");
-                   var com = new JSDOC.DocComment();
-                   com.src = "foo";
-                   assertEqual(""+com, "foo", "stringifying a comment returns the unwrapped src.");
-               */
-
-               /**
-                   Given the title of a tag, returns all tags that have that title.
-                   @type JSDOC.DocTag[]
-                */
-                /*
-                
-                   toQDump : function(t)
-                   {
-                       //println(t.toSource());
-                       var r =  JSDOC.toQDump(t, 'JSDOC.DocComment.fromDump({', '})', {}); // send it an empty object..
-                       //println(r);
-                       return r;
-                   } ,
-                   */
-                
-                   getTag : function(/**String*/tagTitle) {
-                       return this.tags.filter(function($){return (typeof($['title']) != 'undefined') && ($.title == tagTitle)});
-                   }
-                   
-       });
-
-
-       /// static methods..
-
-       XObject.extend(DocComment, 
-               {
-                   
-                   /**
-                    * Used to store the currently shared tag text.
-                    */
-                   shared : "",
-                   
-                   /**
-                    * Remove slash-star comment wrapper from a raw comment string.
-                    *  @type String
-                    */
-                   unwrapComment : function(/**String*/comment) {
-                       if (!comment) return "";
-                       var unwrapped = comment.replace(/(^\/\*\*|\*\/$)/g, "").replace(/^\s*\* ?/gm, "");
-                       return unwrapped;
-                   },
-
-                   fromDump : function(t)
-                   {
-                       var ns = new DocComment();
-                       for (var i in t) {
-                           ns[i] = t[i];
-                       }
-                       return ns;
-                   }
-       });
\ No newline at end of file
index 4a7a851..23d9b14 100644 (file)
@@ -9,6 +9,8 @@ namespace JSDOC
                
 
                public string VERSION = "1.0.0";
+               // extractable via JSON?
+               public string VERSION = "1.0.0" ;
                
                
                private Packer packer;
@@ -168,6 +170,61 @@ namespace JSDOC
                    Parser.finish();
                }
                
+=======
+            //var txs =
+            
+            var tr = new  TokenReader(this.packer);
+                       tr.keepDocs = true;
+                       tr.keepWhite = true;
+                       tr.keepComments = true;
+                       tr.sepIdents = false;
+                       tr.collapseWhite = false;
+                       tr.filename = src;
+            
+
+            var toks = tr.tokenize( new TextStream(src));
+            if (PackerRun.opt_dump_tokens) {
+                               toks.dump();
+                               return "";
+                               //GLib.Process.exit(0);
+                       }
+            
+            
+            var ts = new TokenStream(toks);
+        
+        
+        
+                     
+            DocParser.parse(ts, srcFile);
+            
+            if (useCache) {
+                       
+                       var ar = DocParser.symbolsToObject(srcFile);
+                       
+                       var builder = new Json.Builder ();
+               builder.begin_array ();
+               for (var i=0;i<ar.size;i++) {
+               
+                                       builder.add_object_value (ar.get(i));
+                               }
+                               builder.end_array ();
+                               Json.Generator generator = new Json.Generator ();
+                               Json.Node root = builder.get_root ();
+                               generator.set_root (root);
+                               generator.pretty=  true;
+                               generator.ident = 2;
+                               generator.to_file(cacheFile);
+            
+             
+                
+    //         }
+        }
+        
+        
+        
+        Parser.finish();
+    }
+    
      
         
                void publish() 
index e1c5c8f..b56b663 100644 (file)
@@ -76,6 +76,10 @@ namespace JSDOC
                
                public static bool opt_clean_cache = true;      
                
+               // not actually an option yet..
+               
+               public static string opt_doc_ext = "html";
+               
                const OptionEntry[] options = {
                
                        { "jsfile", 'f', 0, OptionArg.FILENAME_ARRAY, ref opt_files ,"add a file to compile", null },