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.");
49 ns_list.forEach(function(ns_name)
53 var core = imports.gi[ns_name];
54 ns_list_clean.push(ns_name);
56 print(JSON.stringify(e));
60 ns_list = ns_list_clean;
64 // which languages do we want to output for.
66 File.list(__script_path__ + '/templates/').forEach(function(f) {
67 if (!File.isDirectory(__script_path__ + '/templates/' + f)) {
70 if (f == 'resources') {
75 cls_template : new Template( {
76 templateFile : __script_path__ + '/templates/' + f + '/class.html',
77 Link : Link // links might be specific to languages..
79 cls_ix_template : new Template( {
80 templateFile : __script_path__ + '/templates/' + f + '/class_ix.html',
81 Link : Link // links might be specific to languages..
83 reference_template : new Template({
84 templateFile : __script_path__ + '/templates/' + f + '/references.html',
85 Link : Link // links might be specific to languages..
92 var cls_template = new Template(__script_path__ + '/templates/class.html');
93 var cls_ix_template = new Template(__script_path__ + '/templates/class_ix.html');
94 var reference_template = new Template(__script_path__ + '/templates/references.html');
97 print("Looping throught namespaces");
99 ns_list.forEach(function(ns_name)
102 //if (ns_idx.length) { return ;/* do one - for testing */ }
104 var core = imports.gi[ns_name];
105 var idx = { name: ns_name};
106 console.log("START:" + ns_name);
108 var ns = NameSpace.ns(ns_name);
110 // gir goes in top level...
111 if (File.exists(ns.gir_file)) {
112 File.copyFile(ns.gir_file, outputdir + '/'+ ns.gir_filename, Gio.FileCopyFlags.OVERWRITE);
118 langs.forEach(function(lang) {
119 ns['left_bar'] = lang.cls_ix_template.process(ns);
120 // namespace template
122 if (File.exists(outputdir + '/'+ lang.name+)) {
123 File.mkdir(outputdir + '/'+ lang.name+ );
126 Gio.simple_write(outputdir + '/'+ lang.name+ '/' +ns_name + '.html', lang.cls_template.process(ns));
128 // left bar index of elements in namespace...
129 Gio.simple_write(outputdir + '/'+ lang.name + '/_ix_'+ ns_name + '.shtml', lang.cls_ix_template.process(ns));
136 'interfaces' : 'Interface',
137 'structs' : 'Struct',
143 for (var i in actions) {
144 // we flag GLib as a GObject lib...
145 idx[i]= ns_name == 'GLib' ? 1 : ns[i].length ;
147 ns[i].forEach( function(n) {
149 print('NameSpace.factory(' + actions[i] +','+ns_name+','+n);
150 var odata = XObject.extend(
151 NameSpace.factory(actions[i], ns_name, n),
152 { 'left_bar' :ns['left_bar'] }
155 langs.forEach(function(lang) {
156 Gio.simple_write(outputdir + '/'+ lang.name + '/' + ns_name + '.' + n + '.html',
157 lang.cls_template.process(odata)
160 console.log(ns_name + '.' +n);
168 var html_file_path = '';
171 // output cross reference data..
172 langs.forEach(function(lang) {
174 for (var i in NameSpace.references) {
176 html_file_path = [ outputdir, lang.name, i + '.html'].join('/');
178 if (i == 'undefined') {
179 console.log("Undefined name space - ignored");
183 if (!File.isFile(html_file_path)) {
184 console.log("No HTML file " + html_file_path + " to insert references into - ignored");
188 refs = lang.reference_template.process(NameSpace.references[i]);
190 // HTML to put refs into
191 html = File.read(html_file_path);
193 // do the replacement
194 html = html.replace(/\<!--references--\>/, refs);
196 // write back to file
197 Gio.simple_write(html_file_path, html);
202 // set up index and resources.
203 langs.forEach(function(lang) {
204 var ix_template = new Template({
205 templateFile : __script_path__ + '/templates/' + lang.name + '/index.html',
206 Link : Link, // lang specifc?
208 Gio.simple_write(outputdir + '/' + lang.name + '/index.html', ix_template.process(ns_idx));
209 File.silentRecursiveCopy(__script_path__ + '/templates/resources/',
210 outputdir + '/' + lang.name , Gio.FileCopyFlags.OVERWRITE);