Added missing image assets
[gnome.introspection-doc-generator] / docs.js
1 //<Script type="text/javascript">
2
3 Gtk = imports.gi.Gtk;
4 Gio = imports.gi.Gio;
5 Gdk = imports.gi.Gdk;
6
7 imports['Object.js'].load(Object); 
8
9 File        = imports['File.js'].File; 
10 JSDOC       = imports['JSDOC.js'].JSDOC; 
11 console     = imports['console.js'].console; 
12 Introspect  = imports['JSDOC/Introspect.js'].Introspect; 
13
14 var outputdir = Seed.argv[2];
15
16 if (!outputdir) {
17     throw {
18         name: "ArgumentError", 
19         message: "No output directory specified on the command line\n" +
20           "Usage seed docs.js /var/www/seed  [Gtk] \n"
21     };
22 }
23
24 if (!File.isDirectory(outputdir)) {
25     console.log("Creating directory " + outputdir);
26     File.mkdir(outputdir);
27 };
28
29 // list namespace..
30 //var ns_list = [ 'GIRepository' ];
31
32
33
34 var ns_list = JSDOC.Introspect.namespaces();
35 if (typeof(Seed.argv[3]) == 'string') {
36     console.log(Seed.argv.length);
37     ns_list = Seed.argv[3].split(',');
38 }
39  
40 ns_list = ns_list .sort();
41 var cls_list = [];
42 var cls_template = new JSDOC.Template(__script_path__ + '/docs/class.html');
43 var cls_ix_template = new JSDOC.Template(__script_path__ + '/docs/class_ix.html');
44 var reference_template = new JSDOC.Template(__script_path__ + '/docs/references.html');
45  
46 ns_list.map(function(ns_name) 
47 {
48     var  core = imports.gi[ns_name];
49    
50     console.log("START:" + ns_name);
51    
52     var ns = Introspect.ns(ns_name);
53     ns['left_bar'] = cls_ix_template.process(ns);
54
55     Gio.simple_write(outputdir + '/'+ ns_name +  '.html', cls_template.process(ns));
56     
57     cls_list.push({
58         alias : ns_name 
59     });
60     
61     // left bar index of elements in namespace...
62     Gio.simple_write(outputdir + '/_ix_'+ ns_name +  '.shtml', cls_ix_template.process(ns));
63      
64     
65     var actions = {
66         'objects' : 'Class',
67         'interfaces' : 'Interface',
68         'structs' : 'Struct',
69         'unions' : 'Union',
70         'enums' : 'Enum'
71         
72     };
73     for (var i in actions) {
74         ns[i].map( function(n) {
75             Gio.simple_write(outputdir + '/'+ ns_name + '.' + n + '.html', 
76                 cls_template.process(
77                     Object.extend(
78                         Introspect.factory(actions[i], ns_name, n),
79                         { 'left_bar' :ns['left_bar'] }
80                     )
81                 )
82             )
83                        
84             console.log(ns_name + '.' +n);
85         }); 
86     }
87     
88       
89 });
90
91 var refs = '';
92 var html_file_path = '';
93 var html = ''
94
95
96 for (var i in Introspect.references) {
97     html_file_path = File.join(outputdir, i + '.html');
98   
99     if (i == 'undefined') {
100       console.log("Undefined name space - ignored");
101       continue;
102     }
103     if (!File.isFile(html_file_path)) {
104       console.log("No HTML file " + html_file_path + " to insert references into - ignored");
105       continue;
106     }
107     
108     refs = reference_template.process(Introspect.references[i]);
109
110       // HTML to put refs into
111     html =  File.read(html_file_path);
112
113       // do the replacement
114     html = html.replace(/\<!--references--\>/, refs);
115
116       // write back to file
117     Gio.simple_write(html_file_path, html);
118
119 }
120
121 var ix_template = new JSDOC.Template(__script_path__ + '/docs/index.html');
122 Gio.simple_write(outputdir + '/index.html', ix_template.process(ns_list));
123 File.silentRecursiveCopy(__script_path__ + '/docs/resources/', outputdir);
124
125
126