1 //<script type="text/javascript">
3 * Options management...
5 XObject = imports.XObject.XObject;
6 File = imports.File.File;
11 "--help" : 'Show help', // was h
12 "help": false, // was h;se
15 // configurable settings.. -
16 "usage" : "Usage seed jsdocbuild.js OPTIONS \n",
19 // options get defined like this..
20 "--src" : "source directory (either absolute - starts with "/" or relative " +
21 "- without, in which case it's added to baseDir",
22 "--exclude-src" : 'Ex',
23 "--baseDir" : 'Base Directory (root directory of code)',
24 "--target" : 'Target Directory (where html files go)',
25 "--cacheDirectory": 'Cached Files Directory',
26 "--conf" : 'Read From a Configuration file', // was c. - configuration file.. - parsed with JSON.parse
27 "--templateDir" : 'Template Directory', // was t.
28 // "recurse": false, // was r. - not supported..
29 "--ext" : 'Extension of code files to read (normally js)', // was x.
30 "--publishExt" : 'Extension of html files to write (normally html)',
31 //"private": '', // was p
32 //"allfunctions": '', // was a
33 //"encoding": '', // was e.
34 //"nocode": '', // was n
35 //"out": '', // was o.
36 //"suppress": '', // was s ??? used?
37 "--outputSource" : 'Output the Source code to symbols/src/* (boolean)',
38 //"testmode": '', // was t
40 "--verbose" : 'Show verbose messages', // was v
41 //"disablecache": '', // was C -- not needed? - see if cacheDirectory was set..
42 //"define" : [], // was D.
43 //"handler" : [], // was H -- not supported..
46 // and now the defaults.. (which type can be infered from..)
49 "baseDir" : '', // base directory -
50 "target" : '', // was d. ?? source directory (needed to put temporary files..)
51 "cacheDirectory" : '',
52 "conf" : '', // was c. - configuration file.. - parsed with JSON.parse
53 "templateDir": '', // was t.
54 // "recurse": false, // was r. - not supported..
55 "ext": 'js', // was x.
56 "publishExt" : 'html',
57 "private": '', // was p
58 "allfunctions": '', // was a
59 "encoding": '', // was e.
60 "nocode": '', // was n
62 "suppress": '', // was s ??? used?
63 "outputSource" : true,
64 "testmode": '', // was t
66 "verbose": '', // was v
67 "disablecache": '', // was C
68 "define" : [], // was D.
69 "handler" : [], // was H -- not supported..
71 warn : function(str) {
72 print("Warn: " +str );
74 inform : function(str) {
75 print("Inform: " +str );
77 close : function() { },
78 flush : function() { },
91 // the reset of this is specific to JSDOC - and can not be moved to a generic handler..
94 this.LOG.verbose = this.verbose;
96 if (!this.baseDir) { // should we set this to cwd?
98 name: "ArgumentError",
99 message: "No baseDir specified"
103 // this is most likely to come from the command line..
105 var conf = this.conf[0] == '/' ? this.conf : this.baseDir + '/' + this.conf;
107 XObject.extend(this, JSON.parse(File.read(conf)));;
109 // help ?? -- usage..
111 if (!this.src.length) {
113 name: "ArgumentError",
114 message: "No source directories specified"
117 // append full path to source directories.
121 src.forEach(function(v, i) {
122 if (!v.length || v[0] != '/') {
123 v = _this.baseDir + (v.length ? '/' + v : '');
125 if (!File.isDirectory(v)) {
127 name: "ArgumentError",
128 message: "invalid Source Directory : " + v
135 if (!this.templateDir) {
137 name: "ArgumentError",
138 message: "No templateDir Directory specified"
141 if (this.templateDir[0] !='/') {
142 this.templateDir = this.baseDir + '/' + this.templateDir;
148 name: "ArgumentError",
149 message: "No directory specified"
154 // should cacheDirectory be a subdirectory of target??
156 //if (!this.cacheDirectory) {
158 // name: "ArgumentError",
159 // message: "No cacheDirectory specified"
165 * this might be nice as a standard bit of code..
168 parseArgv : function()
171 var args = Array.prototype.slice.call(Seed.argv);
173 args.shift(); // pack.js
175 for(var i =0; i < args.length;i++) {
176 if (args[i].substring(0,2) != '--') {
179 name: "ArgumentError",
180 message: "Unknown argument: " + args[i]
183 var a = args[i].substring(2);
184 if (typeof(this[args[i]]) == 'undefined') {
186 name: "ArgumentError",
187 message: "Unknown argument: " + args[i]
191 if (typeof(this[a]) == 'string') {
196 if (typeof(this[a]) == 'boolean') {
197 if (['false', 'true'].indexOf(args[i+1]) < 0) {
199 name: "ArgumentError",
200 message: "Unknown value for : " + args[i] + ' : ' + args[i+1]
203 this[a] = args[i+1] == 'true';
207 if (typeof(this[a]) == 'object') { // tecnically an array.
209 while(i < args.length)
211 if (args[i].substring(0,2) != '--'){
215 this[a].push(args[i]);
220 name: "ArgumentError",
221 message: "Do not know how to handle: " + a
233 if (i.substring(0,2) != '--') {
236 print( i + ' ARG : ' + this[i]);