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);
40 Options.LOG.inform("JsDoc Toolkit main() running at "+new Date()+".");
41 Options.LOG.inform("With options: ");
42 for (var o in JSDOC.opt) {
43 JSDOC.opt.LOG.inform(" "+o+": "+JSDOC.opt[o]);
46 var jsdoc = new JSDOC.JsDoc();
48 if (JSDOC.opt.hasOwnProperty('Z')) { // secret debugging option
49 JSDOC.opt.LOG.warn("So you want to see the data structure, eh? This might hang if you have circular refs...");
50 //IO.include("frame/Dumper.js");
51 var symbols = jsdoc.symbolSet.toArray();
52 for (var i = 0, l = symbols.length; i < l; i++) {
53 var symbol = symbols[i];
54 print("// symbol: " + symbol.alias);
55 print(symbol.serialize());
59 var template = JSDOC.opt.t; // || System.getProperty("jsdoc.template.dir");
60 println("Template: " + JSDOC.opt.t);
62 function includeJs(fn)
64 return "include '" + fn +"';";
67 eval(includeJs(template + 'publish.js'));
69 JSDOC.publish = publish;
71 //var handler = jsdoc.symbolSet.handler;
72 //if (handler && handler.publish) {
73 // handler.publish(jsdoc.symbolSet);
76 if (typeof(template) != "undefined") {
77 // publish is in template!!
78 JSDOC.publish(jsdoc.symbolSet);
82 JSDOC.opt.LOG.warn("No template or handlers given. Might as well read the usage notes.");
89 if (JSDOC.opt.LOG.warnings.length) {
90 print(JSDOC.opt.LOG.warnings.length+" warning"+(JSDOC.opt.LOG.warnings.length != 1? "s":"")+".");
93 if (JSDOC.opt.LOG.out) {
94 JSDOC.opt.LOG.out.flush();
95 JSDOC.opt.LOG.out.close();
110 apply : function(o, c, defaults){
112 // no "this" reference for friendly out of scope calls
113 JSDOC.apply(o, defaults);
115 if(o && c && typeof c == 'object'){
125 * Qdump is used to generated cache dumps of objects
126 * @arg mixed t - object/array to dump
127 * @arg string prefix output with
128 * @arg string suffix output with
129 * @arg mixed defaults for the object - so they are not dumped..
132 toQDump : function(t, pref, suf, defs)
134 //println("got ToDump: " + pref +" ??? " + suf);
135 //var ret = "JSDOC.Symbol.fromDump(";
137 defs = (typeof(defs) == "undefined") ? {} : defs;
139 var isAr = t.constructor == Array;
143 // println("dump: " + i + " : " +typeof(t[i]));
146 k = typeof(i) == "number" ? i +":" : i.toSource()+":" ;
148 if (typeof(i) != "number") {
162 //if ((typeof(defs[i]) != 'undefined') && (v.toSource() == defs[i]).toSource()) {
180 if (!v.length) { // ?? skip empty!!
188 qret += k + v.toSource();
208 // println(k +"?:" + (v.constructor == Array ? "ARRAY" : "OBJECT"));
211 // what about raw objects...
212 if (v.constructor == Array) {
213 //println("ARRAYLEN:" + v.length);
214 var toadd = JSDOC.toQDump(v, '[', ']');
216 println("Array: " + toadd);
227 //println("AFT AR:" + qret);
230 if (v.constructor == Object) {
231 var toadd = JSDOC.toQDump(v, '{', '}');
240 //println("AFT AR:" + qret);
243 //println("v:toQdump" + typeof(v['toQDump']));
244 if (typeof(v['toQDump']) != "undefined") {
249 qret += k + v.toQDump(v);
252 println("SKIP " + i + " : " +typeof(t[i]) + ":" + t[i].toSource());
256 println("SKIP " + i + " : " +typeof(t[i]) );
264 return pref + qret + suf;
268 * Depreciated - use Script.prettyDump() - cant remember real name..
273 prettyDump : function(src)
275 // println("tidy SRC");
276 return Script.prettyDump(src);
278 var ar = Script.tokenize(src);
279 println("tidy" + ar.length);
284 // this is reallllllllly sloooooowwwwww!!! = perhaps we should just dump it straight to the file!!!
286 for( var i =0 ;i< ar.length; i++) {
288 //println(ar[i].toSource());
290 //println("tidy" + i + ":" + tok.val);
291 if ( (tok.val == '{') || (tok.val == '[') || (tok.val == '(') ) {
297 if ( (tok.val == '}') || (tok.val == ']') || (tok.val == ')') ) {
299 indent = indent.substring(2); // strip spaces..
300 if (i < (ar.length-1) && ar[i+1].val == ',') {
305 eret += (lbr ? "" : "\n" + indent ) + tok.val ;
309 if ( (tok.val == ',')) {
315 eret += "\n" + indent;