1 //<script type="text/javascript">
3 This is the main container for the JSDOC application.
8 XObject = imports.XObject.XObject;
9 File = imports.File.File;
11 Options = imports.Options.Options;
12 Parser = imports.Parser.Parser;
14 TokenReader = imports.TokenReader.TokenReader;
15 TokenStream = imports.TokenStream.TokenStream;
16 Symbol = imports.Symbol.Symbol;
17 /****************** INCLUDES ARE ALL AT THE BOTTOM OF THIS FILE!!!!! *******************/
19 // should not realy be here -- or anywhere...??
32 build : function (opts)
35 XObject.extend(Options, opts);
42 Options.LOG.inform("JsDoc Toolkit main() running at "+new Date()+".");
43 Options.LOG.inform("With options: ");
45 if (!File.isDirectory(Options.cacheDirectory)) {
46 File.mkdir(Options.cacheDirectory)
49 Options.srcFiles = this._getSrcFiles();
50 this._parseSrcFiles();
51 this.symbolSet = Parser.symbols;
61 _getSrcFiles : function()
67 ext = JSDOC.opt.x.split(",").map(function($) {return $.toLowerCase()});
70 for (var i = 0; i < JSDOC.opt._.length; i++) {
71 this.srcFiles = this.srcFiles.concat(
72 IO.ls(JSDOC.opt._[i], JSDOC.opt.r).filter(
74 var thisExt = $.split(".").pop().toLowerCase();
75 return (ext.indexOf(thisExt) > -1 || thisExt in JSDOC.handlers); // we're only interested in files with certain extensions
84 _parseSrcFiles : function()
88 for (var i = 0, l = this.srcFiles.length; i < l; i++) {
90 var srcFile = this.srcFiles[i];
93 var cacheFile = Options.cacheDirectory + srcFile.replace(/\//g, '_') + ".cache";
96 // disabled at present!@!!
98 if (false && !Options.disablecache && File.exists(cacheFile)) {
101 var c_mt = File.getTimes(cacheFile);
102 var o_mt = File.getTimes(srcFile);
103 //println(c_mt.toSource());
104 // println(o_mt.toSource());
106 // this check does not appear to work according to the doc's - need to check it out.
108 if (c_mt[0] > o_mt[0]) { // cached time > original time!
109 // use the cached mtimes..
110 var syms = JSON.parse(File.read(cacheFile));
112 throw "Conversion of cache not done yet!";
114 for (var sy in syms) {
115 //println("ADD:" + sy );
116 Parser.symbols.addSymbol(syms[sy]);
124 src = File.read(srcFile);
127 LOG.warn("Can't read source file '"+srcFile+"': "+e.message);
132 var tr = new TokenReader();
133 var ts = new TokenStream(tr.tokenize(src));
135 Parser.parse(ts, srcFile);
137 //var outstr = JSON.stringify(
138 // Parser.filesSymbols[srcFile]._index
140 //File.write(cacheFile, outstr);