roojs-ui.js
[roojs1] / buildSDK / make_src_highlighted.js
1
2 /**
3  * Make the highlighted docs = needs more work....
4  * 
5  * In the top level Roojs directory.. (you need to change the path of the jstoolkit)
6  * 
7  * 
8  * roolite buildSDK/make_src_highlighted.js -L../rooscript/examples/jstoolkit2 
9  * 
10  * put's the resulting files in docs/symbols/src
11  *  (make sure it exists first..)
12  *
13  * Uses the dependancy order file.. (could do this recursively, it's pretty simple..)
14  * 
15  * <script type="text/javascript">
16  */
17
18 include 'prettyPrint.js'; 
19  
20 function main()
21 {
22     
23     var files = [];
24     var spath = File.getcwd();
25     var flist = File.read(spath+"/buildSDK/dependancy_order.txt" ).split("\n");
26     for(var i = 0; i < flist.length;i++) {
27         var f = flist[i];
28         if (/^\s*\//.test(f) || !/[a-z]+/i.test(f)) {
29             continue;
30         }
31         //println("ADD"+ f.replace(/\./g, '/'));
32         files.push(spath + '/' + f.replace(/\./g, '/').replace(/\s+/g,'')+'.js');
33         
34     }
35     
36      for(var i=0; i < files.length; i++)  {
37         
38         println("reading " +files[i] );
39         if (!File.exists(files[i])) {
40             throw "missing file: " + files[i];
41             continue;
42         }
43         
44         var prettyfile = spath + '/docs/symbols/src/' +files[i].substr(spath.length+1).replace(/\//g, '.').replace(/\.js$/, '.html');
45         // should do timestamp stuff!
46         if (File.exists(prettyfile) &&
47             File.getTimes(prettyfile)[0] > File.getTimes(files[i])[0]
48             ) {
49             File.chmod(prettyfile, 0644);
50             continue;
51         }
52         
53         var str = File.read(files[i]);
54         
55         // probably want do do templating or something here..
56         // we probably want to do some sexy replacement on the comments using our parsed info on the file!? ;)
57         
58         var pretty = toPretty(str);
59         
60         
61         
62         
63         println("write : " + prettyfile);
64         //throw "done";
65         File.write(prettyfile, 
66             '<html><head>' +
67             '<title>' + files[i].substr(spath.length+1) + '</title>' +
68             '<link rel="stylesheet" type="text/css" href="../../../css/highlight-js.css"/>' + 
69             '</head><body class="highlightpage">' +
70             pretty +
71             '</body></html>');
72             
73         File.chmod(prettyfile, 0644);
74     }
75 }
76 main();      
77