1 //<script type="text/javascript">
3 This is the main container for the JSDOC application.
8 XObject = import.XObject.XObject;
9 File = import.File.File;
11 Options = import.Options.Options;
12 Parser = import.Parser.Parser;
14 /****************** INCLUDES ARE ALL AT THE BOTTOM OF THIS FILE!!!!! *******************/
16 // should not realy be here -- or anywhere...??
29 build : function (opts)
32 XObject.extend(Options, opts);
39 Options.LOG.inform("JsDoc Toolkit main() running at "+new Date()+".");
40 Options.LOG.inform("With options: ");
42 if (!File.isDirectory(Options.cacheDirectory)) {
43 File.mkdir(Options.cacheDirectory)
46 Options.srcFiles = this._getSrcFiles();
47 this._parseSrcFiles();
48 this.symbolSet = Parser.symbols;
58 _getSrcFiles : function()
64 ext = JSDOC.opt.x.split(",").map(function($) {return $.toLowerCase()});
67 for (var i = 0; i < JSDOC.opt._.length; i++) {
68 this.srcFiles = this.srcFiles.concat(
69 IO.ls(JSDOC.opt._[i], JSDOC.opt.r).filter(
71 var thisExt = $.split(".").pop().toLowerCase();
72 return (ext.indexOf(thisExt) > -1 || thisExt in JSDOC.handlers); // we're only interested in files with certain extensions
81 _parseSrcFiles : function()
85 for (var i = 0, l = this.srcFiles.length; i < l; i++) {
87 var srcFile = this.srcFiles[i];
90 var cacheFile = Options.cacheDirectory + srcFile.replace(/\//g, '_') + ".cache";
94 if (!Options.disablecache && File.exists(cacheFile)) {
97 var c_mt = File.getTimes(cacheFile);
98 var o_mt = File.getTimes(srcFile);
99 //println(c_mt.toSource());
100 // println(o_mt.toSource());
102 // this check does not appear to work according to the doc's - need to check it out.
104 if (c_mt[0] > o_mt[0]) { // cached time > original time!
105 // use the cached mtimes..
106 var syms = JSON.parse(File.read(cacheFile));
108 throw "Conversion of cache not done yet!";
110 for (var sy in syms) {
111 //println("ADD:" + sy );
112 Parser.symbols.addSymbol(syms[sy]);
120 src = File.read(srcFile);
123 LOG.warn("Can't read source file '"+srcFile+"': "+e.message);
127 // Check to see if there is a handler for this file type
128 // var ext = FilePath.fileExtension(srcFile);
129 // if (JSDOC.handlers[ext]) {
130 // LOG.inform(" Using external handler for '" + ext + "'");
132 // symbols = symbols.concat(JSDOC.handlers[ext].handle(srcFile, src));
133 // symbols.handler = JSDOC.handlers[ext];
136 // The default (JSDOC) handler
137 var tr = new JSDOC.TokenReader();
138 var ts = new JSDOC.TokenStream(tr.tokenize(src));
140 JSDOC.Parser.parse(ts, srcFile);
141 // println("Symbols: " + JSDOC.Parser.symbols.keys().toSource());
142 var outstr = JSDOC.prettyDump(JSDOC.toQDump(JSDOC.Parser.filesSymbols[JSDOC.Symbol.srcFile]._index,'{','}'))
144 //if (outstr.length > 3) {
146 File.write(cacheFile, outstr);
154 JSDOC.Parser.finish();