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