| author | hamidouk |
| Fri, 23 Dec 2011 11:38:47 +0100 | |
| branch | jsdoc |
| changeset 520 | fe008e95a716 |
| permissions | -rw-r--r-- |
|
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 |
@constructor |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
3 |
@param [opt] Used to override the commandline options. Useful for testing. |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
4 |
@version $Id: JsDoc.js 831 2010-03-09 14:24:56Z micmath $ |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
5 |
*/ |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
6 |
JSDOC.JsDoc = function(/**object*/ opt) { |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
7 |
if (opt) { |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
8 |
JSDOC.opt = opt; |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
9 |
} |
|
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 |
if (JSDOC.opt.h) { |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
12 |
JSDOC.usage(); |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
13 |
quit(); |
|
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 |
|
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
16 |
// defend against options that are not sane |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
17 |
if (JSDOC.opt._.length == 0) { |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
18 |
LOG.warn("No source files to work on. Nothing to do."); |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
19 |
quit(); |
|
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 |
if (JSDOC.opt.t === true || JSDOC.opt.d === true) { |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
22 |
JSDOC.usage(); |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
23 |
} |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
24 |
|
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
25 |
if (typeof JSDOC.opt.d == "string") { |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
26 |
if (!JSDOC.opt.d.charAt(JSDOC.opt.d.length-1).match(/[\\\/]/)) { |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
27 |
JSDOC.opt.d = JSDOC.opt.d+"/"; |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
28 |
} |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
29 |
LOG.inform("Output directory set to '"+JSDOC.opt.d+"'."); |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
30 |
IO.mkPath(JSDOC.opt.d); |
|
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 |
if (JSDOC.opt.e) IO.setEncoding(JSDOC.opt.e); |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
33 |
|
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
34 |
// the -r option: scan source directories recursively |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
35 |
if (typeof JSDOC.opt.r == "boolean") JSDOC.opt.r = 10; |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
36 |
else if (!isNaN(parseInt(JSDOC.opt.r))) JSDOC.opt.r = parseInt(JSDOC.opt.r); |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
37 |
else JSDOC.opt.r = 1; |
|
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 |
// the -D option: define user variables |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
40 |
var D = {}; |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
41 |
if (JSDOC.opt.D) { |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
42 |
for (var i = 0; i < JSDOC.opt.D.length; i++) { |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
43 |
var param = JSDOC.opt.D[i]; |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
44 |
// remove first and last character if both == " |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
45 |
if ( |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
46 |
param.length > 1 |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
47 |
&& param.charAt(0) == '"' |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
48 |
&& param.charAt(param.length-1) == '"' |
|
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 |
param = param.substr(1, param.length-2); |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
51 |
} |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
52 |
var defineParts = param.split(":"); |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
53 |
if (defineParts && defineParts.length > 1) { |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
54 |
for ( var dpIdx = 2; dpIdx < defineParts.length; dpIdx++ ) { |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
55 |
defineParts[1] += ':' + defineParts[dpIdx]; |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
56 |
} |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
57 |
D[defineParts[0]] = defineParts[1]; |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
58 |
} |
|
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 |
JSDOC.opt.D = D; |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
62 |
// combine any conf file D options with the commandline D options |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
63 |
if (defined(JSDOC.conf)) for (var c in JSDOC.conf.D) { |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
64 |
if (!defined(JSDOC.opt.D[c])) { |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
65 |
JSDOC.opt.D[c] = JSDOC.conf.D[c]; |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
66 |
} |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
67 |
} |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
68 |
|
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
69 |
// Give plugins a chance to initialize |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
70 |
if (defined(JSDOC.PluginManager)) { |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
71 |
JSDOC.PluginManager.run("onInit", JSDOC.opt); |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
72 |
} |
|
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 |
JSDOC.opt.srcFiles = JSDOC.JsDoc._getSrcFiles(); |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
75 |
JSDOC.JsDoc._parseSrcFiles(); |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
76 |
JSDOC.JsDoc.symbolSet = JSDOC.Parser.symbols; |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
77 |
} |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
78 |
|
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
79 |
/** |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
80 |
Retrieve source file list. |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
81 |
@returns {String[]} The pathnames of the files to be parsed. |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
82 |
*/ |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
83 |
JSDOC.JsDoc._getSrcFiles = function() { |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
84 |
JSDOC.JsDoc.srcFiles = []; |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
85 |
|
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
86 |
var ext = ["js"]; |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
87 |
if (JSDOC.opt.x) { |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
88 |
ext = JSDOC.opt.x.split(",").map(function($) {return $.toLowerCase()}); |
|
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 |
|
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
91 |
for (var i = 0; i < JSDOC.opt._.length; i++) { |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
92 |
JSDOC.JsDoc.srcFiles = JSDOC.JsDoc.srcFiles.concat( |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
93 |
IO.ls(JSDOC.opt._[i], JSDOC.opt.r).filter( |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
94 |
function($) { |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
95 |
var thisExt = $.split(".").pop().toLowerCase(); |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
96 |
|
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
97 |
if (JSDOC.opt.E) { |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
98 |
for(var n = 0; n < JSDOC.opt.E.length; n++) { |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
99 |
if ($.match(new RegExp(JSDOC.opt.E[n]))) { |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
100 |
LOG.inform("Excluding " + $); |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
101 |
return false; // if the file matches the regex then it's excluded. |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
102 |
} |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
103 |
} |
|
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 |
return (ext.indexOf(thisExt) > -1); // we're only interested in files with certain extensions |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
107 |
} |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
108 |
) |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
109 |
); |
|
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 |
|
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
112 |
return JSDOC.JsDoc.srcFiles; |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
113 |
} |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
114 |
|
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
115 |
JSDOC.JsDoc._parseSrcFiles = function() { |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
116 |
JSDOC.Parser.init(); |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
117 |
for (var i = 0, l = JSDOC.JsDoc.srcFiles.length; i < l; i++) { |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
118 |
var srcFile = JSDOC.JsDoc.srcFiles[i]; |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
119 |
|
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
120 |
if (JSDOC.opt.v) LOG.inform("Parsing file: " + srcFile); |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
121 |
|
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
122 |
try { |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
123 |
var src = IO.readFile(srcFile); |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
124 |
} |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
125 |
catch(e) { |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
126 |
LOG.warn("Can't read source file '"+srcFile+"': "+e.message); |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
127 |
} |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
128 |
|
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
129 |
var tr = new JSDOC.TokenReader(); |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
130 |
var ts = new JSDOC.TokenStream(tr.tokenize(new JSDOC.TextStream(src))); |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
131 |
|
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
132 |
JSDOC.Parser.parse(ts, srcFile); |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
133 |
|
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
134 |
} |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
135 |
JSDOC.Parser.finish(); |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
136 |
|
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
137 |
if (JSDOC.PluginManager) { |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
138 |
JSDOC.PluginManager.run("onFinishedParsing", JSDOC.Parser.symbols); |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
139 |
} |
|
fe008e95a716
added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff
changeset
|
140 |
} |