Add links to gir files, and tidy up code
authorAlan Knowles <alan@akbkhome.com>
Sat, 8 May 2010 11:36:14 +0000 (19:36 +0800)
committerAlan Knowles <alan@akbkhome.com>
Sat, 8 May 2010 11:36:14 +0000 (19:36 +0800)
More tidying up of codebase - remove JSDOC.js (not needed as we do not do nested trees.)
Add link to gir file, and copy into place - so that its easy to get hold of the gir used in the docs

20 files changed:
File.js
JSDOC/Introspect.js
JSDOC/Introspect/Base.js
JSDOC/Introspect/Basic.js
JSDOC/Introspect/Callback.js
JSDOC/Introspect/Class.js
JSDOC/Introspect/Constant.js
JSDOC/Introspect/Enum.js
JSDOC/Introspect/Field.js
JSDOC/Introspect/Interface.js
JSDOC/Introspect/Method.js
JSDOC/Introspect/Property.js
JSDOC/Introspect/Signal.js
JSDOC/Introspect/Struct.js
JSDOC/Introspect/Union.js
JSDOC/Template.js
JSDOC/Template/Link.js
docs.js
docs/class.html
docs/index.html

diff --git a/File.js b/File.js
index e788e59..29cff4a 100755 (executable)
--- a/File.js
+++ b/File.js
@@ -149,14 +149,23 @@ var File = {
         var dest = Gio.file_new_for_path(String(destPath));
         return dest.make_directory(null, null);
     },
-
-    copyFile : function (srcPath, destPath) {
+    /**
+     * copyFile
+     * @arg {String} src source path
+     * @arg {String} dest destination path
+     * @arg {Gio.FileCopyFlags} options (optional)  - use Gio.FileCopyFlags.OVERWRITE to .. overwrite..
+     * 
+     */
+    copyFile : function (srcPath, destPath, opts) {
+        if (typeof(opts) =='undefined') {
+            opts = Gio.FileCopyFlags.NONE
+        }
         var dest = Gio.file_new_for_path(String(destPath));
         var src = Gio.file_new_for_path(String(srcPath));
 
         // a bit of a hack for the fact that Gio.File.copy arguments
         // can be nulled, but not according to the GIR file
-        return src.copy(dest, Gio.FileCopyFlags.NONE);
+        return src.copy(dest, opts);
     },
 
     recursiveListing : function (dir) {
index 1e4a4ca..f85d174 100644 (file)
@@ -8,7 +8,7 @@ xml     = imports.libxml;
 imports['Object.js'].load(Object);
 
 console = imports['console.js'].console;
-JSDOC   = imports['JSDOC.js'].JSDOC;
+
 
 xnew    = imports['xnew.js'].xnew;
 
@@ -142,6 +142,16 @@ Object.extend(Introspect, {
                     continue;
             }
         }
+        
+                
+        var gi = GI.IRepository.get_default();
+        var ver = gi.get_version(ns);
+        var pth = GI.IRepository.get_search_path ();
+        var gir_path = pth[0].replace(/lib\/girepository-1.0/, 'share\/gir-1.0');
+       //console.log(fn);
+        ret.gir_file = gir_path + '/'+ ns + '-' + ver + '.gir';
+        ret.gir_filename = ns + '-' + ver + '.gir';
+        
         //console.dump(this.ifaceList);
         return ret;
 
index 39cfa76..8a2bd26 100644 (file)
@@ -8,7 +8,7 @@ xml     = imports.libxml;
 imports['Object.js'].load(Object);
 
 console = imports['console.js'].console;
-JSDOC   = imports['JSDOC.js'].JSDOC;
+
 Introspect = imports['JSDOC/Introspect.js'].Introspect;
 Basic = imports['JSDOC/Introspect/Basic.js'].Basic;
 
@@ -56,6 +56,15 @@ Base = Object.define(
          this.desc = Introspect.doc(this.alias );
         
         
+        var gi = GI.IRepository.get_default();
+        var ver = gi.get_version(ns);
+        var pth = GI.IRepository.get_search_path ();
+        var gir_path = pth[0].replace(/lib\/girepository-1.0/, 'share\/gir-1.0');
+       //console.log(fn);
+        this.gir_file = gir_path + '/'+ ns + '-' + ver + '.gir';
+        this.gir_filename = ns + '-' + ver + '.gir';
+        
+        
     }, 
     Basic, 
     {
index 74b340d..43c723f 100644 (file)
@@ -7,7 +7,6 @@ xml     = imports.libxml;
 imports['Object.js'].load(Object);
 
 console     = imports['console.js'].console;
-JSDOC       = imports['JSDOC.js'].JSDOC;
 Introspect = imports['JSDOC/Introspect.js'].Introspect;
 
 
index 143cf3a..f92f466 100644 (file)
@@ -7,7 +7,7 @@ xml     = imports.libxml;
 imports['Object.js'].load(Object);
 
 console = imports['console.js'].console;
-JSDOC   = imports['JSDOC.js'].JSDOC;
+
 Introspect = imports['JSDOC/Introspect.js'].Introspect;
 Basic = imports['JSDOC/Introspect/Basic.js'].Basic;
 
index e134ba7..08a103b 100644 (file)
@@ -7,7 +7,7 @@ xml     = imports.libxml;
 imports['Object.js'].load(Object);
 
 console = imports['console.js'].console;
-JSDOC   = imports['JSDOC.js'].JSDOC;
+
 
 
 Introspect = imports['JSDOC/Introspect.js'].Introspect;
index f9558b2..bc64386 100644 (file)
@@ -7,7 +7,7 @@ xml     = imports.libxml;
 imports['Object.js'].load(Object);
 
 console = imports['console.js'].console;
-JSDOC   = imports['JSDOC.js'].JSDOC;
+
 
 
 
index dcdf1a6..379b3ad 100644 (file)
@@ -8,7 +8,7 @@ xml     = imports.libxml;
 imports['Object.js'].load(Object);
 
 console = imports['console.js'].console;
-JSDOC   = imports['JSDOC.js'].JSDOC;
+
 
 
 
index ba22947..4eb915c 100644 (file)
@@ -7,7 +7,7 @@ xml     = imports.libxml;
 imports['Object.js'].load(Object);
 
 console = imports['console.js'].console;
-JSDOC   = imports['JSDOC.js'].JSDOC;
+
 
 
 Introspect = imports['JSDOC/Introspect.js'].Introspect;
index 98727a9..1de6ca1 100644 (file)
@@ -5,7 +5,7 @@
 imports['Object.js'].load(Object);
 
 console = imports['console.js'].console;
-JSDOC   = imports['JSDOC.js'].JSDOC;
+
  
 
 Introspect = imports['JSDOC/Introspect.js'].Introspect;
index 5c51d6c..b26a4fb 100644 (file)
@@ -6,7 +6,7 @@ GI      = imports.gi.GIRepository;
 imports['Object.js'].load(Object);
 
 console = imports['console.js'].console;
-JSDOC   = imports['JSDOC.js'].JSDOC;
+
 
 Introspect = imports['JSDOC/Introspect.js'].Introspect;
 Basic = imports['JSDOC/Introspect/Basic.js'].Basic;
index e6e92e3..6630106 100644 (file)
@@ -5,7 +5,7 @@ GI      = imports.gi.GIRepository;
 imports['Object.js'].load(Object);
 
 console = imports['console.js'].console;
-JSDOC   = imports['JSDOC.js'].JSDOC;
+
 
 
 Introspect = imports['JSDOC/Introspect.js'].Introspect;
index 4d4b6b8..66b0994 100644 (file)
@@ -7,7 +7,7 @@ GI      = imports.gi.GIRepository;
 imports['Object.js'].load(Object);
 
 console = imports['console.js'].console;
-JSDOC   = imports['JSDOC.js'].JSDOC;
+
 
 
 Introspect = imports['JSDOC/Introspect.js'].Introspect;
index 02a4362..a705d0e 100644 (file)
@@ -6,7 +6,7 @@ imports['Object.js'].load(Object);
 
 
 console = imports['console.js'].console;
-JSDOC   = imports['JSDOC.js'].JSDOC;
+
 
 
 
index c178f87..b965512 100644 (file)
@@ -6,7 +6,7 @@ imports['Object.js'].load(Object);
 
 
 console = imports['console.js'].console;
-JSDOC   = imports['JSDOC.js'].JSDOC;
 
 
 Introspect = imports['JSDOC/Introspect.js'].Introspect;
index 944d318..4848199 100644 (file)
@@ -6,7 +6,7 @@ GLib = imports.gi.GLib;
 imports['Object.js'].load(Object);
 
 
-JSDOC   = imports['JSDOC.js'].JSDOC;
+
 console = imports['console.js'].console;
 xnew    = imports['xnew.js'].xnew;
 Link    = imports['JSDOC/Template/Link.js'].Link;
@@ -27,7 +27,7 @@ Template = function(templateFile) {
        this.parse();
 }
 
-xnew.load(Template , 'JSDOC/Template');
+
 
 
 Object.extend(Template.prototype , {
index 4d45a5e..a550e49 100644 (file)
@@ -1,5 +1,4 @@
 //<script type="text/javascript">
-JSDOC   = imports['JSDOC.js'].JSDOC;
 
 console = imports['console.js'].console;
 
@@ -348,9 +347,9 @@ Object.extend(Link.prototype, {
         
         var link = {linkPath: linkPath, linkText: linkText, fullLinkPath: fullLinkPath};
         
-        if (typeof PluginManager != "undefined") {
-            JSDOC.PluginManager.run("onSymbolLink", link);
-        }
+        //if (typeof PluginManager != "undefined") {
+        //    JSDOC.PluginManager.run("onSymbolLink", link);
+        //}
         
         return "<a href=\""+link.fullLinkPath+"\""+target+">"+link.linkText+"</a>";
     },
diff --git a/docs.js b/docs.js
index cc82686..1d57200 100644 (file)
--- a/docs.js
+++ b/docs.js
@@ -3,13 +3,15 @@
 Gtk = imports.gi.Gtk;
 Gio = imports.gi.Gio;
 Gdk = imports.gi.Gdk;
+XObject = imports.XObject.XObject;
 
-imports['Object.js'].load(Object); 
 
-File        = imports['File.js'].File; 
-JSDOC       = imports['JSDOC.js'].JSDOC
-console     = imports['console.js'].console; 
+
+File        = imports.File.File
+console     = imports.console.console; 
 Introspect  = imports['JSDOC/Introspect.js'].Introspect; 
+Template    = imports['JSDOC/Template.js'].Template; 
+
 
 var outputdir = Seed.argv[2];
 
@@ -31,7 +33,7 @@ if (!File.isDirectory(outputdir)) {
 
 
 
-var ns_list = JSDOC.Introspect.namespaces();
+var ns_list = Introspect.namespaces();
 if (typeof(Seed.argv[3]) == 'string') {
     console.log(Seed.argv.length);
     ns_list = Seed.argv[3].split(',');
@@ -39,17 +41,26 @@ if (typeof(Seed.argv[3]) == 'string') {
  
 ns_list = ns_list.sort();
 
-var cls_template = new JSDOC.Template(__script_path__ + '/docs/class.html');
-var cls_ix_template = new JSDOC.Template(__script_path__ + '/docs/class_ix.html');
-var reference_template = new JSDOC.Template(__script_path__ + '/docs/references.html');
+var cls_template = new Template(__script_path__ + '/docs/class.html');
+var cls_ix_template = new Template(__script_path__ + '/docs/class_ix.html');
+var reference_template = new Template(__script_path__ + '/docs/references.html');
 var ns_idx = [];
-ns_list.map(function(ns_name) 
+ns_list.forEach(function(ns_name) 
 {
+    
+    //if (ns_idx.length) {         return ;/* do one - for testing */ } 
+    
     var  core = imports.gi[ns_name];
     var idx = { name: ns_name}; 
     console.log("START:" + ns_name);
    
     var ns = Introspect.ns(ns_name);
+    
+    if (File.exists(ns.gir_file)) {
+        File.copyFile(ns.gir_file, outputdir + '/'+ ns.gir_filename,Gio.FileCopyFlags.OVERWRITE);
+    }
+    
+    
     ns['left_bar'] = cls_ix_template.process(ns);
 
     Gio.simple_write(outputdir + '/'+ ns_name +  '.html', cls_template.process(ns));
@@ -69,10 +80,10 @@ ns_list.map(function(ns_name)
     for (var i in actions) {
         // we flag GLib as a GObject lib...
         idx[i]= ns_name == 'GLib' ? 1 : ns[i].length ;
-        ns[i].map( function(n) {
+        ns[i].forEach( function(n) {
             Gio.simple_write(outputdir + '/'+ ns_name + '.' + n + '.html', 
                 cls_template.process(
-                    Object.extend(
+                    XObject.extend(
                         Introspect.factory(actions[i], ns_name, n),
                         { 'left_bar' :ns['left_bar'] }
                     )
@@ -83,7 +94,7 @@ ns_list.map(function(ns_name)
         }); 
     }
     ns_idx.push(idx);
-      
+    
 });
 
 var refs = '';
@@ -115,10 +126,10 @@ for (var i in Introspect.references) {
     Gio.simple_write(html_file_path, html);
 
 }
-
-var ix_template = new JSDOC.Template(__script_path__ + '/docs/index.html');
+console.log("writing index");
+var ix_template = new Template(__script_path__ + '/docs/index.html');
 Gio.simple_write(outputdir + '/index.html', ix_template.process(ns_idx));
+console.log("coping images/css");
 File.silentRecursiveCopy(__script_path__ + '/docs/resources/', outputdir);
 
-
-
+console.log("done");
index 4d0f5e7..3b729a3 100644 (file)
        </tr>
 </if>
      <tr>
-            <td class="label">Note:</td>
-            <td class="hd-info"><b style="color:red">This documentation is generated from the HEAD of most 
-            libraries (and some experimental libs at times) - and may not be exactly the same as your
-            installed .gir files - you may want to download the generator and install on your machine 
-            to find out what you have.<b/></td>
+            <td class="label">GIR File:</td>
+            <td class="hd-info"><a href="{+data.gir_filename+}">{+data.gir_filename+}</a></td>
         </tr>
         <tr>
             <td class="label">C documentation:</td>
index b411cc1..0accbb3 100755 (executable)
@@ -1,52 +1,52 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
- <head>
-       <meta http-equiv="content-type" content="text/html; charset=utf-8" />
-  <title>Seed Documentation</title>
-  <link rel="stylesheet" type="text/css" href="default.css" />
-  <link rel="stylesheet" type="text/css" href="library_gnome.css"></link>
-  <link media="print" rel="stylesheet" type="text/css" href="library_gnome_print.css"></link>
- </head>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 
+ <head> 
+       <meta http-equiv="content-type" content="text/html; charset=utf-8" /> 
+  <title>Seed Documentation</title> 
+  <link rel="stylesheet" type="text/css" href="default.css" /> 
+  <link rel="stylesheet" type="text/css" href="library_gnome.css"></link> 
+  <link media="print" rel="stylesheet" type="text/css" href="library_gnome_print.css"></link> 
+ </head> 
  
- <body>
+ <body> 
      
-    <div id="page">
-
-        <div id="header">
-            <div id="header-wrap">
-                <h1>Un-official Seed Documentation</h1>
-            </div>
-        </div>
-        <div class="body-wrap">
+    <div id="page"> 
+        <div id="header"> 
+            <div id="header-wrap"> 
+                <h1>Un-official Seed Documentation</h1> 
+            </div> 
+        </div> 
+        <div class="body-wrap"> 
                 
-            <div class="ns-list">
-                <h2>GObject Libraries</h2>
-                <for each="thisClass" in="data">
+            <div class="ns-list"> 
+                <h2>GObject Libraries</h2> 
+                <for each="thisClass" in="data"> 
                     {!
                     if (!thisClass.objects) { continue; }
                     !}
-                    <div>
-                        <h2 class="classTitle">{+ (new Link().toSymbol(thisClass.name)) +}</h2>
-                    </div>
-                </for>
-            </div>
+                    <div> 
+                        <h2 class="classTitle">{+ (new Link().toSymbol(thisClass.name)) +}</h2> 
+                    </div> 
+                </for> 
+            </div> 
             
-            <div class="ns-list">
+            <div class="ns-list"> 
      
-                <h2>Non - GObject Libraries</h2>
-                <for each="thisClass" in="data">
+                <h2>Non - GObject Libraries</h2> 
+                <for each="thisClass" in="data"> 
                     {!
                     if (thisClass.objects) { continue; }
                     !}
-                    <div>
-                        <h2 class="classTitle">{+ (new Link().toSymbol(thisClass.name)) +}</h2>
-                    </div>
-                </for>
+                    <div> 
+                        <h2 class="classTitle">{+ (new Link().toSymbol(thisClass.name)) +}</h2> 
+                    </div> 
+                </for> 
             </div> 
      
-        </div>
-    </div>
-</body>
-</html>
-
-       
+        </div> 
+    </div> 
+</body> 
+</html> 
+       
\ No newline at end of file