1 //<Script type="text/javascript">
8 XObject = imports.XObject.XObject;
11 File = imports.File.File;
12 console = imports.console.console;
13 NameSpace = imports.Introspect.NameSpace.NameSpace;
14 Template = imports.JSDOC.Template.Template;
17 var outputdir = Seed.argv[2];
21 name: "ArgumentError",
22 message: "No output directory specified on the command line\n" +
23 "Usage seed docs.js /var/www/seed [Gtk] \n"
28 if (!File.isDirectory(outputdir)) {
29 console.log("Creating directory " + outputdir);
30 File.mkdir(outputdir);
34 // Which libraries to build.
36 var ns_list = NameSpace.namespaces();
37 if (typeof(Seed.argv[3]) == 'string') {
38 console.log(Seed.argv.length);
39 ns_list = Seed.argv[3].split(',');
42 ns_list = ns_list.sort();
45 // which languages do we want to output for.
47 File.list(__script_path__ + '/templates/').forEach(function(f) {
48 if (!File.isDirectory(__script_path__ + '/templates/' + f)) {
51 if (f == 'resources') {
56 cls_template : new Template(__script_path__ + '/templates/' + f + '/class.html'),
57 cls_ix_template : new Template(__script_path__ + '/templates/' + f + '/class_ix.html'),
58 reference_template : new Template(__script_path__ + '/templates/' + f + '/references.html'),
64 var cls_template = new Template(__script_path__ + '/templates/class.html');
65 var cls_ix_template = new Template(__script_path__ + '/templates/class_ix.html');
66 var reference_template = new Template(__script_path__ + '/templates/references.html');
71 ns_list.forEach(function(ns_name)
74 //if (ns_idx.length) { return ;/* do one - for testing */ }
76 var core = imports.gi[ns_name];
77 var idx = { name: ns_name};
78 console.log("START:" + ns_name);
80 var ns = NameSpace.ns(ns_name);
82 // gir goes in top level...
83 if (File.exists(ns.gir_file)) {
84 File.copyFile(ns.gir_file, outputdir + '/'+ ns.gir_filename, Gio.FileCopyFlags.OVERWRITE);
88 ns['left_bar'] = cls_ix_template.process(ns);
90 langs.forEach(function(lang) {
92 Gio.simple_write(outputdir + '/'+ lang.name+ '/' +ns_name + '.html', lang.cls_template.process(ns));
94 // left bar index of elements in namespace...
95 Gio.simple_write(outputdir + '/'+ lang.name + '/_ix_'+ ns_name + '.shtml', lang.cls_ix_template.process(ns));
102 'interfaces' : 'Interface',
103 'structs' : 'Struct',
108 for (var i in actions) {
109 // we flag GLib as a GObject lib...
110 idx[i]= ns_name == 'GLib' ? 1 : ns[i].length ;
111 ns[i].forEach( function(n) {
112 var odata = XObject.extend(
113 NameSpace.factory(actions[i], ns_name, n),
114 { 'left_bar' :ns['left_bar'] }
116 langs.forEach(function(lang) {
117 Gio.simple_write(outputdir + '/'+ lang.name + '/' + ns_name + '.' + n + '.html',
118 lang.cls_template.process(odata)
121 console.log(ns_name + '.' +n);
129 var html_file_path = '';
132 // output cross reference data..
133 langs.forEach(function(lang) {
135 for (var i in NameSpace.references) {
137 html_file_path = [ outputdir, lang.name, i + '.html'].join('/');
139 if (i == 'undefined') {
140 console.log("Undefined name space - ignored");
144 if (!File.isFile(html_file_path)) {
145 console.log("No HTML file " + html_file_path + " to insert references into - ignored");
149 refs = langs.reference_template.process(NameSpace.references[i]);
151 // HTML to put refs into
152 html = File.read(html_file_path);
154 // do the replacement
155 html = html.replace(/\<!--references--\>/, refs);
157 // write back to file
158 Gio.simple_write(html_file_path, html);
163 // set up index and resources.
164 langs.forEach(function(lang) {
165 var ix_template = new Template(__script_path__ + '/templates/' + lang.name + '/index.html');
166 Gio.simple_write(outputdir + '/' + lang.name + '/index.html', ix_template.process(ns_idx));
167 File.silentRecursiveCopy(__script_path__ + '/templates/resources/', outputdir + '/' lang.name , Gio.FileCopyFlags.OVERWRITE);