1 //<Script type="text/javascript">
6 XObject = imports.XObject.XObject;
10 File = imports.File.File;
11 console = imports.console.console;
12 Introspect = imports['JSDOC/Introspect.js'].Introspect;
13 Template = imports['JSDOC/Template.js'].Template;
16 var outputdir = Seed.argv[2];
20 name: "ArgumentError",
21 message: "No output directory specified on the command line\n" +
22 "Usage seed docs.js /var/www/seed [Gtk] \n"
27 if (!File.isDirectory(outputdir)) {
28 console.log("Creating directory " + outputdir);
29 File.mkdir(outputdir);
33 // Which libraries to build.
35 var ns_list = Introspect.namespaces();
36 if (typeof(Seed.argv[3]) == 'string') {
37 console.log(Seed.argv.length);
38 ns_list = Seed.argv[3].split(',');
41 ns_list = ns_list.sort();
44 // which languages do we want to output for.
46 File.list(__script_path__ + '/templates/').forEach(function(f) {
47 if (!File.isDirectory(__script_path__ + '/templates/' + f)) {
50 if (f == 'resources') {
55 cls_template : new Template(__script_path__ + '/templates/' + f + '/class.html'),
56 cls_ix_template : new Template(__script_path__ + '/templates/' + f + '/class_ix.html'),
57 reference_template : new Template(__script_path__ + '/templates/' + f + '/references.html'),
63 var cls_template = new Template(__script_path__ + '/templates/class.html');
64 var cls_ix_template = new Template(__script_path__ + '/templates/class_ix.html');
65 var reference_template = new Template(__script_path__ + '/templates/references.html');
70 ns_list.forEach(function(ns_name)
73 //if (ns_idx.length) { return ;/* do one - for testing */ }
75 var core = imports.gi[ns_name];
76 var idx = { name: ns_name};
77 console.log("START:" + ns_name);
79 var ns = Introspect.ns(ns_name);
81 if (File.exists(ns.gir_file)) {
82 File.copyFile(ns.gir_file, outputdir + '/'+ ns.gir_filename, Gio.FileCopyFlags.OVERWRITE);
86 ns['left_bar'] = cls_ix_template.process(ns);
88 langs.forEach(function(lang) {
90 Gio.simple_write(outputdir + '/'+ lang + '/' +ns_name + '.html', lang.cls_template.process(ns));
92 // left bar index of elements in namespace...
93 Gio.simple_write(outputdir + '/'+ lang + '/_ix_'+ ns_name + '.shtml', lang.cls_ix_template.process(ns));
100 'interfaces' : 'Interface',
101 'structs' : 'Struct',
106 for (var i in actions) {
107 // we flag GLib as a GObject lib...
108 idx[i]= ns_name == 'GLib' ? 1 : ns[i].length ;
109 ns[i].forEach( function(n) {
112 Gio.simple_write(outputdir + '/'+ ns_name + '.' + n + '.html',
113 cls_template.process(
115 Introspect.factory(actions[i], ns_name, n),
116 { 'left_bar' :ns['left_bar'] }
121 console.log(ns_name + '.' +n);
129 var html_file_path = '';
133 for (var i in Introspect.references) {
134 html_file_path = File.join(outputdir, i + '.html');
136 if (i == 'undefined') {
137 console.log("Undefined name space - ignored");
140 if (!File.isFile(html_file_path)) {
141 console.log("No HTML file " + html_file_path + " to insert references into - ignored");
145 refs = reference_template.process(Introspect.references[i]);
147 // HTML to put refs into
148 html = File.read(html_file_path);
150 // do the replacement
151 html = html.replace(/\<!--references--\>/, refs);
153 // write back to file
154 Gio.simple_write(html_file_path, html);
158 var ix_template = new Template(__script_path__ + '/templates/index.html');
159 Gio.simple_write(outputdir + '/index.html', ix_template.process(ns_idx));
160 File.silentRecursiveCopy(__script_path__ + '/templates/resources/', outputdir, Gio.FileCopyFlags.OVERWRITE);