[introspection-doc-generator] generate gjs documentation, run under gjs
- From: Alan Knowles <alank src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [introspection-doc-generator] generate gjs documentation, run under gjs
- Date: Thu, 31 Mar 2011 05:28:59 +0000 (UTC)
commit 44e5eb8d418d148e64e0c29f3c44d081f66804d4
Author: Sylvain Duclos <sylvain_duclos yahoo com>
Date: Thu Mar 31 13:28:47 2011 +0800
generate gjs documentation, run under gjs
File.js | 81 ++++++++++-----
Introspect/Base.js | 20 ++--
Introspect/Basic.js | 31 +++---
Introspect/Callback.js | 17 ++--
Introspect/Class.js | 17 ++--
Introspect/Constant.js | 48 +++++----
Introspect/Enum.js | 17 ++--
Introspect/Field.js | 17 ++--
Introspect/Interface.js | 10 +-
Introspect/Link.js | 6 +-
Introspect/Method.js | 96 +++++++-----------
Introspect/NameSpace.js | 235 +++++++++++++++++++++---------------------
Introspect/Property.js | 16 +--
Introspect/Signal.js | 12 +-
Introspect/Struct.js | 14 +--
Introspect/Union.js | 10 +-
JSDOC/DocComment.js | 10 +-
JsTemplate/Template.js | 140 +++++++++++++-------------
String.js | 37 +++----
XObject.js | 103 +++++++++----------
console.js | 6 +-
docs.js | 209 ++++++++++++++++++++++---------------
templates/seed/class.html | 4 +-
templates/seed/class_ix.html | 2 +-
24 files changed, 605 insertions(+), 553 deletions(-)
---
diff --git a/File.js b/File.js
index 7cbed3d..c09d036 100755
--- a/File.js
+++ b/File.js
@@ -1,8 +1,10 @@
// <script type ="text/Javascript">
-GLib = imports.gi.GLib;
-Gio = imports.gi.Gio;
+const GLib = imports.gi.GLib;
+const Gio = imports.gi.Gio;
+
+//const String = imports.String.String;
+const console = imports.console.console;
-String = imports.String.String;
/**
* @namespace File
*
@@ -21,9 +23,8 @@ var File = {
SEPARATOR : '/',
- // fixme - this needs a bitter location..
+ // fixme - this needs a bitter location..
// they where in a string class before, but overriding String methods is not a good normally a good idea..
-
rtrim : function (s,toTrim) {
if (s.substr(s.length - toTrim.length) == toTrim) {
return s.slice(0, s.length - toTrim.length);
@@ -31,6 +32,7 @@ var File = {
return s;
},
+
trim : function (s,toTrim) {
var out = this.ltrim(s,toTrim);
out = this.rtrim(out,toTrim);
@@ -60,18 +62,28 @@ var File = {
}
return out;
},
+
read : function (path) {
var out = {};
- GLib.file_get_contents(path, out, null, null);
- return out['value'];
+ if (typeof(Seed) == 'undefined') {
+ var ret;
+ var err;
+ [ret, out, err] = GLib.file_get_contents(path, out, null, null);
+ return out;
+ } else {
+ GLib.file_get_contents(path, out, null);
+ return out['value'];
+ }
},
isFile : function (path) {
return GLib.file_test(path, GLib.FileTest.IS_REGULAR);
},
+
exists : function (path) {
return GLib.file_test(path, GLib.FileTest.EXISTS);
},
+
isDirectory : function (path) {
return GLib.file_test(path, GLib.FileTest.IS_DIR);
},
@@ -79,7 +91,8 @@ var File = {
list : function (path) {
var listing = [];
- var f = Gio.file_new_for_path(String(path));
+ //var f = Gio.file_new_for_path(String(path));
+ var f = Gio.file_new_for_path(path);
var file_enum = f.enumerate_children(Gio.FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME, Gio.FileQueryInfoFlags.NONE, null);
var next_file = null;
@@ -96,7 +109,8 @@ var File = {
},
mtime : function (path) {
- var f = Gio.file_new_for_path(String(path));
+ //var f = Gio.file_new_for_path(String(path));
+ var f = Gio.file_new_for_path(path);
var mtime = new GLib.TimeVal();
var info = f.query_info(Gio.FILE_ATTRIBUTE_TIME_MODIFIED, Gio.FileQueryInfoFlags.NONE, null);
@@ -106,7 +120,8 @@ var File = {
},
canonical : function (path) {
- var f = Gio.file_new_for_path(String(path));
+ //var f = Gio.file_new_for_path(String(path));
+ var f = Gio.file_new_for_path(path);
var can = f.resolve_relative_path('');
return can.get_path();
},
@@ -118,11 +133,13 @@ var File = {
*
*/
write : function (path, string) {
- var f = Gio.file_new_for_path(String(path));
+ //var f = Gio.file_new_for_path(String(path));
+ var f = Gio.file_new_for_path(path);
var data_out = new Gio.DataOutputStream({base_stream:f.replace(null, false, Gio.FileCreateFlags.NONE, null)});
data_out.put_string(string, null);
data_out.close(null);
},
+
/**
* append
* @arg path {String} File to write to
@@ -130,13 +147,15 @@ var File = {
*
*/
append : function (path, string) {
- var f = Gio.file_new_for_path(String(path));
+ //var f = Gio.file_new_for_path(String(path));
+ var f = Gio.file_new_for_path(path);
var data_out = new Gio.DataOutputStream({
base_stream:f.append_to(Gio.FileCreateFlags.NONE, null)
});
data_out.put_string(string, null);
data_out.close(null);
},
+
/**
* remove
* Delete a file.
@@ -146,9 +165,11 @@ var File = {
*/
remove : function (path)
{
- var f = Gio.file_new_for_path(String(path));
+ //var f = Gio.file_new_for_path(String(path));
+ var f = Gio.file_new_for_path(path);
return f['delete']();
},
+
/**
* silentRecursiveCopy
* copy files recursively from fromDir, silently ignore them if they already exist in toDir
@@ -160,45 +181,50 @@ var File = {
*
*/
silentRecursiveCopy : function (fromDir, toDir, opts) {
-
+
var filesToCopy = File.recursiveListing(fromDir);
var srcPath, destPath, src, dest;
if (typeof(opts) =='undefined') {
opts = Gio.FileCopyFlags.NONE;
}
-
+
for (var index in filesToCopy) {
- srcPath = File.join(String(fromDir), filesToCopy[index]);
- destPath = File.join(String(toDir), filesToCopy[index]);
+ //srcPath = File.join(String(fromDir), filesToCopy[index]);
+ //destPath = File.join(String(toDir), filesToCopy[index]);
+ srcPath = File.join(fromDir, filesToCopy[index]);
+ destPath = File.join(toDir, filesToCopy[index]);
if (File.isDirectory(srcPath) && !File.isDirectory(destPath)) {
File.mkdir(destPath);
continue;
}
+
// source is not file..?!?!?
if (!File.isFile(srcPath)) {
continue;
}
+
if (File.isFile(destPath) && opts == Gio.FileCopyFlags.NONE) {
// do not overwrite.. - if file exists and we are not flaged to overwrite.
continue;
}
-
+
File.copyFile(srcPath, destPath, opts);
-
}
},
-
+
/**
* mkdir
* make a directory..
* @arg {String} dstPath directory to make
*/
mkdir : function (destPath) {
- var dest = Gio.file_new_for_path(String(destPath));
-
+ //var dest = Gio.file_new_for_path(String(destPath));
+ var dest = Gio.file_new_for_path(destPath);
+
return dest.make_directory(null, null);
},
+
/**
* copyFile
* @arg {String} src source path
@@ -211,11 +237,18 @@ var File = {
opts = Gio.FileCopyFlags.NONE;
}
var dest = Gio.file_new_for_path(String(destPath));
- var src = Gio.file_new_for_path(String(srcPath));
+ //var dest = Gio.file_new_for_path(destPath);
+ var src = Gio.file_new_for_path(String(srcPath));
+ //var src = Gio.file_new_for_path(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, opts);
+ //return src.copy(dest, opts);
+ if (typeof(Seed) != 'undefined')
+ return src.copy(dest, opts, null);
+ else
+ return src.copy(dest, opts, null, null);
+
},
recursiveListing : function (dir) {
diff --git a/Introspect/Base.js b/Introspect/Base.js
index 916ebda..4a2460e 100644
--- a/Introspect/Base.js
+++ b/Introspect/Base.js
@@ -1,15 +1,16 @@
//<script type="text/javascript">
//Gtk = imports.gi.Gtk;
-GI = imports.gi.GIRepository;
-GLib = imports.gi.GLib;
-xml = imports.libxml;
+const GI = imports.gi.GIRepository;
+const GLib = imports.gi.GLib;
+//xml = imports.libxml;
+const xml = imports.gi.libxml2;
//GObject = imports.gi.GObject;
-XObject = imports.XObject.XObject;
-console = imports.console.console;
+const XObject = imports.XObject.XObject;
+const console = imports.console.console;
-NameSpace = imports.NameSpace.NameSpace;
-Basic = imports.Basic.Basic;
+const NameSpace = imports.Introspect.NameSpace.NameSpace;
+const Basic = imports.Introspect.Basic.Basic;
@@ -21,7 +22,7 @@ Basic = imports.Basic.Basic;
-Base = XObject.define(
+var Base = XObject.define(
function(ns, name) {
// fake should not happen?
@@ -105,7 +106,8 @@ Base = XObject.define(
var _this = this;
//console.log("ADD " + type[0].toUpperCase() + type.substring(1));
var clname = type[0].toUpperCase() + type.substring(1);
- var cls = imports[clname][clname];
+ //var cls = imports[clname][clname];
+ var cls = imports.Introspect[clname][clname];
if (!cls) {
console.log("COULD NOT FIND Introspect: " + type[0].toUpperCase() + type.substring(1));
}
diff --git a/Introspect/Basic.js b/Introspect/Basic.js
index 00cc18e..ccb0909 100644
--- a/Introspect/Basic.js
+++ b/Introspect/Basic.js
@@ -1,12 +1,13 @@
//<script type="text/javascript">
//Gtk = imports.gi.Gtk;
-GI = imports.gi.GIRepository;
-GLib = imports.gi.GLib;
-xml = imports.libxml;
+const GI = imports.gi.GIRepository;
+const GLib = imports.gi.GLib;
+//xml = imports.libxml;
+const xml = imports.gi.libxml2;
//GObject = imports.gi.GObject;
-XObject = imports.XObject.XObject;
-console = imports.console.console;
+const XObject = imports.XObject.XObject;
+const console = imports.console.console;
@@ -15,19 +16,21 @@ console = imports.console.console;
*/
-Basic = XObject.define(
+var Basic = XObject.define(
function( ) {
// never called?
},
+
Object,
+
{
-
typeToName : function (type_info) {
var ty = GI.type_tag_to_string( GI.type_info_get_tag(type_info));
if ((ty == 'void') && GI.type_info_is_pointer(type_info)) {
return 'void*'; // it's a fake string?!?!!? - slightly naughty...
}
+
if (ty == 'array') {
// array of what!?!?
var param_type = GI.type_info_get_param_type (type_info, 0);
@@ -36,33 +39,31 @@ Basic = XObject.define(
return 'utf8';
}
-
return ty;
}
+
if (ty != 'interface') {
return ty;
}
+
var interface_info = GI.type_info_get_interface (type_info);
var interface_type = GI.base_info_get_type (interface_info);
if (interface_type == GI.InfoType.CALLBACK) {
// callback..
- var Callback = imports.Callback.Callback ;
+ var Callback = imports.Introspect.Callback.Callback ;
var ret= new Callback(interface_info, this, false, false);
ret.alias = interface_info.get_namespace() + '.' + interface_info.get_name();
+
return ret;
-
-
}
return interface_info.get_namespace() + '.' + interface_info.get_name();
-
},
-
+
directions : [ "in", "out"," inout"],
-
+
argsToArrays : function(m, returnArray)
{
-
var outIntoReturn = false;
if (returnArray && returnArray.length == 1 && returnArray[0].type == 'void') {
outIntoReturn = true;
diff --git a/Introspect/Callback.js b/Introspect/Callback.js
index 021b4d3..0c1d6e5 100644
--- a/Introspect/Callback.js
+++ b/Introspect/Callback.js
@@ -1,20 +1,21 @@
//<script type="text/javascript">
//Gtk = imports.gi.Gtk;
-GI = imports.gi.GIRepository;
-GLib = imports.gi.GLib;
-xml = imports.libxml;
+const GI = imports.gi.GIRepository;
+const GLib = imports.gi.GLib;
+//xml = imports.libxml;
+const xml = imports.gi.libxml2;
//GObject = imports.gi.GObject;
-XObject = imports.XObject.XObject;
-console = imports.console.console;
+const XObject = imports.XObject.XObject;
+const console = imports.console.console;
-NameSpace = imports.NameSpace.NameSpace;
-Basic = imports.Basic.Basic;
+const NameSpace = imports.Introspect.NameSpace.NameSpace;
+const Basic = imports.Introspect.Basic.Basic;
-Callback = XObject.define(
+var Callback = XObject.define(
function(sig, memberOf, saveto, keylist) {
diff --git a/Introspect/Class.js b/Introspect/Class.js
index 90348ec..0e389ab 100644
--- a/Introspect/Class.js
+++ b/Introspect/Class.js
@@ -1,16 +1,17 @@
//<script type="text/javascript">
//Gtk = imports.gi.Gtk;
-GI = imports.gi.GIRepository;
-GLib = imports.gi.GLib;
-xml = imports.libxml;
+const GI = imports.gi.GIRepository;
+const GLib = imports.gi.GLib;
+//xml = imports.libxml;
+const xml = imports.gi.libxml2;
//GObject = imports.gi.GObject;
-XObject = imports.XObject.XObject;
-console = imports.console.console;
-NameSpace = imports.NameSpace.NameSpace;
+const XObject = imports.XObject.XObject;
+const console = imports.console.console;
-Base = imports.Base.Base;
+const NameSpace = imports.Introspect.NameSpace.NameSpace;
+const Base = imports.Introspect.Base.Base;
@@ -22,7 +23,7 @@ Base = imports.Base.Base;
-Class = XObject.define(
+var Class = XObject.define(
function(ns, name) {
Base.call(this, ns, name);
print("Class ctr - parent called");
diff --git a/Introspect/Constant.js b/Introspect/Constant.js
index 4021197..9992ffb 100644
--- a/Introspect/Constant.js
+++ b/Introspect/Constant.js
@@ -1,15 +1,16 @@
//<script type="text/javascript">
//Gtk = imports.gi.Gtk;
-GI = imports.gi.GIRepository;
-GLib = imports.gi.GLib;
-xml = imports.libxml;
+const GI = imports.gi.GIRepository;
+const GLib = imports.gi.GLib;
+//const xml = imports.libxml;
+const xml = imports.gi.libxml2;
-XObject = imports.XObject.XObject;
-console = imports.console.console;
-NameSpace = imports.NameSpace.NameSpace;
+const XObject = imports.XObject.XObject;
+const console = imports.console.console;
-Basic = imports.Basic.Basic;
+const NameSpace = imports.Introspect.NameSpace.NameSpace;
+const Basic = imports.Introspect.Basic.Basic;
@@ -19,36 +20,39 @@ Basic = imports.Basic.Basic;
*/
-Constant = XObject.define(
+var Constant = XObject.define(
function(prop, memberOf, saveto, keylist) {
-
- this.name = prop.get_name();
+
+ this.name = prop.get_name();
var tif = GI.constant_info_get_type(prop);
- var ty = GI.type_tag_to_string( GI.type_info_get_tag(tif));
+ var ty = GI.type_tag_to_string( GI.type_info_get_tag(tif));
this.type = this.typeToName(GI.constant_info_get_type(prop));
-
+
///this.flags = GI.property_info_get_flags(prop),
-
-
+
this.value= 'UNKNOWN';
-
-
+
+ /* gjs constant_info_get_value introspectable="0"
if (ty != 'interface') {
-
- var argm = new GI.Argument();
- GI.constant_info_get_value ( prop ,argm);
+ //var argm = new GI.Argument();
+ //var argm = new GI._Argument();
+ var argm;
+ GI.constant_info_get_value(prop, argm);
if (ty != 'utf8') {
this.value = argm.v_long;
} else {
this.value = argm.v_string;
}
}
-
+ */
+
this.desc = NameSpace.doc(memberOf.alias + '.' + this.name)
-
+
memberOf[saveto].push(this);
keylist.push(this.name);
},
+
Basic,
- { }
+
+ {}
);
diff --git a/Introspect/Enum.js b/Introspect/Enum.js
index aaae157..8c21355 100644
--- a/Introspect/Enum.js
+++ b/Introspect/Enum.js
@@ -1,16 +1,17 @@
//<script type="text/javascript">
//Gtk = imports.gi.Gtk;
-GI = imports.gi.GIRepository;
-GLib = imports.gi.GLib;
-xml = imports.libxml;
+const GI = imports.gi.GIRepository;
+const GLib = imports.gi.GLib;
+//xml = imports.libxml;
+const xml = imports.gi.libxml2;
-XObject = imports.XObject.XObject;
-console = imports.console.console;
-NameSpace = imports.NameSpace.NameSpace;
+const XObject = imports.XObject.XObject;
+const console = imports.console.console;
-Base = imports.Base.Base;
+const NameSpace = imports.Introspect.NameSpace.NameSpace;
+const Base = imports.Introspect.Base.Base;
@@ -18,7 +19,7 @@ Base = imports.Base.Base;
-Enum = XObject.define(
+var Enum = XObject.define(
function(ns, name) {
Base.call(this, ns, name);
},
diff --git a/Introspect/Field.js b/Introspect/Field.js
index f2e24f8..8206b7b 100644
--- a/Introspect/Field.js
+++ b/Introspect/Field.js
@@ -1,16 +1,17 @@
//<script type="text/javascript">
//Gtk = imports.gi.Gtk;
-GI = imports.gi.GIRepository;
-GLib = imports.gi.GLib;
-xml = imports.libxml;
+const GI = imports.gi.GIRepository;
+const GLib = imports.gi.GLib;
+//xml = imports.libxml;
+const xml = imports.gi.libxml2;
-XObject = imports.XObject.XObject;
-console = imports.console.console;
-NameSpace = imports.NameSpace.NameSpace;
+const XObject = imports.XObject.XObject;
+const console = imports.console.console;
-Basic = imports.Basic.Basic;
+const NameSpace = imports.Introspect.NameSpace.NameSpace;
+const Basic = imports.Introspect.Basic.Basic;
@@ -19,7 +20,7 @@ Basic = imports.Basic.Basic;
* Field
*/
-Field = XObject.define(
+var Field = XObject.define(
function(prop, memberOf, saveto, keylist) {
this.name = prop.get_name() ;
diff --git a/Introspect/Interface.js b/Introspect/Interface.js
index a83a5ac..0df776c 100644
--- a/Introspect/Interface.js
+++ b/Introspect/Interface.js
@@ -1,11 +1,11 @@
//<script type="text/javascript">
//Gtk = imports.gi.Gtk;
-XObject = imports.XObject.XObject;
-console = imports.console.console;
-NameSpace = imports.NameSpace.NameSpace;
+const XObject = imports.XObject.XObject;
+const console = imports.console.console;
-Base = imports.Base.Base;
+const NameSpace = imports.Introspect.NameSpace.NameSpace;
+const Base = imports.Introspect.Base.Base;
@@ -14,7 +14,7 @@ Base = imports.Base.Base;
* Interface
*/
-Interface = XObject.define(
+var Interface = XObject.define(
function(ns, name) {
Base.call(this, ns, name);
diff --git a/Introspect/Link.js b/Introspect/Link.js
index fb7d5a1..104f5cc 100644
--- a/Introspect/Link.js
+++ b/Introspect/Link.js
@@ -1,8 +1,8 @@
//<script type="text/javascript">
-console = imports.console.console;
+const console = imports.console.console;
-XObject = imports.XObject.XObject
+const XObject = imports.XObject.XObject
/** Handle the creation of HTML links to documented symbols.
@@ -13,7 +13,7 @@ XObject = imports.XObject.XObject
*/
-Link = XObject.define(
+var Link = XObject.define(
function() {
this.alias = "";
this.src = "";
diff --git a/Introspect/Method.js b/Introspect/Method.js
index 0b1ad48..7d1caa1 100644
--- a/Introspect/Method.js
+++ b/Introspect/Method.js
@@ -1,13 +1,12 @@
//<script type="text/javascript">
+const GI = imports.gi.GIRepository;
-GI = imports.gi.GIRepository;
+const XObject = imports.XObject.XObject;
+const console = imports.console.console;
-XObject = imports.XObject.XObject;
-console = imports.console.console;
-NameSpace = imports.NameSpace.NameSpace;
-
-Basic = imports.Basic.Basic;
+const NameSpace = imports.Introspect.NameSpace.NameSpace;
+const Basic = imports.Introspect.Basic.Basic;
/**
@@ -17,7 +16,7 @@ Basic = imports.Basic.Basic;
-Method = XObject.define(
+var Method = XObject.define(
function(m, memberOf, saveto, keylist) {
this.propertyType = 'Method';
@@ -28,40 +27,31 @@ Method = XObject.define(
if (n.match(/_(ref|unref)$/) || n.match(/^(ref|unref|weakref|weakunref)$/)) {
return false; // skip these!
}
-
- if (n == 'new') {
+
+ if(n == 'new') {
n = 'c_new';
}
-
var retval = [ {
name : 0,
type : this.typeToName(GI.callable_info_get_return_type(m)),
desc : NameSpace.doc(memberOf.alias + '.' + n_original + '.return-value')
} ];
-
-
-
+
var args = this.argsToArrays(m, retval);
-
-
+
if ((n == 'c_new') && !args.length && memberOf.constructors.length) {
-
+
memberOf.constructors[0].doc = NameSpace.doc(memberOf.alias + '.' + n_original);
-
+
return false; // skip.
}
-
-
-
-
//console.log(GI.base_info_get_name(m));
- // console.dump(GI.base_info_get_attribute(m, 'doc') );
-
- // this is a bit messy, as we probably loose the doc's on new..
-
-
+ // console.dump(GI.base_info_get_attribute(m, 'doc') );
+
+ // this is a bit messy, as we probably loose the doc's on new..
+
XObject.extend(this, {
name : n,
params: args,
@@ -74,46 +64,38 @@ Method = XObject.define(
});
// add descriptions to the arguments..
this.params.map(function(p) {
-
-
p.desc = NameSpace.doc(memberOf.alias + '.' + n_original + '.' + p.name);
//Seed.print(memberOf.alias + '.' + n_original + '.' + p.name + ':' + p.desc);
-
});
-
-
- // collect references...
+
+ // collect references...
var addedto = [ memberOf.alias ]; // do not add to self...
-
- for(var i =0; i < args.length;i++) {
+
+ for(var i =0; i < args.length;i++) {
var ty = args[i].type;
if (typeof(ty) != 'string' || ty.indexOf('.') < 0) {
continue;
}
+
if (addedto.indexOf(ty) > -1) {
continue;
}
-
-
-
NameSpace.references[ty] = NameSpace.references[ty] || [];
NameSpace.references[ty].push(this);
addedto.push(ty);
}
-
-
- // decide what to add to...
-
+
+ // decide what to add to...
if (this.isConstructor) {
-
if (this.name.match(/^new_/)) {
this.name = this.name.substring(4);
}
-
-
memberOf.constructors.push(this);
- return;
+
+ //return;
+ return true;
}
+
// return values = only applicable to non-constructors..
for(var i =0; i < retval.length;i++) {
var ty = retval[i].type;
@@ -123,28 +105,24 @@ Method = XObject.define(
if (addedto.indexOf(ty) > -1) {
continue;
}
-
-
-
NameSpace.references[ty] = NameSpace.references[ty] || [];
NameSpace.references[ty].push(this);
addedto.push(ty);
}
-
-
+
if (this.isStatic) {
-
memberOf.functions.push(this);
- return;
+ //return;
+ return true;
}
-
-
+
memberOf.methods.push(this);
keylist.push(this.name);
-
-
-
+
+ return true;
},
- Basic,
- { }
+
+ Basic,
+
+ {}
);
\ No newline at end of file
diff --git a/Introspect/NameSpace.js b/Introspect/NameSpace.js
index 44a387d..c14c5b1 100644
--- a/Introspect/NameSpace.js
+++ b/Introspect/NameSpace.js
@@ -1,163 +1,179 @@
//<script type="text/javascript">
//Gtk = imports.gi.Gtk;
-GI = imports.gi.GIRepository;
-GLib = imports.gi.GLib;
-xml = imports.libxml;
-File = imports.File.File;
-XObject = imports.XObject.XObject;
+const GI = imports.gi.GIRepository;
+const GLib = imports.gi.GLib;
+//const xml = imports.libxml;
+const xml = imports.gi.libxml2;
-console = imports.console.console;
+const File = imports.File.File;
+const XObject = imports.XObject.XObject;
+const console = imports.console.console;
+//const Constant = imports.Constant;
// BC/FC
if (!GI.Repository) {
- GI.Repository = GI.IRepository;
- GI.FunctionInfoFlags = GI.IFunctionInfoFlags ;
- GI.InfoType = GI.IInfoType;
- GI.TypeTag= GI.ITypeTag;
-
+ GI.Repository = GI.IRepository;
+ GI.FunctionInfoFlags = GI.IFunctionInfoFlags;
+ GI.InfoType = GI.IInfoType;
+ GI.TypeTag = GI.ITypeTag;
+
GI.IBaseInfo.prototype.get_name = function(n) {
return GI.base_info_get_name(this, n);
}
- GI.IBaseInfo.prototype.get_namespace = function(n) {
+
+ GI.IBaseInfo.prototype.get_namespace = function(n) {
return GI.base_info_get_namespace(this, n);
}
+
GI.IBaseInfo.prototype.get_attribute = function( n) {
return GI.base_info_get_attribute(this, n);
}
}
+//NameSpace = {
+var NameSpace = {
+ references : {},
-NameSpace = {
-
- references : { },
-
- namespaces : function(ns)
- {
+ namespaces : function(ns) {
// this should be a class of it's own...
this.references[ns] = []; // technically not needed - but fills in files..
// get this from GI... (it's the path..)
var ret = [];
-
+
function scanGir(dir)
{
if (!GLib.file_test(dir, GLib.FileTest.EXISTS)) {
return;
}
- File.list(dir).forEach(function(fn)
+
+ File.list(dir).forEach(function(fn)
{
if (!fn.match(/\.typelib$/)) {
return;
}
+
var par = fn.split('-').shift();
//console.log('trying ' + par);
+
if (ret.indexOf(par) > -1) {
return;
}
ret.push(par);
});
}
-
- var gi = GI.Repository.get_default();
+
+ var gi = GI.Repository.get_default();
var pth = GI.Repository.get_search_path();
-
+
scanGir(pth[0]);
ret.sort();
console.dump(ret);
+
return ret;
-
},
-
-
+
ns: function(ns) {
- var gi = GI.Repository.get_default();
- ret = {
- titleType: 'Namespace',
- ns: ns,
- name : ns,
- alias : ns,
- objects : [],
+ var gi = GI.Repository.get_default();
+ var ret = {
+ titleType : 'Namespace',
+ ns : ns,
+ name : ns,
+ alias : ns,
+ objects : [],
functions : [],
- enums : [],
- structs: [],
+ enums : [],
+ structs : [],
constants : [],
- unions : [],
-
+ unions : [],
+
// so ns looks like class..
-
+
extendsClasses : [], // what it extends...
- childClasses : [], // what uses it..
- properties : [],
- constructors : [],
- methods : [],
- values : [], /// really constants.
- signals : [],
- interfaces: [],
+ childClasses : [], // what uses it..
+ properties : [],
+ constructors : [],
+ methods : [],
+ values : [], /// really constants.
+ signals : [],
+ interfaces : [],
};
-
- for (var i=0; i < gi.get_n_infos (ns); i++ ) {
+
+ //console.log("NS: " + ns);
+ var n_info = gi.get_n_infos(ns);
+ //console.log("n_info: " + n_info);
+
+ for (var i=0; i<n_info; i++) {
+
var info = gi.get_info (ns, i);
- // print("NAME: " + info.get_name());
+ //console.log("NAME: " + info.get_name());
//continue;
+
var info_type = GI.base_info_get_type (info);
- // print("Type: " + info_type);
+ // print("Type: " + info_type);
+
switch(info_type) {
case GI.InfoType.OBJECT:
ret.objects.push(info.get_name());
this.clsGatherInterfaces(ns , info.get_name());
continue;
- case GI.InfoType.INTERFACE:
+
+ case GI.InfoType.INTERFACE:
ret.interfaces.push(info.get_name());
continue;
+
case GI.InfoType.FUNCTION:
- new imports.Method.Method(info, ret, 'functions', []);
+ new imports.Introspect.Method.Method(info, ret, 'functions', []);
continue;
-
+
case GI.InfoType.CALLBACK:
// new Introspect.Callback(info, ret, 'callbacks', []);
continue;
-
+
case GI.InfoType.ENUM:
case GI.InfoType.FLAGS:
ret.enums.push(info.get_name());
continue;
+
case GI.InfoType.STRUCT:
- if (GI.struct_info_is_gtype_struct (info)) {
+ if (GI.struct_info_is_gtype_struct(info)) {
continue;
}
-
ret.structs.push(info.get_name());
continue;
+
case GI.InfoType.UNION:
ret.unions.push(info.get_name());
continue;
+
case GI.InfoType.CONSTANT:
- new imports.Constant.Constant(info, ret, 'values', []);
-
+ new imports.Introspect.Constant.Constant(info, ret, 'values', []);
continue;
-
-
+
+
default:
continue;
}
}
//print ("SCAN NAMESPACES ALL DONE");
-
- var gi = GI.Repository.get_default();
- var ver = gi.get_version(ns);
- var pth = GI.Repository.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';
+
+ //var gi = GI.Repository.get_default();
+ var ver = gi.get_version(ns);
+ var pth = GI.Repository.get_search_path ();
+
+ // SD replace lib with lib.?.? (match lib64 or lib)
+ //var gir_path = pth[0].replace(/lib\/girepository-1.0/, 'share\/gir-1.0');
+ var gir_path = pth[0].replace(/lib.?.?\/girepository-1.0/, 'share\/gir-1.0');
+ //console.log("gir_path: " + gir_path);
+
+ ret.gir_file = gir_path + '/'+ ns + '-' + ver + '.gir';
ret.gir_filename = ns + '-' + ver + '.gir';
-
+
//console.dump(this.ifaceList);
- return ret;
+ return ret;
},
-
-
// store all the interfaces, so we can show a list of them later...
// called when you list the namespace
@@ -168,47 +184,37 @@ NameSpace = {
var bb = gi.find_by_name(ns, cls);
var fullname = ns+'.'+cls;
this.ifaceList = this.ifaceList || { };
-
-
+
for(var i =0; i < GI.object_info_get_n_interfaces(bb); i++) {
-
+
var prop = GI.object_info_get_interface(bb,i);
-
- var add = prop.get_namespace() +'.' + prop.get_name();
+
+ var add = prop.get_namespace() + '.' + prop.get_name();
this.ifaceList[add] = this.ifaceList[add] || [];
if (this.ifaceList[add].indexOf(fullname) < 0) {
this.ifaceList[add].push(fullname);
}
-
}
-
-
-
},
-
-
-
-
+
doc : function(what) {
//print ("DOC: + " +what);
var ns = what.split('.').shift();
return '';
this.commentLoad(ns);
+
return typeof(this.comments[ns][what]) == 'undefined' ? '' : this.comments[ns][what];
-
},
-
-
-
+
comments : {},
-
+
commentLoad : function(ns)
{
-
+
if (typeof(this.comments[ns]) != 'undefined') {
return;
}
-
+
console.log("LOAD DOCS: " + ns);
var gi = GI.Repository.get_default();
var ver = gi.get_version(ns);
@@ -216,8 +222,8 @@ NameSpace = {
this.comments[ns] = {};
return;
}
- var ret = { };
-
+ var ret = {};
+
// no idea why this is broken on my build system.
var getAttribute = function(n, name){
var properties = n.properties;
@@ -228,35 +234,34 @@ NameSpace = {
}
return null;
}
-
-
+
function walk (element, path) {
-
-
+
if (!element) {
return;
}
-
+
var n = getAttribute(element, 'name') ;
//console.log("WALK" + n);
if (element.name == 'signal') {
path += '.signal';
}
-
+
if (n) {
path += path.length ? '.' : '';
path += n;
}
+
if (element.name == 'return-value') {
path += '.return-value';
}
-
+
var d = getAttribute(element,'doc');
if (d) {
// Seed.print(path + ':' + d);
ret[path] = d;
}
-
+
var child = element.children;
while (child){
@@ -267,41 +272,39 @@ NameSpace = {
child = child.next;
}
}
-
+
var pth = GI.Repository.get_search_path ();
-
-
+
var gir_path = pth[0].replace(/lib\/girepository-1.0/, 'share\/gir-1.0');
-
-
+
//console.log(fn);
var fn = gir_path + '/'+ ns + '-' + ver + '.gir';
- // console.log(fn);
-
+ // console.log(fn);
+
if (!GLib.file_test(fn, GLib.FileTest.EXISTS)) {
console.log('missing docc file ' + fn);
this.comments[ns] = {};
-
+
return;
}
+
var doc = xml.parseFile(fn);
//console.log("xmldoc?" + doc);
walk (doc.root, '');
//console.dump(ret);
this.comments[ns] = ret;
-
},
- registry : { },
+
+ registry : {},
+
factory : function(type, ns, name) {
if (typeof (this.registry[ns +'.' + name]) == 'undefined') {
- this.registry[ns +'.' + name] = new imports[type][type](ns,name);
+ //this.registry[ns +'.' + name] = new imports[type][type](ns,name);
+ this.registry[ns +'.' + name] = new imports.Introspect[type][type](ns,name);
this.registry[ns +'.' + name].load();
}
-
+
return this.registry[ns +'.' + name];
}
-
};
-
-
-
+//})();
diff --git a/Introspect/Property.js b/Introspect/Property.js
index 7997796..fb0a9be 100644
--- a/Introspect/Property.js
+++ b/Introspect/Property.js
@@ -1,23 +1,19 @@
//<script type="text/javascript">
//Gtk = imports.gi.Gtk;
-GI = imports.gi.GIRepository;
+const GI = imports.gi.GIRepository;
+const XObject = imports.XObject.XObject;
+const console = imports.console.console;
-
-XObject = imports.XObject.XObject;
-console = imports.console.console;
-NameSpace = imports.NameSpace.NameSpace;
-
-Basic = imports.Basic.Basic;
-
-
+const NameSpace = imports.Introspect.NameSpace.NameSpace;
+const Basic = imports.Introspect.Basic.Basic;
/**
* Property
*/
-Property = XObject.define(
+var Property = XObject.define(
function(prop, memberOf, saveto, keylist) {
this.propertyType = 'Property';
var n_original = prop.get_name();
diff --git a/Introspect/Signal.js b/Introspect/Signal.js
index 0c1a9d5..0624ebf 100644
--- a/Introspect/Signal.js
+++ b/Introspect/Signal.js
@@ -1,17 +1,17 @@
//<script type="text/javascript">
//Gtk = imports.gi.Gtk;
-GI = imports.gi.GIRepository;
+const GI = imports.gi.GIRepository;
-XObject = imports.XObject.XObject;
-console = imports.console.console;
-NameSpace = imports.NameSpace.NameSpace;
+const XObject = imports.XObject.XObject;
+const console = imports.console.console;
-Basic = imports.Basic.Basic;
+const NameSpace = imports.Introspect.NameSpace.NameSpace;
+const Basic = imports.Introspect.Basic.Basic;
-Signal = XObject.define(
+var Signal = XObject.define(
function(sig, memberOf, saveto, keylist) {
this.propertyType = 'Signal';
diff --git a/Introspect/Struct.js b/Introspect/Struct.js
index a3a72dc..d2ae597 100644
--- a/Introspect/Struct.js
+++ b/Introspect/Struct.js
@@ -1,14 +1,12 @@
//<script type="text/javascript">
-GI = imports.gi.GIRepository;
+const GI = imports.gi.GIRepository;
+const XObject = imports.XObject.XObject;
+const console = imports.console.console;
-
-XObject = imports.XObject.XObject;
-console = imports.console.console;
-NameSpace = imports.NameSpace.NameSpace;
-
-Base = imports.Base.Base;
+const NameSpace = imports.Introspect.NameSpace.NameSpace;
+const Base = imports.Introspect.Base.Base;
@@ -16,7 +14,7 @@ Base = imports.Base.Base;
* Struct
*/
-Struct = XObject.define(
+var Struct = XObject.define(
function(ns, name) {
Base.call(this, ns, name);
diff --git a/Introspect/Union.js b/Introspect/Union.js
index 723a756..e1cc926 100644
--- a/Introspect/Union.js
+++ b/Introspect/Union.js
@@ -1,13 +1,13 @@
//<script type="text/javascript">
-GI = imports.gi.GIRepository;
+const GI = imports.gi.GIRepository;
-XObject = imports.XObject.XObject;
-console = imports.console.console;
+const XObject = imports.XObject.XObject;
+const console = imports.console.console;
-Base = imports.Base.Base;
+const Base = imports.Introspect.Base.Base;
@@ -16,7 +16,7 @@ Base = imports.Base.Base;
* Union
*/
-Union = XObject.define(
+var Union = XObject.define(
function(ns, name) {
Base.call(this, ns, name);
diff --git a/JSDOC/DocComment.js b/JSDOC/DocComment.js
index 452ce3c..25691cb 100644
--- a/JSDOC/DocComment.js
+++ b/JSDOC/DocComment.js
@@ -23,8 +23,10 @@ DocComment = XObject.define(
if (typeof comment != "undefined") {
this.parse(comment);
}
- },
+ },
+
Object, // extends
+
{
isUserComment : true,
src : "",
@@ -203,8 +205,8 @@ DocComment = XObject.define(
/// static methods..
-XObject.extend(DocComment,
- {
+XObject.extend(DocComment,
+{
/**
* Used to store the currently shared tag text.
@@ -229,4 +231,4 @@ XObject.extend(DocComment,
}
return ns;
}
-});
\ No newline at end of file
+});
diff --git a/JsTemplate/Template.js b/JsTemplate/Template.js
index 6adb708..bd094ad 100644
--- a/JsTemplate/Template.js
+++ b/JsTemplate/Template.js
@@ -1,60 +1,63 @@
//<script type="text/javscript">
-Gio = imports.gi.Gio;
-GLib = imports.gi.GLib;
+const Gio = imports.gi.Gio;
+const GLib = imports.gi.GLib;
-XObject = imports.XObject.XObject;
+const XObject = imports.XObject.XObject;
+const console = imports.console.console;
-console = imports.console.console;
+const File = imports.File.File;
/**
* Template
*
*
*/
-
-
-Template = XObject.define(
-
+var Template = XObject.define(
function(cfg) {
- XObject.extend(this, cfg)
+ XObject.extend(this, cfg);
+
//this.templateFile = templateFile;
- if (!this.templateFile || !this.Link) {
- throw "No templateFile or Link sent to Template Contructor..";
-
+
+ if (!this.templateFile || !this.Link) {
+ throw "No templateFile or Link sent to Template Constructor..";
}
-
-
- this.template = Gio.simple_read(this.templateFile);
+ //console.log("this.templateFile: " + this.templateFile);
+
+ //this.template = Gio.simple_read(this.templateFile);
+ this.template = File.read(this.templateFile);
+ //console.log("this.template: " + this.template);
+
this.templateName = GLib.path_get_basename(this.templateFile);
this.code = "";
this.parse();
- },
- Object, {
-
+ },
+
+ Object,
+ {
parse : function() {
-
- console.log("Parsing template? " + this.templateName);
-
+
+ console.log("Parsing template: " + this.templateName);
this.template = this.template.replace(/\{#[\s\S]+?#\}/gi, "");
- this.code = "var output=``"+this.template;
+ this.code = "var output=``" + this.template;
this.code = this.code.replace(
/<for +each="(.+?)" +in="(.+?)" *>/gi,
function (match, eachName, inName) {
return "``;\rvar $"+eachName+"_keys = keys("+inName+");\rfor(var $"+eachName+"_i = 0; $"+eachName+"_i < $"+eachName+"_keys.length; $"+eachName+"_i++) {\rvar $"+eachName+"_last = ($"+eachName+"_i == $"+eachName+"_keys.length-1);\rvar $"+eachName+"_key = $"+eachName+"_keys[$"+eachName+"_i];\rvar "+eachName+" = "+inName+"[$"+eachName+"_key];\routput+=``";
}
- );
+ );
+
this.code = this.code.replace(/<if test="(.+?)">/g, "``;\rif ($1) { \routput+=``");
this.code = this.code.replace(/<else\s*\/>/g, "``;} \relse\r{ \routput+=``");
-
+
this.code = this.code.replace(/<\/(if|for)>/g, "``;\r};\routput+=``");
-
+
//File.write("/tmp/jstookit_eval_"+this.templateName+".4.js", this.code);
-
+
this.code = this.code.replace(
/\{\+\s*([\s\S]+?)\s*\+\}/gi,
function (match, code) {
@@ -64,7 +67,7 @@ Template = XObject.define(
}
);
//File.write("/tmp/jstookit_eval_"+this.templateName+".6.js", this.code);
-
+
this.code = this.code.replace(
/\{!\s*([\s\S]+?)\s*!\}/gi,
function (match, code) {
@@ -76,17 +79,13 @@ Template = XObject.define(
//File.write("/tmp/jstookit_eval_"+this.templateName+".7.js", this.code);
this.code = this.code+"``;";
-
-
this.code = this.code.replace(/(\r?\n)/g, "\\n");
this.code = this.code.replace(/"/g, "\\\"");
-
+
this.code = this.code.replace(/``/g, "\"");
this.code = this.code.replace(/\\r/g, "\n");
//File.write("/tmp/jstookit_eval_"+this.templateName+".9.js", this.code);
this.code = this.code.replace(/\r/g, "\n\n");
-
-
},
toCode : function() {
@@ -128,49 +127,52 @@ Template = XObject.define(
process : function(data) {
//console.log("processing template");
- var keys = this.keys;
- var values = this.values;
+ var keys = this.keys;
+ var values = this.values;
- var makeSortby = this.makeSortby;
- var makeSignature = XObject.createDelegate(this.makeSignature, this);
- var summarize = this.summarize ;
- var makeFuncSkel = this.makeFuncSkel;
- var resolveLinks = this.resolveLinks;
- var makeImage = this.makeImage;
+ var makeSortby = this.makeSortby;
+ var makeSignature = XObject.createDelegate(this.makeSignature, this);
+ var summarize = this.summarize ;
+ var makeFuncSkel = this.makeFuncSkel;
+ var resolveLinks = this.resolveLinks;
+ var makeImage = this.makeImage;
+
// usefull for cross refing..
Template.data = data;
-
+
var Link = this.Link;
- var Options = imports.Options ? imports.Options.Options : false;
+ //var Options = imports.Options ? imports.Options.Options : false;
+
try {
eval(this.code);
} catch (e) {
- Gio.simple_write('/tmp/template.js', this.code);
- Seed.print('in /tmp/template.js');
- throw e;
- Seed.quit();
+ //Gio.simple_write('/tmp/template.js', this.code);
+ File.write('/tmp/template.js', this.code);
+ //Seed.print('in /tmp/template.js');
+ console.log('in /tmp/template.js');
+ //throw e;
+ //Seed.quit();
}
-
-
+
//File.write("/tmp/jstookit_eval.js", this.code);
//try {
//eval('include "/tmp/jstookit_eval.js";');
//includeJs("/tmp/jstookit_eval.js");
//eval(this.code);
- // console.log("done eval of template");
-
+ // console.log("done eval of template");
+
return output;
},
-
isdefined : function (typ) {
return typ != 'undefined';
},
-
-
+
summarize : function(desc) {
if (typeof desc != "undefined")
return desc.match(/([\w\W]+?\.)[^a-z0-9]/i)? RegExp.$1 : desc;
+ else
+ return '';
},
/** make a symbol sorter by some attribute */
@@ -180,24 +182,22 @@ Template = XObject.define(
a = a[attribute]; //.toLowerCase();
b = b[attribute];//.toLowerCase();
if (a < b) return -1;
- if (a > b) return 1;
- return 0;
+ if (a > b) return 1;
+ //return 0;
}
+ return 0;
}
},
+
makeImage : function(alias) {
/// http://library.gnome.org/devel/gtk/stable/notebook.png
- var ns = alias.split('.').shift();
+ var ns = alias.split('.').shift();
var cls = alias.split('.').pop().toLowerCase();
if (ns != 'Gtk' ) {
return '';//ns;
}
return '<img class="class-picture" src="http://library.gnome.org/devel/gtk/stable/' + cls + '.png">';
-
-
},
-
-
makeSignature : function(params) {
if (!params) return "()";
@@ -240,30 +240,32 @@ Template = XObject.define(
).map( function($) { return $.name == 'this' ? '_self' : $.name; } ).join(", ")
+
")\n{\n\n}";
-
+
},
/** Find symbol { link ...} strings in text and turn into html links */
resolveLinks : function (str, from) {
+
if (!str || typeof(str) == 'undefined') {
return '';
}
-
+
// gtk specific. now..
// @ -> bold.. - they are arguments..
-
+
str = str.replace(/@([a-z_]+)/gi,
function(match, symbolName) {
return '<b>' + symbolName + '</b>';
}
);
+
// constants.
str = str.replace(/%([a-z_]+)/gi,
function(match, symbolName) {
return '<b>' + symbolName + '</b>';
}
);
-
+
str = str.replace(/#([a-z_]+)/gi,
function(match, symbolName) {
return '<b>' + symbolName + '</b>';
@@ -272,9 +274,9 @@ Template = XObject.define(
//return new Link().toSymbol(Template.data.ns + '.' + symbolName);
}
);
-
+
str = str.replace(/\n/gi, '<br/>');
-
+
/*
str = str.replace(/\{ link ([^} ]+) ?\}/gi,
function(match, symbolName) {
@@ -305,9 +307,7 @@ Template = XObject.define(
}
);
*/
-
+
return str;
}
-
-
-});
\ No newline at end of file
+});
diff --git a/String.js b/String.js
index d30b494..716803a 100755
--- a/String.js
+++ b/String.js
@@ -8,16 +8,18 @@
* Fork - LGPL
* <script type="text/javascript">
*/
+
// usage:
// Seed.include('String.js');
-XObject = imports.XObject.XObject;
+
+const XObject = imports.XObject.XObject;
-XObject.extend(String,
+XObject.extend(String,
{
-
+
/** @scope String */
-
+
/**
* Escapes the passed string for ' and \
* @param {String} string The string to escape
@@ -51,7 +53,8 @@ XObject.extend(String,
}
return result;
},
- /**
+
+ /**
* Allows you to define a tokenized string and pass an arbitrary number of arguments to replace the tokens. Each
* token must be unique, and must increment in the format {0}, {1}, etc. Example usage:
* <pre><code>
@@ -71,7 +74,6 @@ XObject.extend(String,
return args[i];
});
},
-
/**
* Allows you to define a tokenized string and pass an arbitrary number of arguments to replace the tokens. Each
@@ -93,7 +95,7 @@ XObject.extend(String,
return this.htmlEncode(args[i]);
});
},
-
+
/**
* Convert certain characters (&, <, >, and ') to their HTML character equivalents for literal display in web pages.
* @param {String} value The string to encode
@@ -104,8 +106,6 @@ XObject.extend(String,
String(value).replace(/&/g, "&"
).replace(/>/g, ">").replace(/</g, "<").replace(/"/g, """);
}
-
-
}
);
@@ -125,35 +125,32 @@ XObject.extend(String,
* @param {String} other The new value to use if the string already equals the first value passed in
* @return {String} The new value
*/
-
+
XObject.extend(String.prototype, {
-
+
toggle : function(value, other){
return this == value ? other : value;
},
-
+
trim : function (toTrim) {
var out = this.ltrim(toTrim);
out = out.rtrim(toTrim);
return out;
},
-
+
ltrim : function (toTrim) {
if (this.substr(0, toTrim.length) == toTrim) {
return this.slice(toTrim.length);
}
-
+
return this;
},
-
+
rtrim : function (toTrim) {
if (this.substr(this.length - toTrim.length) == toTrim) {
return this.slice(0, this.length - toTrim.length);
}
-
+
return this;
}
-
-
-
-});
\ No newline at end of file
+});
diff --git a/XObject.js b/XObject.js
index 05b35dc..1508659 100644
--- a/XObject.js
+++ b/XObject.js
@@ -32,13 +32,13 @@
*
*
*
- * @arg xtype {String|Function} constructor or string.
- * @arg id {String} (optional) id for registry
- * @arg xns {String|Object} (optional) namespace eg. Gtk or 'Gtk' - used with xtype.
- * @arg items {Array} (optional) list of child elements which will be constructed.. using XObject
+ * @arg xtype {String|Function} constructor or string.
+ * @arg id {String} (optional) id for registry
+ * @arg xns {String|Object} (optional) namespace eg. Gtk or 'Gtk' - used with xtype.
+ * @arg items {Array} (optional) list of child elements which will be constructed.. using XObject
* @arg listeners {Object} (optional) map Gobject signals to functions
- * @arg pack {Function|String|Array} (optional) how this object gets added to it's parent
- * @arg el {Object} (optional) premade GObject
+ * @arg pack {Function|String|Array} (optional) how this object gets added to it's parent
+ * @arg el {Object} (optional) premade GObject
*
* --- needs a xdebug option!
*
@@ -57,12 +57,8 @@ function XObject (cfg) {
if (cfg.init) {
this.init = cfg.init; // override!
}
-
-
}
-
-
XObject.prototype = {
/**
* @property el {GObject} the Gtk / etc. element.
@@ -113,9 +109,9 @@ XObject.prototype = {
for (var i in o) {
if ((typeof(o[i]) == 'object') ||
(typeof(o[i]) == 'function') ||
- i == 'pack' ||
- i == 'id' ||
- i == 'xtype' ||
+ i == 'pack' ||
+ i == 'id' ||
+ i == 'xtype' ||
i == 'xdebug' ||
i == 'xns'
) {
@@ -185,8 +181,7 @@ XObject.prototype = {
* @arg cfg {Object} same as XObject constructor.
*/
addItem : function(o) {
-
-
+
var item = (o.constructor == XObject) ? o : new XObject(o);
item.init();
item.parent = this;
@@ -195,12 +190,14 @@ XObject.prototype = {
if (item.pack===false) { // no
return;
}
+
if (typeof(item.pack) == 'function') {
// parent, child
item.pack.apply(o, [ o , o.items[i] ]);
item.parent = this;
return;
}
+
var args = [];
var pack_m = false;
if (typeof(item.pack) == 'string') {
@@ -225,17 +222,15 @@ XObject.prototype = {
if (pack_m) {
this.el[pack_m].apply(this.el, args);
}
-
-
-
},
+
/**
- * @method addListener
- * Connects a method to a signal. (gjs/Seed aware)
- *
- * @arg sig {String} name of signal
- * @arg fn {Function} handler.
- */
+ * @method addListener
+ * Connects a method to a signal. (gjs/Seed aware)
+ *
+ * @arg sig {String} name of signal
+ * @arg fn {Function} handler.
+ */
addListener : function(sig, fn)
{
@@ -250,48 +245,49 @@ XObject.prototype = {
} else {
this.el.connect( sig, _li);
}
-
-
},
- /**
- * @method get
- * Finds an object in the child elements using xid of object.
- * prefix with '.' to look up the tree.. multiple '..' to look further up..
- *
- * @arg name {String} name of signal
- * @return {XObject|false} the object if found.
- */
+
+ /**
+ * @method get
+ * Finds an object in the child elements using xid of object.
+ * prefix with '.' to look up the tree.. multiple '..' to look further up..
+ *
+ * @arg name {String} name of signal
+ * @return {XObject|false} the object if found.
+ */
get : function(xid)
{
var ret= false;
if (xid[0] == '.') {
return this.parent.get(xid.substring(1));
}
-
-
+
this.items.forEach(function(ch) {
if (ch.id == xid) {
ret = ch;
return true;
- }
- })
+ } else
+ return false;
+ });
+
if (ret) {
return ret;
}
+
// iterate children.
this.items.forEach(function(ch) {
ret = ch.get(xid);
if (ret) {
return true;
- }
- })
+ } else
+ return false;
+ });
+
return ret;
}
-
-
}
-
-
+
+
/**
* Copies all the properties of config to obj.
*
@@ -302,8 +298,6 @@ XObject.prototype = {
* @return {Object} returns obj
* @member XObject extend
*/
-
-
XObject.extend = function(o, c, defaults){
if(defaults){
// no "this" reference for friendly out of scope calls
@@ -326,24 +320,22 @@ XObject.extend(XObject,
* @return {Object} returns obj
* @member Object extendIf
*/
-
-
extendIf : function(o, c){
if(!o || !c || typeof c != 'object'){
return o;
}
+
for(var p in c){
if (typeof(o[p]) != 'undefined') {
continue;
}
o[p] = c[p];
}
+
return o;
},
-
-
/**
* Extends one class with another class and optionally overrides members with the passed literal. This class
* also adds the function "override()" to the class that can be used to override
@@ -359,6 +351,7 @@ XObject.extend(XObject,
* ... methods and properties.
* }
* });
+ *
* @param {Function} constructor The class inheriting the functionality
* @param {Object} superclass The class being extended
* @param {Object} overrides (optional) A literal with members
@@ -372,6 +365,7 @@ XObject.extend(XObject,
this[m] = o[m];
}
};
+
return function(sb, sp, overrides) {
if (typeof(sp) == 'undefined') {
// error condition - try and dump..
@@ -398,7 +392,6 @@ XObject.extend(XObject,
};
}(),
-
/**
* returns a list of keys of the object.
* @param {Object} obj object to inspect
@@ -429,7 +422,6 @@ XObject.extend(XObject,
* x = XObject.createDelegate(a, this);
*
*/
-
createDelegate : function(method, obj, args, appendArgs){
return function() {
@@ -438,12 +430,11 @@ XObject.extend(XObject,
callArgs = Array.prototype.slice.call(arguments, 0);
callArgs = callArgs.concat(args);
}else if(typeof appendArgs == "number"){
- callArgs = Array.prototype.slice.call(arguments, 0); // copy arguments first
- var applyArgs = [appendArgs, 0].concat(args); // create method call params
+ callArgs = Array.prototype.slice.call(arguments, 0); // copy arguments first
+ var applyArgs = [appendArgs, 0].concat(args); // create method call params
Array.prototype.splice.apply(callArgs, applyArgs); // splice them in
}
return method.apply(obj || window, callArgs);
};
}
-
-});
\ No newline at end of file
+});
diff --git a/console.js b/console.js
index e3bd0f3..f3384ff 100644
--- a/console.js
+++ b/console.js
@@ -3,10 +3,12 @@
var console = {
log : function (v) {
- Seed.print(v);
+ //Seed.print(v);
+ print(v);
},
dump : function (ar) {
- Seed.print(this._dump(ar, 0));
+ //Seed.print(this._dump(ar, 0));
+ print(this._dump(ar, 0));
},
_dump: function(arr,level) {
diff --git a/docs.js b/docs.js
index 7a2a233..1d67d12 100644
--- a/docs.js
+++ b/docs.js
@@ -1,28 +1,41 @@
//<Script type="text/javascript">
-Gtk = imports.gi.Gtk;
-Gio = imports.gi.Gio;
-Gdk = imports.gi.Gdk;
+const Gtk = imports.gi.Gtk;
+const Gio = imports.gi.Gio;
+const Gdk = imports.gi.Gdk;
+const GLib = imports.gi.GLib;
+
// generic libraries
-XObject = imports.XObject.XObject;
-File = imports.File.File;
-console = imports.console.console;
-Template = imports.JsTemplate.Template.Template;
+const XObject = imports.XObject.XObject;
+const File = imports.File.File;
+const console = imports.console.console;
+const Template = imports.JsTemplate.Template.Template;
// Introspecion specific..
-NameSpace = imports.Introspect.NameSpace.NameSpace;
-Link = imports.Introspect.Link.Link;
-
+const NameSpace = imports.Introspect.NameSpace.NameSpace;
+const Link = imports.Introspect.Link.Link;
-var outputdir = Seed.argv[2];
+var isSeed = typeof(Seed) != 'undefined';
+function argv(n) {
+ if (isSeed)
+ return Seed.argv[n];
+ else
+ return ARGV[n-2]; // running gjs from gnome-shell 3 (~/binjhbuild run ..)
+ // make args shift 2 place
+}
+//var outputdir = Seed.argv[2];
+var outputdir = argv(2);
if (!outputdir) {
throw {
- name: "ArgumentError",
- message: "No output directory specified on the command line\n" +
- "Usage seed docs.js /var/www/seed [Gtk] \n"
+ name : "ArgumentError",
+ message: "No output directory specified on the command line\n" +
+ "Usage:\n" +
+ "\t<seed|gjs> docs.js <output_dir> [root_gir_name_list]\n" +
+ "\toutput_dir - ex: /var/www/seed \n" +
+ "\tgir_root_name_list - comma separated gir root name ex: Gtk,Gio, ...\n"
};
}
@@ -32,56 +45,66 @@ if (!File.isDirectory(outputdir)) {
File.mkdir(outputdir);
};
-
-// Which libraries to build.
+// Which libraries to build.
var ns_list = NameSpace.namespaces();
-if (typeof(Seed.argv[3]) == 'string') {
- console.log(Seed.argv.length);
- ns_list = Seed.argv[3].split(',');
+//if (typeof(Seed.argv[3]) == 'string') {
+if (typeof(argv(3)) == 'string') {
+// console.log(Seed.argv.length);
+// ns_list = Seed.argv[3].split(',');
+ ns_list = argv(3).split(',');
}
-
-
ns_list = ns_list.sort();
+
// let's try and load them, so we find out early what will fail.
-print("loading library to make sure it works.");
-ns_list.forEach(function(ns_name)
-{
- var core = imports.gi[ns_name];
+//print("loading library to make sure it works.");
+ns_list.forEach(function(ns_name)
+{
+ var core = imports.gi[ns_name];
});
-
+var script_path = GLib.get_current_dir();
// which languages do we want to output for.
-langs=[];
-File.list(__script_path__ + '/templates/').forEach(function(f) {
- if (!File.isDirectory(__script_path__ + '/templates/' + f)) {
+var langs = [];
+//File.list(__script_path__ + '/templates/').forEach(function(f) {
+File.list(script_path + '/templates/').forEach(function(f) {
+ // skip file
+ //if (!File.isDirectory(__script_path__ + '/templates/' + f)) {
+ if (!File.isDirectory(script_path + '/templates/' + f)) {
return;
}
+
+ // skip dir
if (f == 'resources') {
return;
}
+
+ //console.log("lang: " + f);
langs.push({
- name : f,
- cls_template : new Template( {
- templateFile : __script_path__ + '/templates/' + f + '/class.html',
- Link : Link // links might be specific to languages..
- }),
- cls_ix_template : new Template( {
- templateFile : __script_path__ + '/templates/' + f + '/class_ix.html',
- Link : Link // links might be specific to languages..
- }),
+ name : f,
+ cls_template : new Template({
+ //templateFile : __script_path__ + '/templates/' + f + '/class.html',
+ templateFile : script_path + '/templates/' + f + '/class.html',
+ Link : Link // links might be specific to languages..
+ }),
+ cls_ix_template : new Template({
+ //templateFile : __script_path__ + '/templates/' + f + '/class_ix.html',
+ templateFile : script_path + '/templates/' + f + '/class_ix.html',
+ Link : Link // links might be specific to languages..
+ }),
reference_template : new Template({
- templateFile : __script_path__ + '/templates/' + f + '/references.html',
- Link : Link // links might be specific to languages..
- }),
+ //templateFile : __script_path__ + '/templates/' + f + '/references.html',
+ templateFile : script_path + '/templates/' + f + '/references.html',
+ Link : Link // links might be specific to languages..
+ }),
});
});
/*
-var cls_template = new Template(__script_path__ + '/templates/class.html');
-var cls_ix_template = new Template(__script_path__ + '/templates/class_ix.html');
+var cls_template = new Template(__script_path__ + '/templates/class.html');
+var cls_ix_template = new Template(__script_path__ + '/templates/class_ix.html');
var reference_template = new Template(__script_path__ + '/templates/references.html');
*/
@@ -91,55 +114,68 @@ 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};
+
+ // need to load the lib before introspecting it later
+ //var core = imports.gi[ns_name];
+
+ var idx = {name: ns_name};
console.log("START:" + ns_name);
-
+
var ns = NameSpace.ns(ns_name);
-
+
// gir goes in top level...
if (File.exists(ns.gir_file)) {
+ console.log("gir_file: " + ns.gir_file);
File.copyFile(ns.gir_file, outputdir + '/'+ ns.gir_filename, Gio.FileCopyFlags.OVERWRITE);
}
-
-
-
langs.forEach(function(lang) {
- ns['left_bar'] = lang.cls_ix_template.process(ns);
+
+ //console.log("lang.name: " + lang.name);
+
+ //ns['left_bar'] = lang.cls_ix_template.process(ns);
+ ns.left_bar = lang.cls_ix_template.process(ns);
+
+ // create lang dir if needed
+ if (!File.isDirectory(outputdir + '/' + lang.name)) {
+ console.log("Creating directory: " + outputdir + '/' + lang.name);
+ File.mkdir(outputdir + '/' + lang.name);
+ };
+
// namespace template
- Gio.simple_write(outputdir + '/'+ lang.name+ '/' +ns_name + '.html', lang.cls_template.process(ns));
-
+ //Gio.simple_write(outputdir + '/'+ lang.name + '/' + ns_name + '.html', lang.cls_template.process(ns));
+ File.write(outputdir + '/' + lang.name + '/' + ns_name + '.html', lang.cls_template.process(ns));
+
// left bar index of elements in namespace...
- Gio.simple_write(outputdir + '/'+ lang.name + '/_ix_'+ ns_name + '.shtml', lang.cls_ix_template.process(ns));
-
+ //Gio.simple_write(outputdir + '/'+ lang.name + '/_ix_'+ ns_name + '.shtml', lang.cls_ix_template.process(ns));
+ File.write(outputdir + '/' + lang.name + '/_ix_'+ ns_name + '.shtml', lang.cls_ix_template.process(ns));
});
-
-
+
var actions = {
- 'objects' : 'Class',
+ 'objects' : 'Class',
'interfaces' : 'Interface',
- 'structs' : 'Struct',
- 'unions' : 'Union',
- 'enums' : 'Enum'
-
+ 'structs' : 'Struct',
+ 'unions' : 'Union',
+ 'enums' : 'Enum'
};
-
+
for (var i in actions) {
// we flag GLib as a GObject lib...
idx[i]= ns_name == 'GLib' ? 1 : ns[i].length ;
ns[i].forEach( function(n) {
- print('NameSpace.factory(' + actions[i] +','+ns_name+','+n);
+ //print('NameSpace.factory(' + actions[i] +','+ns_name+','+n);
var odata = XObject.extend(
NameSpace.factory(actions[i], ns_name, n),
{ 'left_bar' :ns['left_bar'] }
);
langs.forEach(function(lang) {
- Gio.simple_write(outputdir + '/'+ lang.name + '/' + ns_name + '.' + n + '.html',
+ //Gio.simple_write(outputdir + '/'+ lang.name + '/' + ns_name + '.' + n + '.html',
+ // lang.cls_template.process(odata)
+ //)
+ File.write(outputdir + '/'+ lang.name + '/' + ns_name + '.' + n + '.html',
lang.cls_template.process(odata)
)
});
@@ -147,40 +183,40 @@ ns_list.forEach(function(ns_name)
});
}
ns_idx.push(idx);
-
});
-var refs = '';
+var refs = '';
var html_file_path = '';
-var html = ''
+var html = '';
// output cross reference data..
langs.forEach(function(lang) {
-
+
for (var i in NameSpace.references) {
-
+
html_file_path = [ outputdir, lang.name, i + '.html'].join('/');
-
+
if (i == 'undefined') {
console.log("Undefined name space - ignored");
continue;
}
-
+
if (!File.isFile(html_file_path)) {
console.log("No HTML file " + html_file_path + " to insert references into - ignored");
continue;
}
-
+
refs = lang.reference_template.process(NameSpace.references[i]);
- // HTML to put refs into
+ // HTML to put refs into
html = File.read(html_file_path);
- // do the replacement
+ // do the replacement
html = html.replace(/\<!--references--\>/, refs);
- // write back to file
- Gio.simple_write(html_file_path, html);
+ // write back to file
+ //Gio.simple_write(html_file_path, html);
+ File.write(html_file_path, html);
}
});
@@ -188,10 +224,15 @@ langs.forEach(function(lang) {
// set up index and resources.
langs.forEach(function(lang) {
var ix_template = new Template({
- templateFile : __script_path__ + '/templates/' + lang.name + '/index.html',
- Link : Link, // lang specifc?
- });
- Gio.simple_write(outputdir + '/' + lang.name + '/index.html', ix_template.process(ns_idx));
- File.silentRecursiveCopy(__script_path__ + '/templates/resources/',
- outputdir + '/' + lang.name , Gio.FileCopyFlags.OVERWRITE);
+ //templateFile : __script_path__ + '/templates/' + lang.name + '/index.html',
+ templateFile : script_path + '/templates/' + lang.name + '/index.html',
+ Link : Link, // lang specifc?
+ });
+
+ //Gio.simple_write(outputdir + '/' + lang.name + '/index.html', ix_template.process(ns_idx));
+ File.write(outputdir + '/' + lang.name + '/index.html', ix_template.process(ns_idx));
+ //File.silentRecursiveCopy(__script_path__ + '/templates/resources/',
+ File.silentRecursiveCopy(script_path + '/templates/resources/',
+ outputdir + '/' + lang.name ,
+ Gio.FileCopyFlags.OVERWRITE);
});
diff --git a/templates/seed/class.html b/templates/seed/class.html
index d4bc71e..63f88c7 100644
--- a/templates/seed/class.html
+++ b/templates/seed/class.html
@@ -11,7 +11,7 @@
<title>JsDoc Reference - {+data.name+}</title>
<script type="text/javascript" src="page.js"></script>
- c
+
<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>
@@ -747,4 +747,4 @@
<a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> on {+new Date()+}
</div>
</body>
-</html>
\ No newline at end of file
+</html>
diff --git a/templates/seed/class_ix.html b/templates/seed/class_ix.html
index 96602b1..09d011b 100644
--- a/templates/seed/class_ix.html
+++ b/templates/seed/class_ix.html
@@ -46,4 +46,4 @@
</for>
</ul>
-</if>
\ No newline at end of file
+</if>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]