[introspection-doc-generator] Add links to gir files, and tidy up code



commit d0445ccc41e95f9e629049d07e0e667d9cbb2273
Author: Alan Knowles <alan akbkhome com>
Date:   Sat May 8 19:36:14 2010 +0800

    Add links to gir files, and tidy up code
    
    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

 File.js                       |   15 ++++++--
 JSDOC/Introspect.js           |   12 ++++++-
 JSDOC/Introspect/Base.js      |   11 +++++-
 JSDOC/Introspect/Basic.js     |    1 -
 JSDOC/Introspect/Callback.js  |    2 +-
 JSDOC/Introspect/Class.js     |    2 +-
 JSDOC/Introspect/Constant.js  |    2 +-
 JSDOC/Introspect/Enum.js      |    2 +-
 JSDOC/Introspect/Field.js     |    2 +-
 JSDOC/Introspect/Interface.js |    2 +-
 JSDOC/Introspect/Method.js    |    2 +-
 JSDOC/Introspect/Property.js  |    2 +-
 JSDOC/Introspect/Signal.js    |    2 +-
 JSDOC/Introspect/Struct.js    |    2 +-
 JSDOC/Introspect/Union.js     |    2 +-
 JSDOC/Template.js             |    4 +-
 JSDOC/Template/Link.js        |    7 ++--
 docs.js                       |   43 ++++++++++++++--------
 docs/class.html               |    7 +---
 docs/index.html               |   78 ++++++++++++++++++++--------------------
 20 files changed, 117 insertions(+), 83 deletions(-)
---
diff --git a/File.js b/File.js
index e788e59..29cff4a 100755
--- 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) {
diff --git a/JSDOC/Introspect.js b/JSDOC/Introspect.js
index 1e4a4ca..f85d174 100644
--- a/JSDOC/Introspect.js
+++ b/JSDOC/Introspect.js
@@ -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;
 
diff --git a/JSDOC/Introspect/Base.js b/JSDOC/Introspect/Base.js
index 39cfa76..8a2bd26 100644
--- a/JSDOC/Introspect/Base.js
+++ b/JSDOC/Introspect/Base.js
@@ -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, 
     {
diff --git a/JSDOC/Introspect/Basic.js b/JSDOC/Introspect/Basic.js
index 74b340d..43c723f 100644
--- a/JSDOC/Introspect/Basic.js
+++ b/JSDOC/Introspect/Basic.js
@@ -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;
 
 
diff --git a/JSDOC/Introspect/Callback.js b/JSDOC/Introspect/Callback.js
index 143cf3a..f92f466 100644
--- a/JSDOC/Introspect/Callback.js
+++ b/JSDOC/Introspect/Callback.js
@@ -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;
 
diff --git a/JSDOC/Introspect/Class.js b/JSDOC/Introspect/Class.js
index e134ba7..08a103b 100644
--- a/JSDOC/Introspect/Class.js
+++ b/JSDOC/Introspect/Class.js
@@ -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;
diff --git a/JSDOC/Introspect/Constant.js b/JSDOC/Introspect/Constant.js
index f9558b2..bc64386 100644
--- a/JSDOC/Introspect/Constant.js
+++ b/JSDOC/Introspect/Constant.js
@@ -7,7 +7,7 @@ xml     = imports.libxml;
 imports['Object.js'].load(Object);
 
 console = imports['console.js'].console;
-JSDOC   = imports['JSDOC.js'].JSDOC;
+
 
 
 
diff --git a/JSDOC/Introspect/Enum.js b/JSDOC/Introspect/Enum.js
index dcdf1a6..379b3ad 100644
--- a/JSDOC/Introspect/Enum.js
+++ b/JSDOC/Introspect/Enum.js
@@ -8,7 +8,7 @@ xml     = imports.libxml;
 imports['Object.js'].load(Object);
 
 console = imports['console.js'].console;
-JSDOC   = imports['JSDOC.js'].JSDOC;
+
 
 
 
diff --git a/JSDOC/Introspect/Field.js b/JSDOC/Introspect/Field.js
index ba22947..4eb915c 100644
--- a/JSDOC/Introspect/Field.js
+++ b/JSDOC/Introspect/Field.js
@@ -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;
diff --git a/JSDOC/Introspect/Interface.js b/JSDOC/Introspect/Interface.js
index 98727a9..1de6ca1 100644
--- a/JSDOC/Introspect/Interface.js
+++ b/JSDOC/Introspect/Interface.js
@@ -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;
diff --git a/JSDOC/Introspect/Method.js b/JSDOC/Introspect/Method.js
index 5c51d6c..b26a4fb 100644
--- a/JSDOC/Introspect/Method.js
+++ b/JSDOC/Introspect/Method.js
@@ -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;
diff --git a/JSDOC/Introspect/Property.js b/JSDOC/Introspect/Property.js
index e6e92e3..6630106 100644
--- a/JSDOC/Introspect/Property.js
+++ b/JSDOC/Introspect/Property.js
@@ -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;
diff --git a/JSDOC/Introspect/Signal.js b/JSDOC/Introspect/Signal.js
index 4d4b6b8..66b0994 100644
--- a/JSDOC/Introspect/Signal.js
+++ b/JSDOC/Introspect/Signal.js
@@ -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;
diff --git a/JSDOC/Introspect/Struct.js b/JSDOC/Introspect/Struct.js
index 02a4362..a705d0e 100644
--- a/JSDOC/Introspect/Struct.js
+++ b/JSDOC/Introspect/Struct.js
@@ -6,7 +6,7 @@ imports['Object.js'].load(Object);
 
 
 console = imports['console.js'].console;
-JSDOC   = imports['JSDOC.js'].JSDOC;
+
 
 
 
diff --git a/JSDOC/Introspect/Union.js b/JSDOC/Introspect/Union.js
index c178f87..b965512 100644
--- a/JSDOC/Introspect/Union.js
+++ b/JSDOC/Introspect/Union.js
@@ -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;
diff --git a/JSDOC/Template.js b/JSDOC/Template.js
index 944d318..4848199 100644
--- a/JSDOC/Template.js
+++ b/JSDOC/Template.js
@@ -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 , {
diff --git a/JSDOC/Template/Link.js b/JSDOC/Template/Link.js
index 4d45a5e..a550e49 100644
--- a/JSDOC/Template/Link.js
+++ b/JSDOC/Template/Link.js
@@ -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
--- 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");
diff --git a/docs/class.html b/docs/class.html
index 4d0f5e7..3b729a3 100644
--- a/docs/class.html
+++ b/docs/class.html
@@ -113,11 +113,8 @@
        </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>
diff --git a/docs/index.html b/docs/index.html
index b411cc1..0accbb3 100755
--- a/docs/index.html
+++ b/docs/index.html
@@ -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



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]