1 //<Script type="text/javascript">
9 XObject = imports.XObject.XObject;
10 File = imports.File.File;
11 console = imports.console.console;
12 Template = imports.JsTemplate.Template.Template;
14 // Introspecion specific..
15 NameSpace = imports.Introspect.NameSpace.NameSpace;
16 Link = imports.Introspect.Link.Link;
20 var outputdir = Seed.argv[2];
24 name: "ArgumentError",
25 message: "No output directory specified on the command line\n" +
26 "Usage seed docs.js /var/www/seed [Gtk] \n"
31 if (!File.isDirectory(outputdir)) {
32 console.log("Creating directory " + outputdir);
33 File.mkdir(outputdir);
37 // Which libraries to build.
39 var ns_list = NameSpace.namespaces();
40 if (typeof(Seed.argv[3]) == 'string') {
41 console.log(Seed.argv.length);
42 ns_list = Seed.argv[3].split(',');
46 ns_list = ns_list.sort();
47 // let's try and load them, so we find out early what will fail.
48 print("loading library to make sure it works.");
50 ns_list.forEach(function(ns_name)
54 var core = imports.gi[ns_name];
55 ns_list_clean.push(ns_name);
57 print(JSON.stringify(e));
61 ns_list = ns_list_clean;
65 // which languages do we want to output for.
67 File.list(__script_path__ + '/templates/').forEach(function(f) {
68 if (!File.isDirectory(__script_path__ + '/templates/' + f)) {
71 if (f == 'resources') {
76 cls_template : new Template( {
77 templateFile : __script_path__ + '/templates/' + f + '/class.html',
78 Link : Link // links might be specific to languages..
80 cls_ix_template : new Template( {
81 templateFile : __script_path__ + '/templates/' + f + '/class_ix.html',
82 Link : Link // links might be specific to languages..
84 reference_template : new Template({
85 templateFile : __script_path__ + '/templates/' + f + '/references.html',
86 Link : Link // links might be specific to languages..
93 var cls_template = new Template(__script_path__ + '/templates/class.html');
94 var cls_ix_template = new Template(__script_path__ + '/templates/class_ix.html');
95 var reference_template = new Template(__script_path__ + '/templates/references.html');
98 print("Looping throught namespaces");
100 ns_list.forEach(function(ns_name)
103 //if (ns_idx.length) { return ;/* do one - for testing */ }
105 var core = imports.gi[ns_name];
106 var idx = { name: ns_name};
107 console.log("START:" + ns_name);
109 var ns = NameSpace.ns(ns_name);
111 // gir goes in top level...
112 if (File.exists(ns.gir_file)) {
113 File.copyFile(ns.gir_file, outputdir + '/'+ ns.gir_filename, Gio.FileCopyFlags.OVERWRITE);
119 langs.forEach(function(lang) {
120 ns['left_bar'] = lang.cls_ix_template.process(ns);
121 // namespace template
123 if (!File.exists(outputdir + '/'+ lang.name)) {
124 File.mkdir(outputdir + '/'+ lang.name );
128 Gio.simple_write(outputdir + '/'+ lang.name+ '/' +ns_name + '.html', lang.cls_template.process(ns));
130 // left bar index of elements in namespace...
131 Gio.simple_write(outputdir + '/'+ lang.name + '/_ix_'+ ns_name + '.shtml', lang.cls_ix_template.process(ns));
138 'interfaces' : 'Interface',
139 'structs' : 'Struct',
145 for (var i in actions) {
146 // we flag GLib as a GObject lib...
147 idx[i]= ns_name == 'GLib' ? 1 : ns[i].length ;
149 ns[i].forEach( function(n) {
151 print('NameSpace.factory(' + actions[i] +','+ns_name+','+n);
152 var odata = XObject.extend(
153 NameSpace.factory(actions[i], ns_name, n),
154 { 'left_bar' :ns['left_bar'] }
157 langs.forEach(function(lang) {
158 Gio.simple_write(outputdir + '/'+ lang.name + '/' + ns_name + '.' + n + '.html',
159 lang.cls_template.process(odata)
162 console.log(ns_name + '.' +n);
170 var html_file_path = '';
173 // output cross reference data..
174 langs.forEach(function(lang) {
176 for (var i in NameSpace.references) {
178 html_file_path = [ outputdir, lang.name, i + '.html'].join('/');
180 if (i == 'undefined') {
181 console.log("Undefined name space - ignored");
185 if (!File.isFile(html_file_path)) {
186 console.log("No HTML file " + html_file_path + " to insert references into - ignored");
190 refs = lang.reference_template.process(NameSpace.references[i]);
192 // HTML to put refs into
193 html = File.read(html_file_path);
195 // do the replacement
196 html = html.replace(/\<!--references--\>/, refs);
198 // write back to file
199 Gio.simple_write(html_file_path, html);
204 // set up index and resources.
205 langs.forEach(function(lang) {
206 var ix_template = new Template({
207 templateFile : __script_path__ + '/templates/' + lang.name + '/index.html',
208 Link : Link, // lang specifc?
210 Gio.simple_write(outputdir + '/' + lang.name + '/index.html', ix_template.process(ns_idx));
211 File.silentRecursiveCopy(__script_path__ + '/templates/resources/',
212 outputdir + '/' + lang.name , Gio.FileCopyFlags.OVERWRITE);