sbin/res/jsdoc/app/main.js
author hamidouk
Fri, 23 Dec 2011 11:38:47 +0100
branchjsdoc
changeset 520 fe008e95a716
permissions -rw-r--r--
added jsdoc support, and a script to generate the docs. Also added sample documentation for the IriSP.widget base class.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
520
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
     1
/**
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
     2
 * @version $Id: main.js 818 2009-11-08 14:51:41Z micmath $
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
     3
 */
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
     4
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
     5
function main() {
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
     6
	IO.include("lib/JSDOC.js");
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
     7
	IO.includeDir("plugins/");
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
     8
	
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
     9
	// process the options
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    10
	
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    11
	// the -c option: options are defined in a configuration file
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    12
	if (JSDOC.opt.c) {
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    13
		eval("JSDOC.conf = " + IO.readFile(JSDOC.opt.c));
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    14
		
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    15
		LOG.inform("Using configuration file at '"+JSDOC.opt.c+"'.");
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    16
		
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    17
		for (var c in JSDOC.conf) {
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    18
			if (c !== "D" && !defined(JSDOC.opt[c])) { // commandline overrules config file
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    19
				JSDOC.opt[c] = JSDOC.conf[c];
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    20
			}
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    21
		}
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    22
		
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    23
		if (typeof JSDOC.conf["_"] != "undefined") {
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    24
			JSDOC.opt["_"] = JSDOC.opt["_"].concat(JSDOC.conf["_"]);
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    25
		}
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    26
		
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    27
		LOG.inform("With configuration: ");
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    28
		for (var o in JSDOC.opt) {
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    29
			LOG.inform("    "+o+": "+JSDOC.opt[o]);
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    30
		}
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    31
	}
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    32
	
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    33
	// be verbose
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    34
	if (JSDOC.opt.v) LOG.verbose = true;
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    35
	
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    36
	// send log messages to a file
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    37
	if (JSDOC.opt.o) LOG.out = IO.open(JSDOC.opt.o);
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    38
	
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    39
	// run the unit tests
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    40
	if (JSDOC.opt.T) {
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    41
		LOG.inform("JsDoc Toolkit running in test mode at "+new Date()+".");
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    42
		IO.include("frame/Testrun.js");
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    43
		IO.include("test.js");
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    44
	}
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    45
	else {
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    46
		// a template must be defined and must be a directory path
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    47
		if (!JSDOC.opt.t && System.getProperty("jsdoc.template.dir")) {
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    48
			JSDOC.opt.t = System.getProperty("jsdoc.template.dir");
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    49
		}
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    50
		if (JSDOC.opt.t && SYS.slash != JSDOC.opt.t.slice(-1)) {
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    51
			JSDOC.opt.t += SYS.slash;
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    52
		}
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    53
		
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    54
		// verbose messages about the options we were given
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    55
		LOG.inform("JsDoc Toolkit main() running at "+new Date()+".");
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    56
		LOG.inform("With options: ");
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    57
		for (var o in JSDOC.opt) {
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    58
			LOG.inform("    "+o+": "+JSDOC.opt[o]);
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    59
		}
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    60
		
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    61
		// initialize and build a symbolSet from your code
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    62
		JSDOC.JsDoc();
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    63
		
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    64
		// debugger's option: dump the entire symbolSet produced from your code
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    65
		if (JSDOC.opt.Z) {
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    66
			LOG.warn("So you want to see the data structure, eh? This might hang if you have circular refs...");
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    67
			IO.include("frame/Dumper.js");
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    68
			var symbols = JSDOC.JsDoc.symbolSet.toArray();
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    69
			for (var i = 0, l = symbols.length; i < l; i++) {
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    70
				var symbol = symbols[i];
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    71
				print("// symbol: " + symbol.alias);
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    72
				print(symbol.serialize());
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    73
			}
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    74
		}
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    75
		else {
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    76
			if (typeof JSDOC.opt.t != "undefined") {
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    77
				try {
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    78
					// a file named "publish.js" must exist in the template directory
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    79
					load(JSDOC.opt.t+"publish.js");
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    80
					
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    81
					// and must define a function named "publish"
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    82
					if (!publish) {
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    83
						LOG.warn("No publish() function is defined in that template so nothing to do.");
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    84
					}
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    85
					else {
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    86
						// which will be called with the symbolSet produced from your code
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    87
						publish(JSDOC.JsDoc.symbolSet);
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    88
					}
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    89
				}
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    90
				catch(e) {
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    91
					LOG.warn("Sorry, that doesn't seem to be a valid template: "+JSDOC.opt.t+"publish.js : "+e);
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    92
				}
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    93
			}
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    94
			else {
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    95
				LOG.warn("No template given. Might as well read the usage notes.");
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    96
				JSDOC.usage();
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    97
			}
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    98
		}
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    99
	}
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
   100
	
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
   101
	// notify of any warnings
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
   102
	if (!JSDOC.opt.q && LOG.warnings.length) {
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
   103
		print(LOG.warnings.length+" warning"+(LOG.warnings.length != 1? "s":"")+".");
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
   104
	}
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
   105
	
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
   106
	// stop sending log messages to a file
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
   107
	if (LOG.out) {
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
   108
		LOG.out.flush();
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
   109
		LOG.out.close();
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
   110
	}
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
   111
}