JSDOC/Options.js
[gnome.introspection-doc-generator] / JSDOC / Options.js
1 //<script type="text/javascript">
2 /**
3  * Options management...
4  */
5 XObject = import.XObject.XObject;
6 File = import.File.File;
7
8 Options = {
9     
10     argTypes : {
11         "baseDir"       :  'Base Directory (root directory of code)',
12         "target"        :  'Target Directory (where html files go)',
13         "cacheDirectory": 'Cached Files Directory',
14         "conf"          : 'Read From a Configuration file',       // was c. - configuration file.. - parsed with JSON.parse
15         "template"      : 'Template Directory',   // was t.
16         // "recurse": false,   // was r. - not supported..
17         "ext"           :  'Extension of code files to read (normally js)',   // was x.
18         "publishExt"    : 'Extension of html files to write (normally html)',
19         //"private": '',   // was p
20         //"allfunctions": '',   // was a
21         //"encoding": '',   // was e.
22         //"nocode": '',  // was n
23         //"out": '',   // was o.
24         //"suppress": '',  // was s ??? used?
25         "outputSource" : 'Output the Source code to symbols/src/* (boolean)',
26         //"testmode": '',  // was t
27         "help"          : 'Show help',   // was h
28         "verbose"       : 'Show verbose messages',   // was v
29         //"disablecache": '',   // was C -- not needed? - see if cacheDirectory was set..
30         //"define" : [],   // was D.
31         //"handler" : [],  // was H -- not supported..
32     }
33     
34     
35     "baseDir" :  '',  // base directory - 
36     "target" : '',   // was d. ?? source directory (needed to put temporary files..)
37     "cacheDirectory" : '',
38     "conf" : '',       // was c. - configuration file.. - parsed with JSON.parse
39     "template": '',   // was t.
40     // "recurse": false,   // was r. - not supported..
41     "ext": 'js',   // was x.
42     "publishExt" : 'html',
43     "private": '',   // was p
44     "allfunctions": '',   // was a
45     "encoding": '',   // was e.
46     "nocode": '',  // was n
47     "out": '',   // was o.
48     "suppress": '',  // was s ??? used?
49     "outputSource" : true,
50     "testmode": '',  // was t
51     "help": '',   // was h
52     "verbose": '',   // was v
53     "disablecache": '',   // was C
54     "define" : [],   // was D.
55     "handler" : [],  // was H -- not supported..
56     LOG : {
57         warn : function(str) {
58             print("Warn: " +str );
59         },
60         inform : function(str) {
61             print("Inform: " +str );
62         },
63         close : function() { },
64         flush : function() { },
65         out: false,
66         warnings : [],
67         verbose : false    
68     },
69     init : function()
70     {
71         this.LOG.verbose = this.verbose;
72         
73         
74         if (this.conf) {
75             XObject.extend(this, JSON.parse(File.read(this.conf)));;
76         }
77         // help ?? -- usage..
78         
79         if (!this.src.length) {
80             throw {
81                 name: "ArgumentError", 
82                 message: "No source directories specified" 
83             };
84         }
85         if (!this.template) {
86             throw {
87                 name: "ArgumentError", 
88                 message: "No template specified" 
89             };
90         }
91          
92         if (!this.target) {
93             throw {
94                 name: "ArgumentError", 
95                 message: "No directory specified" 
96             };
97         }
98         f (!this.baseDir) {
99             throw {
100                 name: "ArgumentError", 
101                 message: "No baseDir specified" 
102             };
103         }
104         
105         // should cacheDirectory be a subdirectory of target??
106         // if not set..
107         if (!this.cacheDirectory) {
108             throw {
109                 name: "ArgumentError", 
110                 message: "No cacheDirectory specified" 
111             };
112         }
113         
114     },
115     /** 
116      *  this might be nice as a standard bit of code..
117      */
118        
119     parseArgv : function() 
120     {
121         
122         var args = Array.prototype.slice.call(Seed.argv);
123         args.shift(); //seed
124         args.shift(); // pack.js
125         
126         
127         
128         
129         
130
131         for(var i =0; i < args.length;i++) {
132             if (args[i] == '-o') {
133                 cfg.target = args[i+1];
134                 i++;
135                 continue;
136             }
137             if (args[i] == '-O') {
138                 cfg.debugTarget = args[i+1];
139                 i++;
140                 continue;
141             }
142             if (args[i] == '-t') {
143                 cfg.translateJSON = args[i+1];
144                 i++;
145                 continue;
146             }
147             if (args[i] == '-w') {
148                 cfg.tmpDir = args[i+1];
149                 i++;
150                 continue;
151             }
152             if (args[i] == '-p') {
153                 cfg.prefix = args[i+1];
154                 i++;
155                 continue;
156             }
157          
158             if (args[i] == '-C') {
159                 cfg.cleanup = false;
160                 continue;
161             }
162             if (args[i] == '-f') {
163                 cfg.srcfile = args[i+1];
164                 i++;
165                 continue;
166             }
167             if (cfg.files.indexOf(args[i]) > -1) {
168                 continue; // remove dupes.
169             }
170             cfg.files.push(args[i]);
171         }
172     
173 }