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;
15 Link = = imports.Introspect.Link.Link;
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( {
57 templateFile : __script_path__ + '/templates/' + f + '/class.html',
58 Link : Link // links might be specific to languages..
60 cls_ix_template : new Template( {
61 templateFile : __script_path__ + '/templates/' + f + '/class_ix.html',
62 Link : Link// links might be specific to languages..
64 reference_template : new Template(
65 templateFile : __script_path__ + '/templates/' + f + '/references.html',
66 Link : Link// links might be specific to languages..
73 var cls_template = new Template(__script_path__ + '/templates/class.html');
74 var cls_ix_template = new Template(__script_path__ + '/templates/class_ix.html');
75 var reference_template = new Template(__script_path__ + '/templates/references.html');
80 ns_list.forEach(function(ns_name)
83 //if (ns_idx.length) { return ;/* do one - for testing */ }
85 var core = imports.gi[ns_name];
86 var idx = { name: ns_name};
87 console.log("START:" + ns_name);
89 var ns = NameSpace.ns(ns_name);
91 // gir goes in top level...
92 if (File.exists(ns.gir_file)) {
93 File.copyFile(ns.gir_file, outputdir + '/'+ ns.gir_filename, Gio.FileCopyFlags.OVERWRITE);
97 ns['left_bar'] = cls_ix_template.process(ns);
99 langs.forEach(function(lang) {
100 // namespace template
101 Gio.simple_write(outputdir + '/'+ lang.name+ '/' +ns_name + '.html', lang.cls_template.process(ns));
103 // left bar index of elements in namespace...
104 Gio.simple_write(outputdir + '/'+ lang.name + '/_ix_'+ ns_name + '.shtml', lang.cls_ix_template.process(ns));
111 'interfaces' : 'Interface',
112 'structs' : 'Struct',
117 for (var i in actions) {
118 // we flag GLib as a GObject lib...
119 idx[i]= ns_name == 'GLib' ? 1 : ns[i].length ;
120 ns[i].forEach( function(n) {
121 var odata = XObject.extend(
122 NameSpace.factory(actions[i], ns_name, n),
123 { 'left_bar' :ns['left_bar'] }
125 langs.forEach(function(lang) {
126 Gio.simple_write(outputdir + '/'+ lang.name + '/' + ns_name + '.' + n + '.html',
127 lang.cls_template.process(odata)
130 console.log(ns_name + '.' +n);
138 var html_file_path = '';
141 // output cross reference data..
142 langs.forEach(function(lang) {
144 for (var i in NameSpace.references) {
146 html_file_path = [ outputdir, lang.name, i + '.html'].join('/');
148 if (i == 'undefined') {
149 console.log("Undefined name space - ignored");
153 if (!File.isFile(html_file_path)) {
154 console.log("No HTML file " + html_file_path + " to insert references into - ignored");
158 refs = langs.reference_template.process(NameSpace.references[i]);
160 // HTML to put refs into
161 html = File.read(html_file_path);
163 // do the replacement
164 html = html.replace(/\<!--references--\>/, refs);
166 // write back to file
167 Gio.simple_write(html_file_path, html);
172 // set up index and resources.
173 langs.forEach(function(lang) {
174 var ix_template = new Template({
175 templateFile : __script_path__ + '/templates/' + lang.name + '/index.html',
176 Link : Link, // lang specifc?
178 Gio.simple_write(outputdir + '/' + lang.name + '/index.html', ix_template.process(ns_idx));
179 File.silentRecursiveCopy(__script_path__ + '/templates/resources/', outputdir + '/' lang.name , Gio.FileCopyFlags.OVERWRITE);