PageRenderTime 30ms CodeModel.GetById 14ms app.highlight 11ms RepoModel.GetById 1ms app.codeStats 0ms

/tags/jsdoc_toolkit-2.0.1/jsdoc-toolkit/app/main.js

http://jsdoc-toolkit.googlecode.com/
JavaScript | 74 lines | 63 code | 8 blank | 3 comment | 20 complexity | ebfff31c768caafc073def1c3dbb1576 MD5 | raw file
 1/**
 2 * @version $Id: main.js 570 2008-04-07 23:54:50Z micmath $
 3 */
 4
 5function main() {
 6	IO.include("lib/JSDOC.js");
 7	IO.includeDir("plugins/");
 8	
 9	if (JSDOC.opt.v) LOG.verbose = true;
10	if (JSDOC.opt.o) LOG.out = IO.open(JSDOC.opt.o);
11	
12	if (JSDOC.opt.T) {
13		LOG.inform("JsDoc Toolkit running in test mode at "+new Date()+".");
14		IO.include("frame/Testrun.js");
15		IO.include("test.js");
16	}
17	else {
18		LOG.inform("JsDoc Toolkit main() running at "+new Date()+".");
19		LOG.inform("With options: ");
20		for (var o in JSDOC.opt) {
21			LOG.inform("    "+o+": "+JSDOC.opt[o]);
22		}
23		
24		var jsdoc = new JSDOC.JsDoc();
25		
26		if (JSDOC.opt.Z) { // secret debugging option
27			LOG.warn("So you want to see the data structure, eh? This might hang if you have circular refs...");
28			IO.include("frame/Dumper.js");
29			var symbols = jsdoc.symbolSet.toArray();
30			for (var i = 0, l = symbols.length; i < l; i++) {
31				var symbol = symbols[i];
32				print("// symbol: " + symbol.alias);
33				print(symbol.serialize());
34			}
35		}
36		else {
37			var template = JSDOC.opt.t || System.getProperty("jsdoc.template.dir");
38
39			var handler = jsdoc.symbolSet.handler;
40			if (handler && handler.publish) {
41				handler.publish(jsdoc.symbolSet);
42			}
43			else {
44				if (typeof template != "undefined") {
45					try {
46						load(template+"/publish.js");
47						if (!publish) {
48							LOG.warn("No publish() function is defined in that template so nothing to do.");
49						}
50						else {
51							publish(jsdoc.symbolSet);
52						}
53					}
54					catch(e) {
55						LOG.warn("Sorry, that doesn't seem to be a valid template: "+template+"/publish.js : "+e);
56					}
57				}
58				else {
59					LOG.warn("No template or handlers given. Might as well read the usage notes.");
60					JSDOC.usage();
61				}
62			}
63		}
64	}
65	
66	if (LOG.warnings.length) {
67		print(LOG.warnings.length+" warning"+(LOG.warnings.length != 1? "s":"")+".");
68	}
69	
70	if (LOG.out) {
71		LOG.out.flush();
72		LOG.out.close();
73	}
74}