sync with gnome
[gnome.introspection-doc-generator] / JSDOC / Packer.js
index 22a3757..b4a41fa 100644 (file)
@@ -10,7 +10,6 @@ CompressWhite   = imports.CompressWhite.CompressWhite;
 Collapse        = imports.Collapse.Collapse;
 
 GLib = imports.gi.GLib;
-Gio = imports.gi.Gio;
 /**
  * @namespace JSDOC
  * @class  Packer
@@ -86,10 +85,25 @@ Packer = function(cfg)
     
     var link = false;
     if (cfg.autoBuild) {
+        
+        function dateString(d){
+            function pad(n){return n<10 ? '0'+n : n}
+            return d.getFullYear() +
+                 pad(d.getMonth()+1)+
+                 pad(d.getDate())+'_'+
+                 pad(d.getHours())+
+                 pad(d.getMinutes())+
+                 pad(d.getSeconds());
+        }
+
+        
+        
         var version = 0;
         this.files.forEach(function(f) {
             version = Math.max(File.mtime(f), version);
         });
+        var version  = dateString(new Date(version));
+        
         var dirname = GLib.path_get_dirname(this.files[0]);
         var outname = this.module ? this.module : GLib.path_get_basename(dirname);
         this.target = dirname + '/compiled/' + outname + '-' + version + '.js';
@@ -112,33 +126,24 @@ Packer = function(cfg)
 }
 Packer.prototype = {
     /**
-     * @cfg {String} srcfiles file containing a list of files/or classes to use.
+     * @prop srcfiles {String} file containing a list of files/or classes to use.
      */
     srcfile : false,
     
     /**
-     * @cfg {Array} files list of files to compress (must be full path)
+     * @prop files {Array} list of files to compress (must be full path)
      */
     files : false,
     /**
-     * @cfg {String} target to write files to - must be full path.
+     * @prop target {String} target to write files to - must be full path.
      */
     target : '',
     /**
-     * @cfg {Boolean} autoBuild - turn on autobuild feature (puts files in compiled directory,
-     * and enables translation toolkit.
-     */
-    autoBuild : false,
-     /**
-     * @cfg {String} module used with autoBuild to force a file name
-     */
-    module: false,
-    /**
-     * @cfg {String} debugTargettarget to write files debug version to (uncompacted)- must be full path.
+     * @prop debugTarget {String} target to write files debug version to (uncompacted)- must be full path.
      */
     debugTarget : '', // merged file without compression.
     /**
-     * @cfg {String} tmpDir  (optional) where to put the temporary files. 
+     * @prop tmpDir {String} (optional) where to put the temporary files. 
      *      if you set this, then files will not be cleaned up
      */
     tmpDir : '/tmp',
@@ -146,29 +151,18 @@ Packer.prototype = {
     translateJSON : '', // json based list of strings in all files.
    
     /**
-     * @cfg {Boolean} cleanup  (optional) clean up temp files after done - 
+     * @prop cleanup {Boolean} (optional) clean up temp files after done - 
      *    Defaults to false if you set tmpDir, otherwise true.
      */
     cleanup : true,  
-    /**
-     * @cfg {Boolean} keepWhite (optional) do not remove white space in output.
-     *    usefull for debugging compressed files.
-     */
-    
-    keepWhite: true,
     
     /**
-     * @cfg {String} prefix (optional) prefix of directory to be stripped of when
+     * @prop prefix {String} (optional) prefix of directory to be stripped of when
      *    Calculating md5 of filename 
      */
     prefix : '',  
     out : '', // if no target is specified - then this will contain the result
     
-    /**
-     * load a dependancy list -f option
-     * @param {String} srcfile sourcefile to parse
-     * 
-     */
     
     loadSourceFile : function(srcfile)
     {
@@ -338,8 +332,6 @@ Packer.prototype = {
             }
             
         }
-        print("Output file: " + this.target);
-        if (this.debugTarget) print("Output debug file: " + this.debugTarget);
         
          
     
@@ -362,8 +354,7 @@ Packer.prototype = {
             keepWhite : true,  
             keepComments : true, 
             sepIdents : true,
-            collapseWhite : false,
-            filename : fn
+            collapseWhite : false
         });
         this.timerPrint("START" + fn);
         
@@ -397,9 +388,8 @@ Packer.prototype = {
         print(sp.warnings.join("\n"));
         
         
-        var out = CompressWhite(new TokenStream(toks), this, this.keepWhite); // do not kill whitespace..
-        
-        
+        //var out = CompressWhite(new TokenStream(toks), this, true); // do not kill whitespace..
+        var out = CompressWhite(new TokenStream(toks), this, false);
         this.timerPrint("Compressed");
         return out;
         
@@ -461,13 +451,10 @@ Packer.prototype = {
          
         File.write(transmd5, '');
         for(v in map) {
-            if (!v.length) {
-                continue;
-            }
-            File.append(transfile, l + "\n\t" + JSON.stringify(v) + " : " + JSON.stringify(v));
+            File.append(transfile, l + "\n\t \"" + v + '" : "' + v + '"');
             l = ',';
             // strings are raw... - as the where encoded to start with!!!
-            File.append(transmd5, '_T["' + this.md5(ffn + '-' + v) + '"]='+JSON.stringify(v)+";\n");
+            File.append(transmd5, '_T["' + this.md5(ffn + '-' + v) + '"]="'+v+"\";\n");
         }
         File.append(transfile, "\n},"); // always one trailing..