1 //<script type="text/javascript">
3 * Options management...
5 XObject = import.XObject.XObject;
6 File = import.File.File;
11 "--help" : 'Show help', // was h
12 "help": false, // was h;se
16 // options get defined like this..
17 "--src" : "source directory (either absolute - starts with "/" or relative " +
18 "- without, in which case it's added to baseDir"
19 "--baseDir" : 'Base Directory (root directory of code)',
20 "--target" : 'Target Directory (where html files go)',
21 "--cacheDirectory": 'Cached Files Directory',
22 "--conf" : 'Read From a Configuration file', // was c. - configuration file.. - parsed with JSON.parse
23 "--template" : 'Template Directory', // was t.
24 // "recurse": false, // was r. - not supported..
25 "--ext" : 'Extension of code files to read (normally js)', // was x.
26 "--publishExt" : 'Extension of html files to write (normally html)',
27 //"private": '', // was p
28 //"allfunctions": '', // was a
29 //"encoding": '', // was e.
30 //"nocode": '', // was n
31 //"out": '', // was o.
32 //"suppress": '', // was s ??? used?
33 "--outputSource" : 'Output the Source code to symbols/src/* (boolean)',
34 //"testmode": '', // was t
36 "--verbose" : 'Show verbose messages', // was v
37 //"disablecache": '', // was C -- not needed? - see if cacheDirectory was set..
38 //"define" : [], // was D.
39 //"handler" : [], // was H -- not supported..
42 // and now the defaults.. (which type can be infered from..)
44 "baseDir" : '', // base directory -
45 "target" : '', // was d. ?? source directory (needed to put temporary files..)
46 "cacheDirectory" : '',
47 "conf" : '', // was c. - configuration file.. - parsed with JSON.parse
48 "template": '', // was t.
49 // "recurse": false, // was r. - not supported..
50 "ext": 'js', // was x.
51 "publishExt" : 'html',
52 "private": '', // was p
53 "allfunctions": '', // was a
54 "encoding": '', // was e.
55 "nocode": '', // was n
57 "suppress": '', // was s ??? used?
58 "outputSource" : true,
59 "testmode": '', // was t
61 "verbose": '', // was v
62 "disablecache": '', // was C
63 "define" : [], // was D.
64 "handler" : [], // was H -- not supported..
66 warn : function(str) {
67 print("Warn: " +str );
69 inform : function(str) {
70 print("Inform: " +str );
72 close : function() { },
73 flush : function() { },
86 // the reset of this is specific to JSDOC - and can not be moved to a generic handler..
89 this.LOG.verbose = this.verbose;
91 // this is most likely to come from the command line..
93 XObject.extend(this, JSON.parse(File.read(this.conf)));;
98 name: "ArgumentError",
99 message: "No baseDir specified"
102 if (!this.src.length) {
104 name: "ArgumentError",
105 message: "No source directories specified"
108 // append full path to source directories.
110 this.src.forEach(function(v, i) {
112 this.src[i] = _this.baseDir + '/' + v;
114 if (File.isDirectory(this.src[i])) {
116 name: "ArgumentError",
117 message: "invalid Source Directory : " + v;
123 if (!this.template) {
125 name: "ArgumentError",
126 message: "No template Directory specified"
132 name: "ArgumentError",
133 message: "No directory specified"
138 // should cacheDirectory be a subdirectory of target??
140 //if (!this.cacheDirectory) {
142 // name: "ArgumentError",
143 // message: "No cacheDirectory specified"
149 * this might be nice as a standard bit of code..
152 parseArgv : function()
155 var args = Array.prototype.slice.call(Seed.argv);
157 args.shift(); // pack.js
159 for(var i =0; i < args.length;i++) {
160 if (args[i].substring(0,2) != '--') {
163 name: "ArgumentError",
164 message: "Unknown argument: " + args[i]
167 var a = arg[i].substring(2);
168 if (typeof(argTypes[arg[i]]) == 'undefined') {
170 name: "ArgumentError",
171 message: "Unknown argument: " + args[i]
175 if (typeof(this[a]) == 'string') {
180 if (typeof(this[a]) == 'boolean') {
181 if (['false', 'true'].indexOf(args[i+1]) < 0) {
183 name: "ArgumentError",
184 message: "Unknown value for : " + args[i] + ' : ' + args[i+1]
187 this[a] = args[i+1] == 'true';
191 if (typeof(this[a]) == 'object') { // tecnically an array.
193 while(i < args.length)
195 if (args[i].substring(0,2) != '--'){
199 this[a].push(args[i]);
204 name: "ArgumentError",
205 message: "Do not know how to handle: " + a
215 print (""Usage seed jsdocbulid.js /var/www/seed [Gtk] \n": ");
217 if (i.substring(0,2) != '--') {
220 print( i + ' ARG : ' + this[i]);