1 //<Script type="text/javascript">
8 XObject = imports.XObject.XObject;
9 File = imports.File.File;
10 console = imports.console.console;
11 Template = imports.JsTemplate.Template.Template;
13 // Introspecion specific..
14 NameSpace = imports.Introspect.NameSpace.NameSpace;
15 Link = imports.Introspect.Link.Link;
19 var outputdir = Seed.argv[2];
23 name: "ArgumentError",
24 message: "No output directory specified on the command line\n" +
25 "Usage seed docs.js /var/www/seed [Gtk] \n"
30 if (!File.isDirectory(outputdir)) {
31 console.log("Creating directory " + outputdir);
32 File.mkdir(outputdir);
36 // Which libraries to build.
38 var ns_list = NameSpace.namespaces();
39 if (typeof(Seed.argv[3]) == 'string') {
40 console.log(Seed.argv.length);
41 ns_list = Seed.argv[3].split(',');
45 ns_list = ns_list.sort();
46 // let's try and load them, so we find out early what will fail.
47 print("loading library to make sure it works.");
48 ns_list.forEach(function(ns_name)
50 var core = imports.gi[ns_name];
55 // which languages do we want to output for.
57 File.list(__script_path__ + '/templates/').forEach(function(f) {
58 if (!File.isDirectory(__script_path__ + '/templates/' + f)) {
61 if (f == 'resources') {
66 cls_template : new Template( {
67 templateFile : __script_path__ + '/templates/' + f + '/class.html',
68 Link : Link // links might be specific to languages..
70 cls_ix_template : new Template( {
71 templateFile : __script_path__ + '/templates/' + f + '/class_ix.html',
72 Link : Link // links might be specific to languages..
74 reference_template : new Template({
75 templateFile : __script_path__ + '/templates/' + f + '/references.html',
76 Link : Link // links might be specific to languages..
83 var cls_template = new Template(__script_path__ + '/templates/class.html');
84 var cls_ix_template = new Template(__script_path__ + '/templates/class_ix.html');
85 var reference_template = new Template(__script_path__ + '/templates/references.html');
88 print("Looping throught namespaces");
90 ns_list.forEach(function(ns_name)
93 //if (ns_idx.length) { return ;/* do one - for testing */ }
95 var core = imports.gi[ns_name];
96 var idx = { name: ns_name};
97 console.log("START:" + ns_name);
99 var ns = NameSpace.ns(ns_name);
101 // gir goes in top level...
102 if (File.exists(ns.gir_file)) {
103 File.copyFile(ns.gir_file, outputdir + '/'+ ns.gir_filename, Gio.FileCopyFlags.OVERWRITE);
109 langs.forEach(function(lang) {
110 ns['left_bar'] = lang.cls_ix_template.process(ns);
111 // namespace template
112 Gio.simple_write(outputdir + '/'+ lang.name+ '/' +ns_name + '.html', lang.cls_template.process(ns));
114 // left bar index of elements in namespace...
115 Gio.simple_write(outputdir + '/'+ lang.name + '/_ix_'+ ns_name + '.shtml', lang.cls_ix_template.process(ns));
122 'interfaces' : 'Interface',
123 'structs' : 'Struct',
129 for (var i in actions) {
130 // we flag GLib as a GObject lib...
131 idx[i]= ns_name == 'GLib' ? 1 : ns[i].length ;
133 ns[i].forEach( function(n) {
135 print('NameSpace.factory(' + actions[i] +','+ns_name+','+n);
136 var odata = XObject.extend(
137 NameSpace.factory(actions[i], ns_name, n),
138 { 'left_bar' :ns['left_bar'] }
141 langs.forEach(function(lang) {
142 Gio.simple_write(outputdir + '/'+ lang.name + '/' + ns_name + '.' + n + '.html',
143 lang.cls_template.process(odata)
146 console.log(ns_name + '.' +n);
154 var html_file_path = '';
157 // output cross reference data..
158 langs.forEach(function(lang) {
160 for (var i in NameSpace.references) {
162 html_file_path = [ outputdir, lang.name, i + '.html'].join('/');
164 if (i == 'undefined') {
165 console.log("Undefined name space - ignored");
169 if (!File.isFile(html_file_path)) {
170 console.log("No HTML file " + html_file_path + " to insert references into - ignored");
174 refs = lang.reference_template.process(NameSpace.references[i]);
176 // HTML to put refs into
177 html = File.read(html_file_path);
179 // do the replacement
180 html = html.replace(/\<!--references--\>/, refs);
182 // write back to file
183 Gio.simple_write(html_file_path, html);
188 // set up index and resources.
189 langs.forEach(function(lang) {
190 var ix_template = new Template({
191 templateFile : __script_path__ + '/templates/' + lang.name + '/index.html',
192 Link : Link, // lang specifc?
194 Gio.simple_write(outputdir + '/' + lang.name + '/index.html', ix_template.process(ns_idx));
195 File.silentRecursiveCopy(__script_path__ + '/templates/resources/',
196 outputdir + '/' + lang.name , Gio.FileCopyFlags.OVERWRITE);