1 //<Script type="text/javascript">
8 XObject = imports.XObject.XObject;
11 File = imports.File.File;
12 console = imports.console.console;
13 Template = imports.JSDOC.Template.Template;
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(',');
45 ns_list = ns_list.sort();
48 // which languages do we want to output for.
50 File.list(__script_path__ + '/templates/').forEach(function(f) {
51 if (!File.isDirectory(__script_path__ + '/templates/' + f)) {
54 if (f == 'resources') {
59 cls_template : new Template( {
60 templateFile : __script_path__ + '/templates/' + f + '/class.html',
61 Link : Link // links might be specific to languages..
63 cls_ix_template : new Template( {
64 templateFile : __script_path__ + '/templates/' + f + '/class_ix.html',
65 Link : Link// links might be specific to languages..
67 reference_template : new Template(
68 templateFile : __script_path__ + '/templates/' + f + '/references.html',
69 Link : Link// links might be specific to languages..
76 var cls_template = new Template(__script_path__ + '/templates/class.html');
77 var cls_ix_template = new Template(__script_path__ + '/templates/class_ix.html');
78 var reference_template = new Template(__script_path__ + '/templates/references.html');
83 ns_list.forEach(function(ns_name)
86 //if (ns_idx.length) { return ;/* do one - for testing */ }
88 var core = imports.gi[ns_name];
89 var idx = { name: ns_name};
90 console.log("START:" + ns_name);
92 var ns = NameSpace.ns(ns_name);
94 // gir goes in top level...
95 if (File.exists(ns.gir_file)) {
96 File.copyFile(ns.gir_file, outputdir + '/'+ ns.gir_filename, Gio.FileCopyFlags.OVERWRITE);
100 ns['left_bar'] = cls_ix_template.process(ns);
102 langs.forEach(function(lang) {
103 // namespace template
104 Gio.simple_write(outputdir + '/'+ lang.name+ '/' +ns_name + '.html', lang.cls_template.process(ns));
106 // left bar index of elements in namespace...
107 Gio.simple_write(outputdir + '/'+ lang.name + '/_ix_'+ ns_name + '.shtml', lang.cls_ix_template.process(ns));
114 'interfaces' : 'Interface',
115 'structs' : 'Struct',
120 for (var i in actions) {
121 // we flag GLib as a GObject lib...
122 idx[i]= ns_name == 'GLib' ? 1 : ns[i].length ;
123 ns[i].forEach( function(n) {
124 var odata = XObject.extend(
125 NameSpace.factory(actions[i], ns_name, n),
126 { 'left_bar' :ns['left_bar'] }
128 langs.forEach(function(lang) {
129 Gio.simple_write(outputdir + '/'+ lang.name + '/' + ns_name + '.' + n + '.html',
130 lang.cls_template.process(odata)
133 console.log(ns_name + '.' +n);
141 var html_file_path = '';
144 // output cross reference data..
145 langs.forEach(function(lang) {
147 for (var i in NameSpace.references) {
149 html_file_path = [ outputdir, lang.name, i + '.html'].join('/');
151 if (i == 'undefined') {
152 console.log("Undefined name space - ignored");
156 if (!File.isFile(html_file_path)) {
157 console.log("No HTML file " + html_file_path + " to insert references into - ignored");
161 refs = langs.reference_template.process(NameSpace.references[i]);
163 // HTML to put refs into
164 html = File.read(html_file_path);
166 // do the replacement
167 html = html.replace(/\<!--references--\>/, refs);
169 // write back to file
170 Gio.simple_write(html_file_path, html);
175 // set up index and resources.
176 langs.forEach(function(lang) {
177 var ix_template = new Template({
178 templateFile : __script_path__ + '/templates/' + lang.name + '/index.html',
179 Link : Link, // lang specifc?
181 Gio.simple_write(outputdir + '/' + lang.name + '/index.html', ix_template.process(ns_idx));
182 File.silentRecursiveCopy(__script_path__ + '/templates/resources/', outputdir + '/' lang.name , Gio.FileCopyFlags.OVERWRITE);