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     "baseDir" :  '',  // base directory - 
11     "target" : '',   // was d. ?? source directory (needed to put temporary files..)
12     "cacheDirectory" : '',
13     "conf" : '',       // was c. - configuration file.. - parsed with JSON.parse
14     "template": '',   // was t.
15     // "recurse": false,   // was r. - not supported..
16     "ext": '',   // was x.
17     "publishExt" : 'html',
18     "private": '',   // was p
19     "allfunctions": '',   // was a
20     "encoding": '',   // was e.
21     "nocode": '',  // was n
22     "out": '',   // was o.
23     "suppress": '',  // was s ??? used?
24     "outputSource" : true,
25     "testmode": '',  // was t
26     "help": '',   // was h
27     "verbose": '',   // was v
28     "disablecache": '',   // was C
29     "define" : [],   // was D.
30     "handler" : [],  // was H -- not supported..
31     LOG : {
32         warn : function(str) {
33             print("Warn: " +str );
34         },
35         inform : function(str) {
36             print("Inform: " +str );
37         },
38         close : function() { },
39         flush : function() { },
40         out: false,
41         warnings : [],
42         verbose : false    
43     },
44     init : function()
45     {
46         this.LOG.verbose = this.verbose;
47         
48         
49         if (this.conf) {
50             XObject.extend(this, JSON.parse(File.read(this.conf)));;
51         }
52         // help ?? -- usage..
53         
54         if (!this.src.length) {
55             throw {
56                 name: "ArgumentError", 
57                 message: "No source directories specified" 
58             };
59         }
60         if (!this.template) {
61             throw {
62                 name: "ArgumentError", 
63                 message: "No template specified" 
64             };
65         }
66          
67         if (!this.target) {
68             throw {
69                 name: "ArgumentError", 
70                 message: "No directory specified" 
71             };
72         }
73         f (!this.baseDir) {
74             throw {
75                 name: "ArgumentError", 
76                 message: "No baseDir specified" 
77             };
78         }
79         
80         // should cacheDirectory be a subdirectory of target??
81         // if not set..
82         if (!this.cacheDirectory) {
83             throw {
84                 name: "ArgumentError", 
85                 message: "No cacheDirectory specified" 
86             };
87         }
88         
89     },
90     /** 
91      *  this might be nice as a standard bit of code..
92      */
93        
94     parseArgv : function() 
95     {
96         
97         var args = Array.prototype.slice.call(Seed.argv);
98         args.shift(); //seed
99         args.shift(); // pack.js
100         
101         
102         
103         
104         
105
106         for(var i =0; i < args.length;i++) {
107             if (args[i] == '-o') {
108                 cfg.target = args[i+1];
109                 i++;
110                 continue;
111             }
112             if (args[i] == '-O') {
113                 cfg.debugTarget = args[i+1];
114                 i++;
115                 continue;
116             }
117             if (args[i] == '-t') {
118                 cfg.translateJSON = args[i+1];
119                 i++;
120                 continue;
121             }
122             if (args[i] == '-w') {
123                 cfg.tmpDir = args[i+1];
124                 i++;
125                 continue;
126             }
127             if (args[i] == '-p') {
128                 cfg.prefix = args[i+1];
129                 i++;
130                 continue;
131             }
132          
133             if (args[i] == '-C') {
134                 cfg.cleanup = false;
135                 continue;
136             }
137             if (args[i] == '-f') {
138                 cfg.srcfile = args[i+1];
139                 i++;
140                 continue;
141             }
142             if (cfg.files.indexOf(args[i]) > -1) {
143                 continue; // remove dupes.
144             }
145             cfg.files.push(args[i]);
146         }
147     
148 }