JSDOC/Template.js
[gnome.introspection-doc-generator] / JSDOC / Packer.js
index 30d19e7..d04e630 100644 (file)
@@ -70,6 +70,11 @@ Packer = function(cfg)
 {
     
     XObject.extend(this, cfg);
+    
+    if (this.srcfile) {
+        this.loadSourceFile();
+    }
+    
     if (!this.files) {
         throw "No Files";
     }
@@ -81,6 +86,11 @@ Packer = function(cfg)
  
 }
 Packer.prototype = {
+    /**
+     * @prop srcfiles {String} file containing a list of files/or classes to use.
+     */
+    srcfiles : false,
+    
     /**
      * @prop files {Array} list of files to compress (must be full path)
      */
@@ -114,6 +124,33 @@ Packer.prototype = {
     prefix : '',  
     out : '', // if no target is specified - then this will contain the result
     
+    
+    loadSourceFile : function()
+    {
+        var lines = File.read(this.srcfile).split("\n");
+        var _this = this;
+        lines.forEach(function(f) {
+            
+            if (/^\s*\//.test(f) || !/[a-z]+/i.test(f)) { // skip comments..
+                return;
+            }
+            if (/\.js$/.test(f)) {
+                _this.files.push( f);
+                // js file..
+                return;
+            }
+            
+            //println("ADD"+ f.replace(/\./g, '/'));
+            var add = f.replace(/\./g, '/').replace(/\s+/g,'')+'.js';
+            if (_this.files.indexOf(f) > -1) {
+                return;
+            }
+            _this.files.push( add );
+            
+        })
+    },
+    
+    
     packAll : function()  // do the packing (run from constructor)
     {
         
@@ -328,13 +365,13 @@ Packer.prototype = {
     writeTranslateFile : function(fn, minfile, toks) 
     {
         
-        var map = [];
+        var map = {};
         var _this = this;
         toks.forEach(function (t) {
             if (t.type == 'STRN' && t.name == 'DOUBLE_QUOTE') {
                 var sval = t.data.substring(1,t.data.length-1);
-                
-                map.push( sval);
+                var ffn = fn.substring(_this.prefix.length);
+                map[sval] = _this.md5(ffn + '-' + sval);
             }
         })