1 //<script type="text/javascript">
3 This is the main container for the JSDOC application.
7 Options = import.Options.Options;
8 XObject = import.XObject.XObject;
10 /****************** INCLUDES ARE ALL AT THE BOTTOM OF THIS FILE!!!!! *******************/
12 // should not realy be here -- or anywhere...??
22 * apply properties to an object
24 * @param object to get properties (eg. JSDOC.Token.prototype)
25 * @param object of properties, - eg. a list of all the methods
26 * @param default (optional) -- no idea :)
30 build : function (opts)
33 XObject.extend(Options, opts);
37 if (JSDOC.opt.v) JSDOC.opt.LOG.verbose = true;
38 if (JSDOC.opt.o) JSDOC.opt.LOG.out = IO.open(JSDOC.opt.o);
41 //JSDOC.opt.LOG.inform("JsDoc Toolkit running in test mode at "+new Date()+".");
42 //IO.include("frame/Testrun.js");
43 //IO.include("test.js");
46 JSDOC.opt.LOG.inform("JsDoc Toolkit main() running at "+new Date()+".");
47 JSDOC.opt.LOG.inform("With options: ");
48 for (var o in JSDOC.opt) {
49 JSDOC.opt.LOG.inform(" "+o+": "+JSDOC.opt[o]);
52 var jsdoc = new JSDOC.JsDoc();
54 if (JSDOC.opt.hasOwnProperty('Z')) { // secret debugging option
55 JSDOC.opt.LOG.warn("So you want to see the data structure, eh? This might hang if you have circular refs...");
56 //IO.include("frame/Dumper.js");
57 var symbols = jsdoc.symbolSet.toArray();
58 for (var i = 0, l = symbols.length; i < l; i++) {
59 var symbol = symbols[i];
60 print("// symbol: " + symbol.alias);
61 print(symbol.serialize());
65 var template = JSDOC.opt.t; // || System.getProperty("jsdoc.template.dir");
66 println("Template: " + JSDOC.opt.t);
68 function includeJs(fn)
70 return "include '" + fn +"';";
73 eval(includeJs(template + 'publish.js'));
75 JSDOC.publish = publish;
77 //var handler = jsdoc.symbolSet.handler;
78 //if (handler && handler.publish) {
79 // handler.publish(jsdoc.symbolSet);
82 if (typeof(template) != "undefined") {
83 // publish is in template!!
84 JSDOC.publish(jsdoc.symbolSet);
88 JSDOC.opt.LOG.warn("No template or handlers given. Might as well read the usage notes.");
95 if (JSDOC.opt.LOG.warnings.length) {
96 print(JSDOC.opt.LOG.warnings.length+" warning"+(JSDOC.opt.LOG.warnings.length != 1? "s":"")+".");
99 if (JSDOC.opt.LOG.out) {
100 JSDOC.opt.LOG.out.flush();
101 JSDOC.opt.LOG.out.close();
116 apply : function(o, c, defaults){
118 // no "this" reference for friendly out of scope calls
119 JSDOC.apply(o, defaults);
121 if(o && c && typeof c == 'object'){
131 * Qdump is used to generated cache dumps of objects
132 * @arg mixed t - object/array to dump
133 * @arg string prefix output with
134 * @arg string suffix output with
135 * @arg mixed defaults for the object - so they are not dumped..
138 toQDump : function(t, pref, suf, defs)
140 //println("got ToDump: " + pref +" ??? " + suf);
141 //var ret = "JSDOC.Symbol.fromDump(";
143 defs = (typeof(defs) == "undefined") ? {} : defs;
145 var isAr = t.constructor == Array;
149 // println("dump: " + i + " : " +typeof(t[i]));
152 k = typeof(i) == "number" ? i +":" : i.toSource()+":" ;
154 if (typeof(i) != "number") {
168 //if ((typeof(defs[i]) != 'undefined') && (v.toSource() == defs[i]).toSource()) {
186 if (!v.length) { // ?? skip empty!!
194 qret += k + v.toSource();
214 // println(k +"?:" + (v.constructor == Array ? "ARRAY" : "OBJECT"));
217 // what about raw objects...
218 if (v.constructor == Array) {
219 //println("ARRAYLEN:" + v.length);
220 var toadd = JSDOC.toQDump(v, '[', ']');
222 println("Array: " + toadd);
233 //println("AFT AR:" + qret);
236 if (v.constructor == Object) {
237 var toadd = JSDOC.toQDump(v, '{', '}');
246 //println("AFT AR:" + qret);
249 //println("v:toQdump" + typeof(v['toQDump']));
250 if (typeof(v['toQDump']) != "undefined") {
255 qret += k + v.toQDump(v);
258 println("SKIP " + i + " : " +typeof(t[i]) + ":" + t[i].toSource());
262 println("SKIP " + i + " : " +typeof(t[i]) );
270 return pref + qret + suf;
274 * Depreciated - use Script.prettyDump() - cant remember real name..
279 prettyDump : function(src)
281 // println("tidy SRC");
282 return Script.prettyDump(src);
284 var ar = Script.tokenize(src);
285 println("tidy" + ar.length);
290 // this is reallllllllly sloooooowwwwww!!! = perhaps we should just dump it straight to the file!!!
292 for( var i =0 ;i< ar.length; i++) {
294 //println(ar[i].toSource());
296 //println("tidy" + i + ":" + tok.val);
297 if ( (tok.val == '{') || (tok.val == '[') || (tok.val == '(') ) {
303 if ( (tok.val == '}') || (tok.val == ']') || (tok.val == ')') ) {
305 indent = indent.substring(2); // strip spaces..
306 if (i < (ar.length-1) && ar[i+1].val == ',') {
311 eret += (lbr ? "" : "\n" + indent ) + tok.val ;
315 if ( (tok.val == ',')) {
321 eret += "\n" + indent;