sc-docs 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (162) hide show
  1. data/.gitignore +4 -0
  2. data/.gitmodules +3 -0
  3. data/Gemfile +5 -0
  4. data/Gemfile.lock +48 -0
  5. data/LICENSE +21 -0
  6. data/README.md +59 -0
  7. data/bin/sc-docs +5 -0
  8. data/lib/sc_docs.rb +3 -0
  9. data/lib/sc_docs/cli.rb +54 -0
  10. data/lib/sc_docs/docs/Buildfile +8 -0
  11. data/lib/sc_docs/docs/README +8 -0
  12. data/lib/sc_docs/docs/apps/docs/Buildfile +15 -0
  13. data/lib/sc_docs/docs/apps/docs/controllers/classes.js +27 -0
  14. data/lib/sc_docs/docs/apps/docs/controllers/search_controller.js +62 -0
  15. data/lib/sc_docs/docs/apps/docs/controllers/selected_class.js +143 -0
  16. data/lib/sc_docs/docs/apps/docs/core.js +148 -0
  17. data/lib/sc_docs/docs/apps/docs/main.js +41 -0
  18. data/lib/sc_docs/docs/apps/docs/models/class.js +63 -0
  19. data/lib/sc_docs/docs/apps/docs/models/entity.js +29 -0
  20. data/lib/sc_docs/docs/apps/docs/models/method.js +79 -0
  21. data/lib/sc_docs/docs/apps/docs/models/property.js +48 -0
  22. data/lib/sc_docs/docs/apps/docs/resources/images/method_icon.png +0 -0
  23. data/lib/sc_docs/docs/apps/docs/resources/images/property_icon.png +0 -0
  24. data/lib/sc_docs/docs/apps/docs/resources/loading.rhtml +9 -0
  25. data/lib/sc_docs/docs/apps/docs/resources/main_page.css +156 -0
  26. data/lib/sc_docs/docs/apps/docs/resources/main_page.js +91 -0
  27. data/lib/sc_docs/docs/apps/docs/resources/templates/details.handlebars +81 -0
  28. data/lib/sc_docs/docs/apps/docs/resources/templates/extensions/signature.js +0 -0
  29. data/lib/sc_docs/docs/apps/docs/system/jquery_ui.js +62 -0
  30. data/lib/sc_docs/docs/apps/docs/system/showdown.js +1297 -0
  31. data/lib/sc_docs/docs/apps/docs/theme.js +29 -0
  32. data/lib/sc_docs/docs/apps/docs/views/detail_list.js +24 -0
  33. data/lib/sc_docs/docs/apps/docs/views/master_list.js +35 -0
  34. data/lib/sc_docs/docs/apps/docs/views/methods_collection.js +80 -0
  35. data/lib/sc_docs/docs/apps/docs/views/properties_collection.js +9 -0
  36. data/lib/sc_docs/generator.rb +145 -0
  37. data/lib/sc_docs/server.rb +21 -0
  38. data/lib/sc_docs/templates/docs.sproutcore.com/allclasses.tmpl +31 -0
  39. data/lib/sc_docs/templates/docs.sproutcore.com/allfiles.tmpl +66 -0
  40. data/lib/sc_docs/templates/docs.sproutcore.com/class.tmpl +437 -0
  41. data/lib/sc_docs/templates/docs.sproutcore.com/index.tmpl +52 -0
  42. data/lib/sc_docs/templates/docs.sproutcore.com/output/css/api.css +619 -0
  43. data/lib/sc_docs/templates/docs.sproutcore.com/output/img/apidocs.jpg +0 -0
  44. data/lib/sc_docs/templates/docs.sproutcore.com/output/img/apidocs.png +0 -0
  45. data/lib/sc_docs/templates/docs.sproutcore.com/output/img/clearinput.png +0 -0
  46. data/lib/sc_docs/templates/docs.sproutcore.com/output/img/cross.png +0 -0
  47. data/lib/sc_docs/templates/docs.sproutcore.com/output/img/ddiagonal.png +0 -0
  48. data/lib/sc_docs/templates/docs.sproutcore.com/output/img/diagonal.png +0 -0
  49. data/lib/sc_docs/templates/docs.sproutcore.com/output/img/docbullet.jpg +0 -0
  50. data/lib/sc_docs/templates/docs.sproutcore.com/output/img/docbullet.png +0 -0
  51. data/lib/sc_docs/templates/docs.sproutcore.com/output/img/glow.png +0 -0
  52. data/lib/sc_docs/templates/docs.sproutcore.com/output/img/logo.png +0 -0
  53. data/lib/sc_docs/templates/docs.sproutcore.com/output/img/pixels.png +0 -0
  54. data/lib/sc_docs/templates/docs.sproutcore.com/output/img/search.png +0 -0
  55. data/lib/sc_docs/templates/docs.sproutcore.com/output/js/api.js +134 -0
  56. data/lib/sc_docs/templates/docs.sproutcore.com/output/js/jquery-bbq.js +18 -0
  57. data/lib/sc_docs/templates/docs.sproutcore.com/output/js/lib/jquery-1.5.1.min.js +16 -0
  58. data/lib/sc_docs/templates/docs.sproutcore.com/output/js/lib/modernizr-1.7.min.js +2 -0
  59. data/lib/sc_docs/templates/docs.sproutcore.com/output/js/plugin.js +1 -0
  60. data/lib/sc_docs/templates/docs.sproutcore.com/output/js/script.js +5 -0
  61. data/lib/sc_docs/templates/docs.sproutcore.com/publish.js +200 -0
  62. data/lib/sc_docs/templates/docs.sproutcore.com/static/default.css +300 -0
  63. data/lib/sc_docs/templates/docs.sproutcore.com/static/header.html +19 -0
  64. data/lib/sc_docs/templates/docs.sproutcore.com/static/index.html +19 -0
  65. data/lib/sc_docs/templates/docs.sproutcore.com/symbol.tmpl +35 -0
  66. data/lib/sc_docs/templates/sc_fixture/publish.js +632 -0
  67. data/lib/sc_docs/version.rb +4 -0
  68. data/sc_docs.gemspec +27 -0
  69. data/vendor/jsdoc/README.txt +109 -0
  70. data/vendor/jsdoc/app/frame.js +33 -0
  71. data/vendor/jsdoc/app/frame/Chain.js +102 -0
  72. data/vendor/jsdoc/app/frame/Dumper.js +144 -0
  73. data/vendor/jsdoc/app/frame/Hash.js +84 -0
  74. data/vendor/jsdoc/app/frame/Link.js +173 -0
  75. data/vendor/jsdoc/app/frame/Namespace.js +10 -0
  76. data/vendor/jsdoc/app/frame/Opt.js +134 -0
  77. data/vendor/jsdoc/app/frame/Reflection.js +26 -0
  78. data/vendor/jsdoc/app/frame/String.js +93 -0
  79. data/vendor/jsdoc/app/frame/Testrun.js +129 -0
  80. data/vendor/jsdoc/app/handlers/FOODOC.js +26 -0
  81. data/vendor/jsdoc/app/handlers/XMLDOC.js +26 -0
  82. data/vendor/jsdoc/app/handlers/XMLDOC/DomReader.js +159 -0
  83. data/vendor/jsdoc/app/handlers/XMLDOC/XMLDoc.js +16 -0
  84. data/vendor/jsdoc/app/handlers/XMLDOC/XMLParse.js +292 -0
  85. data/vendor/jsdoc/app/lib/JSDOC.js +106 -0
  86. data/vendor/jsdoc/app/lib/JSDOC/DocComment.js +204 -0
  87. data/vendor/jsdoc/app/lib/JSDOC/DocTag.js +294 -0
  88. data/vendor/jsdoc/app/lib/JSDOC/JsDoc.js +140 -0
  89. data/vendor/jsdoc/app/lib/JSDOC/JsPlate.js +109 -0
  90. data/vendor/jsdoc/app/lib/JSDOC/Lang.js +144 -0
  91. data/vendor/jsdoc/app/lib/JSDOC/Parser.js +146 -0
  92. data/vendor/jsdoc/app/lib/JSDOC/PluginManager.js +33 -0
  93. data/vendor/jsdoc/app/lib/JSDOC/Symbol.js +644 -0
  94. data/vendor/jsdoc/app/lib/JSDOC/SymbolSet.js +243 -0
  95. data/vendor/jsdoc/app/lib/JSDOC/TextStream.js +41 -0
  96. data/vendor/jsdoc/app/lib/JSDOC/Token.js +18 -0
  97. data/vendor/jsdoc/app/lib/JSDOC/TokenReader.js +332 -0
  98. data/vendor/jsdoc/app/lib/JSDOC/TokenStream.js +133 -0
  99. data/vendor/jsdoc/app/lib/JSDOC/Util.js +32 -0
  100. data/vendor/jsdoc/app/lib/JSDOC/Walker.js +507 -0
  101. data/vendor/jsdoc/app/main.js +111 -0
  102. data/vendor/jsdoc/app/plugins/commentSrcJson.js +20 -0
  103. data/vendor/jsdoc/app/plugins/frameworkPrototype.js +16 -0
  104. data/vendor/jsdoc/app/plugins/functionCall.js +10 -0
  105. data/vendor/jsdoc/app/plugins/publishSrcHilite.js +62 -0
  106. data/vendor/jsdoc/app/plugins/symbolLink.js +10 -0
  107. data/vendor/jsdoc/app/plugins/tagParamConfig.js +31 -0
  108. data/vendor/jsdoc/app/plugins/tagSynonyms.js +43 -0
  109. data/vendor/jsdoc/app/run.js +297 -0
  110. data/vendor/jsdoc/app/t/TestDoc.js +144 -0
  111. data/vendor/jsdoc/app/t/runner.js +13 -0
  112. data/vendor/jsdoc/app/test.js +342 -0
  113. data/vendor/jsdoc/app/test/addon.js +24 -0
  114. data/vendor/jsdoc/app/test/anon_inner.js +14 -0
  115. data/vendor/jsdoc/app/test/augments.js +31 -0
  116. data/vendor/jsdoc/app/test/augments2.js +26 -0
  117. data/vendor/jsdoc/app/test/borrows.js +46 -0
  118. data/vendor/jsdoc/app/test/borrows2.js +23 -0
  119. data/vendor/jsdoc/app/test/config.js +22 -0
  120. data/vendor/jsdoc/app/test/constructs.js +18 -0
  121. data/vendor/jsdoc/app/test/encoding.js +10 -0
  122. data/vendor/jsdoc/app/test/encoding_other.js +12 -0
  123. data/vendor/jsdoc/app/test/event.js +54 -0
  124. data/vendor/jsdoc/app/test/exports.js +14 -0
  125. data/vendor/jsdoc/app/test/functions_anon.js +39 -0
  126. data/vendor/jsdoc/app/test/functions_nested.js +33 -0
  127. data/vendor/jsdoc/app/test/global.js +13 -0
  128. data/vendor/jsdoc/app/test/globals.js +25 -0
  129. data/vendor/jsdoc/app/test/ignore.js +10 -0
  130. data/vendor/jsdoc/app/test/inner.js +16 -0
  131. data/vendor/jsdoc/app/test/jsdoc_test.js +477 -0
  132. data/vendor/jsdoc/app/test/lend.js +33 -0
  133. data/vendor/jsdoc/app/test/memberof.js +19 -0
  134. data/vendor/jsdoc/app/test/memberof2.js +38 -0
  135. data/vendor/jsdoc/app/test/memberof3.js +33 -0
  136. data/vendor/jsdoc/app/test/memberof_constructor.js +17 -0
  137. data/vendor/jsdoc/app/test/module.js +17 -0
  138. data/vendor/jsdoc/app/test/multi_methods.js +25 -0
  139. data/vendor/jsdoc/app/test/name.js +19 -0
  140. data/vendor/jsdoc/app/test/namespace_nested.js +23 -0
  141. data/vendor/jsdoc/app/test/nocode.js +13 -0
  142. data/vendor/jsdoc/app/test/oblit_anon.js +20 -0
  143. data/vendor/jsdoc/app/test/overview.js +20 -0
  144. data/vendor/jsdoc/app/test/param_inline.js +37 -0
  145. data/vendor/jsdoc/app/test/params_optional.js +8 -0
  146. data/vendor/jsdoc/app/test/prototype.js +17 -0
  147. data/vendor/jsdoc/app/test/prototype_nested.js +9 -0
  148. data/vendor/jsdoc/app/test/prototype_oblit.js +13 -0
  149. data/vendor/jsdoc/app/test/prototype_oblit_constructor.js +24 -0
  150. data/vendor/jsdoc/app/test/public.js +10 -0
  151. data/vendor/jsdoc/app/test/scripts/code.js +5 -0
  152. data/vendor/jsdoc/app/test/scripts/notcode.txt +5 -0
  153. data/vendor/jsdoc/app/test/shared.js +42 -0
  154. data/vendor/jsdoc/app/test/shared2.js +2 -0
  155. data/vendor/jsdoc/app/test/shortcuts.js +22 -0
  156. data/vendor/jsdoc/app/test/static_this.js +13 -0
  157. data/vendor/jsdoc/app/test/synonyms.js +31 -0
  158. data/vendor/jsdoc/app/test/tosource.js +23 -0
  159. data/vendor/jsdoc/app/test/variable_redefine.js +14 -0
  160. data/vendor/jsdoc/changes.txt +127 -0
  161. data/vendor/jsdoc/conf/sample.conf +31 -0
  162. metadata +240 -0
@@ -0,0 +1,111 @@
1
+ /**
2
+ * @version $Id: main.js 818 2009-11-08 14:51:41Z micmath $
3
+ */
4
+
5
+ function main() {
6
+ IO.include("lib/JSDOC.js");
7
+ IO.includeDir("plugins/");
8
+
9
+ // process the options
10
+
11
+ // the -c option: options are defined in a configuration file
12
+ if (JSDOC.opt.c) {
13
+ eval("JSDOC.conf = " + IO.readFile(JSDOC.opt.c));
14
+
15
+ LOG.inform("Using configuration file at '"+JSDOC.opt.c+"'.");
16
+
17
+ for (var c in JSDOC.conf) {
18
+ if (c !== "D" && !defined(JSDOC.opt[c])) { // commandline overrules config file
19
+ JSDOC.opt[c] = JSDOC.conf[c];
20
+ }
21
+ }
22
+
23
+ if (typeof JSDOC.conf["_"] != "undefined") {
24
+ JSDOC.opt["_"] = JSDOC.opt["_"].concat(JSDOC.conf["_"]);
25
+ }
26
+
27
+ LOG.inform("With configuration: ");
28
+ for (var o in JSDOC.opt) {
29
+ LOG.inform(" "+o+": "+JSDOC.opt[o]);
30
+ }
31
+ }
32
+
33
+ // be verbose
34
+ if (JSDOC.opt.v) LOG.verbose = true;
35
+
36
+ // send log messages to a file
37
+ if (JSDOC.opt.o) LOG.out = IO.open(JSDOC.opt.o);
38
+
39
+ // run the unit tests
40
+ if (JSDOC.opt.T) {
41
+ LOG.inform("JsDoc Toolkit running in test mode at "+new Date()+".");
42
+ IO.include("frame/Testrun.js");
43
+ IO.include("test.js");
44
+ }
45
+ else {
46
+ // a template must be defined and must be a directory path
47
+ if (!JSDOC.opt.t && System.getProperty("jsdoc.template.dir")) {
48
+ JSDOC.opt.t = System.getProperty("jsdoc.template.dir");
49
+ }
50
+ if (JSDOC.opt.t && SYS.slash != JSDOC.opt.t.slice(-1)) {
51
+ JSDOC.opt.t += SYS.slash;
52
+ }
53
+
54
+ // verbose messages about the options we were given
55
+ LOG.inform("JsDoc Toolkit main() running at "+new Date()+".");
56
+ LOG.inform("With options: ");
57
+ for (var o in JSDOC.opt) {
58
+ LOG.inform(" "+o+": "+JSDOC.opt[o]);
59
+ }
60
+
61
+ // initialize and build a symbolSet from your code
62
+ JSDOC.JsDoc();
63
+
64
+ // debugger's option: dump the entire symbolSet produced from your code
65
+ if (JSDOC.opt.Z) {
66
+ LOG.warn("So you want to see the data structure, eh? This might hang if you have circular refs...");
67
+ IO.include("frame/Dumper.js");
68
+ var symbols = JSDOC.JsDoc.symbolSet.toArray();
69
+ for (var i = 0, l = symbols.length; i < l; i++) {
70
+ var symbol = symbols[i];
71
+ print("// symbol: " + symbol.alias);
72
+ print(symbol.serialize());
73
+ }
74
+ }
75
+ else {
76
+ if (typeof JSDOC.opt.t != "undefined") {
77
+ try {
78
+ // a file named "publish.js" must exist in the template directory
79
+ load(JSDOC.opt.t+"publish.js");
80
+
81
+ // and must define a function named "publish"
82
+ if (!publish) {
83
+ LOG.warn("No publish() function is defined in that template so nothing to do.");
84
+ }
85
+ else {
86
+ // which will be called with the symbolSet produced from your code
87
+ publish(JSDOC.JsDoc.symbolSet);
88
+ }
89
+ }
90
+ catch(e) {
91
+ LOG.warn("Sorry, that doesn't seem to be a valid template: "+JSDOC.opt.t+"publish.js : "+e);
92
+ }
93
+ }
94
+ else {
95
+ LOG.warn("No template given. Might as well read the usage notes.");
96
+ JSDOC.usage();
97
+ }
98
+ }
99
+ }
100
+
101
+ // notify of any warnings
102
+ if (!JSDOC.opt.q && LOG.warnings.length) {
103
+ print(LOG.warnings.length+" warning"+(LOG.warnings.length != 1? "s":"")+".");
104
+ }
105
+
106
+ // stop sending log messages to a file
107
+ if (LOG.out) {
108
+ LOG.out.flush();
109
+ LOG.out.close();
110
+ }
111
+ }
@@ -0,0 +1,20 @@
1
+ JSDOC.PluginManager.registerPlugin(
2
+ "JSDOC.commentSrcJson",
3
+ {
4
+ onDocCommentSrc: function(comment) {
5
+ var json;
6
+ if (/^\s*@json\b/.test(comment)) {
7
+ comment.src = new String(comment.src).replace("@json", "");
8
+
9
+ eval("json = "+comment.src);
10
+ var tagged = "";
11
+ for (var i in json) {
12
+ var tag = json[i];
13
+ // todo handle cases where tag is an object
14
+ tagged += "@"+i+" "+tag+"\n";
15
+ }
16
+ comment.src = tagged;
17
+ }
18
+ }
19
+ }
20
+ );
@@ -0,0 +1,16 @@
1
+ JSDOC.PluginManager.registerPlugin(
2
+ "JSDOC.frameworkPrototype",
3
+ {
4
+ onPrototypeClassCreate: function(classCreator) {
5
+ var desc = "";
6
+ if (classCreator.comment) {
7
+ desc = classCreator.comment;
8
+ }
9
+ var insert = desc+"/** @name "+classCreator.name+"\n@constructor\n@scope "+classCreator.name+".prototype */"
10
+
11
+ insert = insert.replace(/\*\/\/\*\*/g, "\n");
12
+ /*DEBUG*///print("insert is "+insert);
13
+ classCreator.addComment.data = insert;
14
+ }
15
+ }
16
+ );
@@ -0,0 +1,10 @@
1
+ JSDOC.PluginManager.registerPlugin(
2
+ "JSDOC.functionCall",
3
+ {
4
+ onFunctionCall: function(functionCall) {
5
+ if (functionCall.name == "dojo.define" && functionCall.arg1) {
6
+ functionCall.doc = "/** @lends "+eval(functionCall.arg1)+".prototype */";
7
+ }
8
+ }
9
+ }
10
+ );
@@ -0,0 +1,62 @@
1
+ JSDOC.PluginManager.registerPlugin(
2
+ "JSDOC.publishSrcHilite",
3
+ {
4
+ onPublishSrc: function(src) {
5
+ if (src.path in JsHilite.cache) {
6
+ return; // already generated src code
7
+ }
8
+ else JsHilite.cache[src.path] = true;
9
+
10
+ try {
11
+ var sourceCode = IO.readFile(src.path);
12
+ }
13
+ catch(e) {
14
+ print(e.message);
15
+ quit();
16
+ }
17
+
18
+ var hiliter = new JsHilite(sourceCode, src.charset);
19
+ src.hilited = hiliter.hilite();
20
+ }
21
+ }
22
+ );
23
+
24
+ function JsHilite(src, charset) {
25
+
26
+ var tr = new JSDOC.TokenReader();
27
+
28
+ tr.keepComments = true;
29
+ tr.keepDocs = true;
30
+ tr.keepWhite = true;
31
+
32
+ this.tokens = tr.tokenize(new JSDOC.TextStream(src));
33
+
34
+ // TODO is redefining toString() the best way?
35
+ JSDOC.Token.prototype.toString = function() {
36
+ return "<span class=\""+this.type+"\">"+this.data.replace(/</g, "&lt;")+"</span>";
37
+ }
38
+
39
+ if (!charset) charset = "utf-8";
40
+
41
+ this.header = '<html><head><meta http-equiv="content-type" content="text/html; charset='+charset+'"> '+
42
+ "<style>\n\
43
+ .KEYW {color: #933;}\n\
44
+ .COMM {color: #bbb; font-style: italic;}\n\
45
+ .NUMB {color: #393;}\n\
46
+ .STRN {color: #393;}\n\
47
+ .REGX {color: #339;}\n\
48
+ .line {border-right: 1px dotted #666; color: #666; font-style: normal;}\n\
49
+ </style></head><body><pre>";
50
+ this.footer = "</pre></body></html>";
51
+ this.showLinenumbers = true;
52
+ }
53
+
54
+ JsHilite.cache = {};
55
+
56
+ JsHilite.prototype.hilite = function() {
57
+ var hilited = this.tokens.join("");
58
+ var line = 1;
59
+ if (this.showLinenumbers) hilited = hilited.replace(/(^|\n)/g, function(m){return m+"<span class='line'>"+((line<10)? " ":"")+((line<100)? " ":"")+(line++)+"</span> "});
60
+
61
+ return this.header+hilited+this.footer;
62
+ }
@@ -0,0 +1,10 @@
1
+ JSDOC.PluginManager.registerPlugin(
2
+ "JSDOC.symbolLink",
3
+ {
4
+ onSymbolLink: function(link) {
5
+ // modify link.linkPath (the href part of the link)
6
+ // or link.linkText (the text displayed)
7
+ // or link.linkInner (the #name part of the link)
8
+ }
9
+ }
10
+ );
@@ -0,0 +1,31 @@
1
+ JSDOC.PluginManager.registerPlugin(
2
+ "JSDOC.tagParamConfig",
3
+ {
4
+ onDocCommentTags: function(comment) {
5
+ var currentParam = null;
6
+ var tags = comment.tags;
7
+ for (var i = 0, l = tags.length; i < l; i++) {
8
+
9
+ if (tags[i].title == "param") {
10
+ if (tags[i].name.indexOf(".") == -1) {
11
+ currentParam = i;
12
+ }
13
+ }
14
+ else if (tags[i].title == "config") {
15
+ tags[i].title = "param";
16
+ if (currentParam == null) {
17
+ tags[i].name = "arguments"+"."+tags[i].name;
18
+ }
19
+ else if (tags[i].name.indexOf(tags[currentParam].name+".") != 0) {
20
+ tags[i].name = tags[currentParam].name+"."+tags[i].name;
21
+ }
22
+ currentParam != null
23
+ //tags[currentParam].properties.push(tags[i]);
24
+ }
25
+ else {
26
+ currentParam = null;
27
+ }
28
+ }
29
+ }
30
+ }
31
+ );
@@ -0,0 +1,43 @@
1
+ JSDOC.PluginManager.registerPlugin(
2
+ "JSDOC.tagSynonyms",
3
+ {
4
+ onDocCommentSrc: function(comment) {
5
+ comment.src = comment.src.replace(/@methodOf\b/i, "@function\n@memberOf");
6
+ comment.src = comment.src.replace(/@fieldOf\b/i, "@field\n@memberOf");
7
+ },
8
+
9
+ onDocCommentTags: function(comment) {
10
+ for (var i = 0, l = comment.tags.length; i < l; i++) {
11
+ var title = comment.tags[i].title.toLowerCase();
12
+ var syn;
13
+ if ((syn = JSDOC.tagSynonyms.synonyms["="+title])) {
14
+ comment.tags[i].title = syn;
15
+ }
16
+ }
17
+ }
18
+ }
19
+ );
20
+
21
+ new Namespace(
22
+ "JSDOC.tagSynonyms",
23
+ function() {
24
+ JSDOC.tagSynonyms.synonyms = {
25
+ "=member": "memberOf",
26
+ "=memberof": "memberOf",
27
+ "=description": "desc",
28
+ "=exception": "throws",
29
+ "=argument": "param",
30
+ "=returns": "return",
31
+ "=classdescription": "class",
32
+ "=fileoverview": "overview",
33
+ "=extends": "augments",
34
+ "=base": "augments",
35
+ "=projectdescription": "overview",
36
+ "=classdescription": "class",
37
+ "=link": "see",
38
+ "=borrows": "inherits",
39
+ "=scope": "lends",
40
+ "=construct": "constructor"
41
+ }
42
+ }
43
+ );
@@ -0,0 +1,297 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * @fileOverview
4
+ * A bootstrap script that creates some basic required objects
5
+ * for loading other scripts. This variant provides the glue
6
+ * to run on top of Node.js rather than Java+Rhino.
7
+ * @author Aaron Wirtz, me@awirtz.com
8
+ */
9
+
10
+ // load the node.js libraries to be abstracted
11
+ var fs = require('fs');
12
+ var Script = process.binding('evals').Script;
13
+
14
+ // define a few globals to be compatible with jsrun.jar
15
+ global.arguments = process.argv.slice(2);
16
+ load = function(file) {
17
+ Script.runInThisContext(fs.readFileSync(file), file);
18
+ };
19
+ print = console.log;
20
+ quit = process.exit;
21
+
22
+ /**
23
+ * @namespace Keep track of any messages from the running script.
24
+ */
25
+ LOG = {
26
+ warn: function(msg, e) {
27
+ if (JSDOC.opt.q) return;
28
+ if (e) msg = e.fileName+", line "+e.lineNumber+": "+msg;
29
+
30
+ msg = ">> WARNING: "+msg;
31
+ LOG.warnings.push(msg);
32
+ if (LOG.out) LOG.out.write(msg+"\n");
33
+ else print(msg);
34
+ },
35
+
36
+ inform: function(msg) {
37
+ if (JSDOC.opt.q) return;
38
+ msg = " > "+msg;
39
+ if (LOG.out) LOG.out.write(msg+"\n");
40
+ else if (typeof LOG.verbose != "undefined" && LOG.verbose) print(msg);
41
+ }
42
+ };
43
+ LOG.warnings = [];
44
+ LOG.verbose = false;
45
+ LOG.out = undefined;
46
+
47
+ /**
48
+ * @class Manipulate a filepath.
49
+ */
50
+ FilePath = function(absPath, separator) {
51
+ this.slash = separator || "/";
52
+ this.root = this.slash;
53
+ this.path = [];
54
+ this.file = "";
55
+
56
+ var parts = absPath.split(/[\\\/]/);
57
+ if (parts) {
58
+ if (parts.length) this.root = parts.shift() + this.slash;
59
+ if (parts.length) this.file = parts.pop();
60
+ if (parts.length) this.path = parts;
61
+ }
62
+
63
+ this.path = this.resolvePath();
64
+ }
65
+
66
+ /** Collapse any dot-dot or dot items in a filepath. */
67
+ FilePath.prototype.resolvePath = function() {
68
+ var resolvedPath = [];
69
+ for (var i = 0; i < this.path.length; i++) {
70
+ if (this.path[i] == "..") resolvedPath.pop();
71
+ else if (this.path[i] != ".") resolvedPath.push(this.path[i]);
72
+ }
73
+ return resolvedPath;
74
+ }
75
+
76
+ /** Trim off the filename. */
77
+ FilePath.prototype.toDir = function() {
78
+ if (this.file) this.file = "";
79
+ return this;
80
+ }
81
+
82
+ /** Go up a directory. */
83
+ FilePath.prototype.upDir = function() {
84
+ this.toDir();
85
+ if (this.path.length) this.path.pop();
86
+ return this;
87
+ }
88
+
89
+ FilePath.prototype.toString = function() {
90
+ return this.root
91
+ + this.path.join(this.slash)
92
+ + ((this.path.length > 0)? this.slash : "")
93
+ + this.file;
94
+ }
95
+
96
+ /**
97
+ * Turn a path into just the name of the file.
98
+ */
99
+ FilePath.fileName = function(path) {
100
+ var nameStart = Math.max(path.lastIndexOf("/")+1, path.lastIndexOf("\\")+1, 0);
101
+ return path.substring(nameStart);
102
+ }
103
+
104
+ /**
105
+ * Get the extension of a filename
106
+ */
107
+ FilePath.fileExtension = function(filename) {
108
+ return filename.split(".").pop().toLowerCase();
109
+ };
110
+
111
+ /**
112
+ * Turn a path into just the directory part.
113
+ */
114
+ FilePath.dir = function(path) {
115
+ var nameStart = Math.max(path.lastIndexOf("/")+1, path.lastIndexOf("\\")+1, 0);
116
+ return path.substring(0, nameStart-1);
117
+ }
118
+
119
+
120
+ /**
121
+ * @namespace A collection of information about your system.
122
+ */
123
+ SYS = {}
124
+ /**
125
+ * Which way does your slash lean.
126
+ * @type string
127
+ */
128
+ SYS.slash = "/";
129
+ /**
130
+ * The absolute path to the directory containing this script.
131
+ * @type string
132
+ */
133
+ SYS.pwd = __dirname+SYS.slash;
134
+
135
+
136
+ /**
137
+ * @namespace A collection of functions that deal with reading a writing to disk.
138
+ */
139
+ IO = {
140
+
141
+ /**
142
+ * Create a new file in the given directory, with the given name and contents.
143
+ */
144
+ saveFile: function(/**string*/ outDir, /**string*/ fileName, /**string*/ content) {
145
+ fs.writeFileSync(outDir + "/" + fileName, content, IO.encoding);
146
+ },
147
+
148
+ /**
149
+ * @type string
150
+ */
151
+ readFile: function(/**string*/ path) {
152
+ return fs.readFileSync(path, IO.encoding);
153
+ },
154
+
155
+ /**
156
+ * @param inFile
157
+ * @param outDir
158
+ * @param [fileName=The original filename]
159
+ */
160
+ copyFile: function(/**string*/ inFile, /**string*/ outDir, /**string*/ fileName) {
161
+ if (fileName == null) fileName = FilePath.fileName(inFile);
162
+
163
+ var inFile = fs.openSync(inFile, "r");
164
+ var outFile = fs.openSync(outDir+"/"+fileName, "w");
165
+
166
+ var buf = new Buffer(4096);
167
+
168
+ while (fs.readSync(inFile, buf, 0, buf.length) > 0) {
169
+ fs.writeSync(outFile, buf);
170
+ }
171
+
172
+ fs.closeSync(inFile);
173
+ fs.closeSync(outFile);
174
+ },
175
+
176
+ /**
177
+ * Creates a series of nested directories.
178
+ */
179
+ mkPath: function(/**Array*/ path) {
180
+ if (path.constructor != Array) path = path.split(/[\\\/]/);
181
+ var make = "";
182
+ for (var i = 0, l = path.length; i < l; i++) {
183
+ make += path[i] + SYS.slash;
184
+ if (! IO.exists(make)) {
185
+ IO.makeDir(make);
186
+ }
187
+ }
188
+ },
189
+
190
+ /**
191
+ * Creates a directory at the given path.
192
+ */
193
+ makeDir: function(/**string*/ path) {
194
+ fs.mkdirSync(path, 0777);
195
+ },
196
+
197
+ /**
198
+ * @type string[]
199
+ * @param dir The starting directory to look in.
200
+ * @param [recurse=1] How many levels deep to scan.
201
+ * @returns An array of all the paths to files in the given dir.
202
+ */
203
+ ls: function(/**string*/ dir, /**number*/ recurse, _allFiles, _path) {
204
+ if (_path === undefined) { // initially
205
+ var _allFiles = [];
206
+ var _path = [dir];
207
+ }
208
+ if (_path.length == 0) return _allFiles;
209
+ if (recurse === undefined) recurse = 1;
210
+
211
+ var s = fs.statSync(dir);
212
+ if (!s.isDirectory()) return [dir];
213
+ var files = fs.readdirSync(dir);
214
+
215
+ for (var f = 0; f < files.length; f++) {
216
+ var file = files[f];
217
+ if (file.match(/^\.[^\.\/\\]/)) continue; // skip dot files
218
+
219
+ if ((fs.statSync(_path.join("/")+"/"+file).isDirectory())) { // it's a directory
220
+ _path.push(file);
221
+ if (_path.length-1 < recurse) IO.ls(_path.join("/"), recurse, _allFiles, _path);
222
+ _path.pop();
223
+ }
224
+ else {
225
+ _allFiles.push((_path.join("/")+"/"+file).replace("//", "/"));
226
+ }
227
+ }
228
+
229
+ return _allFiles;
230
+ },
231
+
232
+ /**
233
+ * @type boolean
234
+ */
235
+ exists: function(/**string*/ path) {
236
+ try {
237
+ fs.statSync(path);
238
+ return true;
239
+ } catch(e) {
240
+ return false;
241
+ }
242
+ },
243
+
244
+ /**
245
+ *
246
+ */
247
+ open: function(/**string*/ path, /**boolean*/ append) {
248
+ if(append == null) append = true;
249
+ return fs.createWriteStream(path, {flags: (append ? "a" : "w")});
250
+ },
251
+
252
+ /**
253
+ * Sets {@link IO.encoding}.
254
+ * Encoding is used when reading and writing text to files,
255
+ * and in the meta tags of HTML output.
256
+ */
257
+ setEncoding: function(/**string*/ encoding) {
258
+ if (/UTF-8/i.test(encoding)) {
259
+ IO.encoding = "utf8";
260
+ }
261
+ else if (/ASCII/i.test(encoding)) {
262
+ IO.encoding = "ascii";
263
+ }
264
+ else {
265
+ throw("Unsupported encoding: "+encoding+" - perhaps you can use UTF-8?");
266
+ }
267
+ },
268
+
269
+ /**
270
+ * @default "utf8"
271
+ * @private
272
+ */
273
+ encoding: "utf8",
274
+
275
+ /**
276
+ * Load the given script.
277
+ */
278
+ include: function(relativePath) {
279
+ load(SYS.pwd+relativePath);
280
+ },
281
+
282
+ /**
283
+ * Loads all scripts from the given directory path.
284
+ */
285
+ includeDir: function(path) {
286
+ if (!path) return;
287
+
288
+ for (var lib = IO.ls(SYS.pwd+path), i = 0; i < lib.length; i++)
289
+ if (/\.js$/i.test(lib[i])) load(lib[i]);
290
+ }
291
+ }
292
+
293
+ // now run the application
294
+ IO.include("frame.js");
295
+ IO.include("main.js");
296
+
297
+ main();