1 //<Script type="text/javascript">
8 XObject = imports.XObject.XObject;
12 File = imports.File.File;
13 console = imports.console.console;
14 NameSpace = imports.Introspect.NameSpace.NameSpace;
15 Template = imports.JSDOC.Template..Template;
18 var outputdir = Seed.argv[2];
22 name: "ArgumentError",
23 message: "No output directory specified on the command line\n" +
24 "Usage seed docs.js /var/www/seed [Gtk] \n"
29 if (!File.isDirectory(outputdir)) {
30 console.log("Creating directory " + outputdir);
31 File.mkdir(outputdir);
35 // Which libraries to build.
37 var ns_list = NameSpace.namespaces();
38 if (typeof(Seed.argv[3]) == 'string') {
39 console.log(Seed.argv.length);
40 ns_list = Seed.argv[3].split(',');
43 ns_list = ns_list.sort();
46 // which languages do we want to output for.
48 File.list(__script_path__ + '/templates/').forEach(function(f) {
49 if (!File.isDirectory(__script_path__ + '/templates/' + f)) {
52 if (f == 'resources') {
57 cls_template : new Template(__script_path__ + '/templates/' + f + '/class.html'),
58 cls_ix_template : new Template(__script_path__ + '/templates/' + f + '/class_ix.html'),
59 reference_template : new Template(__script_path__ + '/templates/' + f + '/references.html'),
65 var cls_template = new Template(__script_path__ + '/templates/class.html');
66 var cls_ix_template = new Template(__script_path__ + '/templates/class_ix.html');
67 var reference_template = new Template(__script_path__ + '/templates/references.html');
72 ns_list.forEach(function(ns_name)
75 //if (ns_idx.length) { return ;/* do one - for testing */ }
77 var core = imports.gi[ns_name];
78 var idx = { name: ns_name};
79 console.log("START:" + ns_name);
81 var ns = NameSpace.ns(ns_name);
83 // gir goes in top level...
84 if (File.exists(ns.gir_file)) {
85 File.copyFile(ns.gir_file, outputdir + '/'+ ns.gir_filename, Gio.FileCopyFlags.OVERWRITE);
89 ns['left_bar'] = cls_ix_template.process(ns);
91 langs.forEach(function(lang) {
93 Gio.simple_write(outputdir + '/'+ lang.name+ '/' +ns_name + '.html', lang.cls_template.process(ns));
95 // left bar index of elements in namespace...
96 Gio.simple_write(outputdir + '/'+ lang.name + '/_ix_'+ ns_name + '.shtml', lang.cls_ix_template.process(ns));
103 'interfaces' : 'Interface',
104 'structs' : 'Struct',
109 for (var i in actions) {
110 // we flag GLib as a GObject lib...
111 idx[i]= ns_name == 'GLib' ? 1 : ns[i].length ;
112 ns[i].forEach( function(n) {
113 var odata = XObject.extend(
114 NameSpace.factory(actions[i], ns_name, n),
115 { 'left_bar' :ns['left_bar'] }
117 langs.forEach(function(lang) {
118 Gio.simple_write(outputdir + '/'+ lang.name + '/' + ns_name + '.' + n + '.html',
119 lang.cls_template.process(odata)
122 console.log(ns_name + '.' +n);
130 var html_file_path = '';
133 // output cross reference data..
134 langs.forEach(function(lang) {
136 for (var i in NameSpace.references) {
138 html_file_path = [ outputdir, lang.name, i + '.html'].join('/');
140 if (i == 'undefined') {
141 console.log("Undefined name space - ignored");
145 if (!File.isFile(html_file_path)) {
146 console.log("No HTML file " + html_file_path + " to insert references into - ignored");
150 refs = langs.reference_template.process(NameSpace.references[i]);
152 // HTML to put refs into
153 html = File.read(html_file_path);
155 // do the replacement
156 html = html.replace(/\<!--references--\>/, refs);
158 // write back to file
159 Gio.simple_write(html_file_path, html);
164 // set up index and resources.
165 langs.forEach(function(lang) {
166 var ix_template = new Template(__script_path__ + '/templates/' + lang.name + '/index.html');
167 Gio.simple_write(outputdir + '/' + lang.name + '/index.html', ix_template.process(ns_idx));
168 File.silentRecursiveCopy(__script_path__ + '/templates/resources/', outputdir + '/' lang.name , Gio.FileCopyFlags.OVERWRITE);