1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
|
#!/usr/bin/env kjscmd
function write_page( name, body )
{
var markUp = "";
markUp += '<html>\n';
markUp += '<head>\n';
markUp += '<title>' + name + '</title>\n';
markUp += '<style type="text/css"><!--\n';
markUp += 'h1 { text-align: center; background-color: #ccccff; }\n';
markUp += 'h2 { background-color: #eeeeff; }\n';
markUp += 'h3 { background-color: #eeeeff; }\n';
markUp += 'th { background-color: #cccccc; }\n';
markUp += 'td { background-color: #eeeeee; }\n';
markUp += '--></style>\n';
markUp += '</head>\n';
markUp += '<body>\n';
markUp += '<a href="index.html">All Objects</a>';
markUp += '| <a href="index-static.html">Statics</a>';
markUp += '| <a href="index-objects.html">Objects</a>';
markUp += '| <a href="index-kjsembedobjects.html">KJSEmbed Objects</a>';
markUp += '| <a href="index-qtobjects.html">Qt Objects</a>';
markUp += '| <a href="index-kdeobjects.html">KDE Objects</a>';
markUp += '| <a href="index-exceptions.html">Exceptions</a>';
markUp += '| <a href="index-nocreate.html">Uncreatable Objects</a>\n';
markUp += '<h1>' + name + '</h1>\n';
markUp += '<hr>\n';
markUp += body;
markUp += '<hr>\n';
markUp += '</body>\n';
markUp += '</html>\n';
return markUp;
}
function write_classlist( title, intro, classlist )
{
text = '<h3>'+title+'</h3>';
text += intro;
text += '<ul>\n';
var hrefroot = '';
for ( var i = 0; i < classlist.length; i++ )
{
text += '<li>';
var href = classlist[i].toLowerCase() + '.html';
href = href.replace( /.*::/, '' );
var name = classlist[i];
text += '<a href="' + hrefroot + href + '">' + name + '</a>\n';
}
text += '</ul>\n';
return text;
}
function write_classes( title, desc, sections )
{
var txt = desc;
for ( var i = 0; i < sections.length; i += 3 ) {
txt += write_classlist( sections[ i ], sections[ i+1 ], sections[ i+2 ] );
}
return write_page( title, txt );
}
function generate_docs_object( name, obj )
{
var fileText = write_page( name,
'Bindings for the ' + name + ' class.<br />' + dump(obj) );
System.writeFile("jsref/" + name.toLowerCase() + ".html", fileText);
}
function generate_docs_nocreate( name )
{
var fileText = write_page( name,
'Bindings for the ' + name + ' class.<br />'
+ 'This class is understood by the interpreter, but cannot be created from scripts.' );
System.writeFile("jsref/" + name.toLowerCase() + ".html", fileText);
}
//
// Document the static objects
//
function document_statics( statics )
{
for ( var idx = 0; idx < statics.length; idx++ ) {
var name = statics[idx];
try
{
var obj = eval( name );
var fileText = write_page( name,
'Bindings for the static ' + name + ' object.' + dump(obj) );
System.writeFile("jsref/" + name.toLowerCase() + ".html", fileText);
}
catch(x)
{
println("Error: " + x );
}
}
}
//
// Build script that will document the constructable objects
//
function document_constructable( objects )
{
for ( var idx = 0; idx < objects.length; idx++ )
{
println('Document class: ' + objects[idx] );
try {
generate_docs_object( objects[idx], Factory.createObject( objects[idx] ));
println(', Success');
}
catch(x) {
println(', Error ' + x );
generate_docs_nocreate( objects[idx] );
nocreate.push( objects[idx] );
}
}
}
////
//// Main
////
var statics = [ 'Factory', 'System', 'Global', 'StdDialog',
'StdAction', 'StdDirs', 'StdIcons', 'Qt' ];
qttps = [];
kdetps = [];
kjsetps = [];
other = [];
nocreate = [];
var expts = [ 'ReferenceError', 'EvalError', 'RangeError', 'TypeError' ];
tps = Factory.types().sort();
statics.sort();
expts.sort();
cons = Factory.constructors().sort();
cons += 'Part';
for ( var i=0; i < tps.length; i++ ) {
if ( /^Q/.test(tps[i]) ) {
qttps.push( tps[i] );
}
else if ( /^KJSEmbed::/.test(tps[i]) ) {
if ( tps[i] != 'KJSEmbed::Bindings::JSDCOPInterface' ) {
kjsetps.push( tps[i] );
}
}
else if ( /^K/.test(tps[i]) ) {
kdetps.push( tps[i] );
}
else {
other.push( tps[i] );
}
}
//
// Generate object reference pages
//
document_constructable( tps );
document_statics( statics );
document_statics( expts );
generate_docs_object( 'TextStream', System.stdin );
generate_docs_object( 'Application', application );
generate_docs_object( 'KJSEmbedPart', part );
generate_docs_object( 'TQListViewItem', new TQListViewItem(new TQListView()) );
generate_docs_object( 'TQCheckListItem', new TQCheckListItem(new TQListView()) );
generate_docs_object( 'TQCanvasText', new TQCanvasText(new TQCanvas()) );
other.push( 'Application' );
other.sort();
//
// Generate index pages
//
index = [ 'Static Objects',
'Statics that are available to scripts as JS objects.',
statics,
'Object Types',
'The non-widget objects that are defined for scripts.',
other,
'KJSEmbed Objects',
'KDE objects that are available to scripts as JS objects.',
kjsetps,
'Qt Objects',
'Qt objects that are available to scripts as JS objects.',
qttps,
'KDE Objects',
'KDE objects that are available to scripts as JS objects.',
kdetps,
'Exception Types',
'Exceptions that are defined for scripts.',
expts,
'Unconstructable Types',
'Known type that scripts cannot create.',
nocreate
];
System.writeFile( "jsref/index.html",
write_classes( 'All Scriptable Objects',
'The full set of objects that can be accessed by scripts.',
index ) );
System.writeFile( "jsref/index-static.html", write_classes( index[0], index[1], ['','',index[2]] ) );
System.writeFile( "jsref/index-objects.html", write_classes( index[3], index[4], ['','',index[5]] ) );
System.writeFile( "jsref/index-kjsembedobjects.html", write_classes( index[6], index[7], ['','',index[8]] ) );
System.writeFile( "jsref/index-qtobjects.html", write_classes( index[9], index[10], ['','',index[11]] ) );
System.writeFile( "jsref/index-kdeobjects.html", write_classes( index[12], index[13], ['','',index[14]] ) );
System.writeFile( "jsref/index-exceptions.html", write_classes( index[15], index[16], ['','',index[17]] ) );
System.writeFile( "jsref/index-nocreate.html", write_classes( index[18], index[19], ['','',index[20]] ) );
System.exit(0);
|