Permalink
Browse files

Merge branch 'master' into iced2

Conflicts:
	extras/coffee-script.js
	lib/coffee-script/browser.js
	lib/coffee-script/cake.js
	lib/coffee-script/coffee-script.js
	lib/coffee-script/command.js
	lib/coffee-script/grammar.js
	lib/coffee-script/helpers.js
	lib/coffee-script/index.js
	lib/coffee-script/lexer.js
	lib/coffee-script/nodes.js
	lib/coffee-script/optparse.js
	lib/coffee-script/register.js
	lib/coffee-script/repl.js
	lib/coffee-script/rewriter.js
	lib/coffee-script/scope.js
	lib/coffee-script/sourcemap.js
	package.json
	src/coffee-script.coffee
  • Loading branch information...
2 parents 9f05038 + eda4f0c commit adbd09cd70852f01a316558b011695ac79132422 @maxtaco committed Feb 6, 2014
Showing with 5,476 additions and 6,113 deletions.
  1. +2 −2 Cakefile
  2. +74 −67 documentation/docs/browser.html
  3. +75 −97 documentation/docs/cake.html
  4. +252 −365 documentation/docs/coffee-script.html
  5. +335 −301 documentation/docs/command.html
  6. +2 −11 documentation/docs/docco.css
  7. +493 −615 documentation/docs/grammar.html
  8. +190 −172 documentation/docs/helpers.html
  9. +7 −3 documentation/docs/index.html
  10. +791 −846 documentation/docs/lexer.html
  11. +2,020 −2,423 documentation/docs/nodes.html
  12. +85 −105 documentation/docs/optparse.html
  13. +251 −0 documentation/docs/register.html
  14. +139 −132 documentation/docs/repl.html
  15. +434 −509 documentation/docs/rewriter.html
  16. +85 −123 documentation/docs/scope.html
  17. +141 −266 documentation/docs/sourcemap.html
  18. +12 −1 documentation/index.html.js
  19. +1 −1 documentation/js/aliases.js
  20. +1 −1 documentation/js/array_comprehensions.js
  21. +1 −1 documentation/js/block_comment.js
  22. +1 −1 documentation/js/cake_tasks.js
  23. +1 −1 documentation/js/chaining.js
  24. +1 −1 documentation/js/classes.js
  25. +1 −1 documentation/js/comparisons.js
  26. +1 −1 documentation/js/conditionals.js
  27. +1 −1 documentation/js/constructor_destructuring.js
  28. +1 −1 documentation/js/default_args.js
  29. +1 −1 documentation/js/do.js
  30. +1 −1 documentation/js/embedded.js
  31. +1 −1 documentation/js/existence.js
  32. +1 −1 documentation/js/expansion.js
  33. +1 −1 documentation/js/expressions.js
  34. +1 −1 documentation/js/expressions_assignment.js
  35. +1 −1 documentation/js/expressions_comprehension.js
  36. +1 −1 documentation/js/expressions_try.js
  37. +1 −1 documentation/js/fat_arrow.js
  38. +1 −1 documentation/js/functions.js
  39. +1 −1 documentation/js/heredocs.js
  40. +1 −1 documentation/js/heregexes.js
  41. +1 −1 documentation/js/interpolation.js
  42. +1 −1 documentation/js/multiple_return_values.js
  43. +1 −1 documentation/js/object_comprehensions.js
  44. +1 −1 documentation/js/object_extraction.js
  45. +1 −1 documentation/js/objects_and_arrays.js
  46. +1 −1 documentation/js/objects_reserved.js
  47. +1 −1 documentation/js/overview.js
  48. +1 −1 documentation/js/parallel_assignment.js
  49. +1 −1 documentation/js/patterns_and_splats.js
  50. +1 −1 documentation/js/prototypes.js
  51. +1 −1 documentation/js/range_comprehensions.js
  52. +1 −1 documentation/js/scope.js
  53. +1 −1 documentation/js/slices.js
  54. +1 −1 documentation/js/soaks.js
  55. +1 −1 documentation/js/splats.js
  56. +1 −1 documentation/js/splices.js
  57. +1 −1 documentation/js/strings.js
  58. +1 −1 documentation/js/switch.js
  59. +1 −1 documentation/js/switch_with_no_expression.js
  60. +1 −1 documentation/js/try.js
  61. +1 −1 documentation/js/while.js
  62. +1 −1 extras/coffee-script-iced-large.js
  63. +1 −1 extras/coffee-script-iced.js
  64. +2 −2 extras/coffee-script.js
  65. +15 −4 index.html
  66. +1 −1 lib/coffee-script/browser.js
  67. +1 −1 lib/coffee-script/cake.js
  68. +3 −3 lib/coffee-script/coffee-script.js
  69. +1 −1 lib/coffee-script/command.js
  70. +1 −1 lib/coffee-script/grammar.js
  71. +1 −1 lib/coffee-script/helpers.js
  72. +1 −1 lib/coffee-script/iced.js
  73. +1 −1 lib/coffee-script/icedlib.js
  74. +1 −1 lib/coffee-script/index.js
  75. +1 −1 lib/coffee-script/lexer.js
  76. +1 −1 lib/coffee-script/nodes.js
  77. +1 −1 lib/coffee-script/optparse.js
  78. +1 −1 lib/coffee-script/register.js
  79. +1 −1 lib/coffee-script/repl.js
  80. +1 −1 lib/coffee-script/rewriter.js
  81. +1 −1 lib/coffee-script/scope.js
  82. +1 −1 lib/coffee-script/sourcemap.js
  83. +5 −3 package.json
  84. +2 −2 src/coffee-script.coffee
View
@@ -192,12 +192,12 @@ task 'doc:site', 'watch and continually rebuild the documentation for the websit
log "watching..." , green
task 'doc:source', 'rebuild the internal documentation', ->
- exec 'docco src/*.*coffee && cp -rf docs documentation && rm -r docs', (err) ->
+ exec 'node_modules/.bin/docco src/*.*coffee && cp -rf docs documentation && rm -r docs', (err) ->
throw err if err
task 'doc:underscore', 'rebuild the Underscore.coffee documentation page', ->
- exec 'docco examples/underscore.coffee && cp -rf docs documentation && rm -r docs', (err) ->
+ exec 'node_modules/.bin/docco examples/underscore.coffee && cp -rf docs documentation && rm -r docs', (err) ->
throw err if err
task 'bench', 'quick benchmark of compilation time', ->
@@ -69,6 +69,11 @@
</a>
+ <a class="source" href="register.html">
+ register.coffee
+ </a>
+
+
<a class="source" href="repl.html">
repl.coffee
</a>
@@ -111,14 +116,12 @@
<p>This <strong>Browser</strong> compatibility layer extends core CoffeeScript functions
to make things work smoothly when compiling code directly in the browser.
We add support for loading remote Coffee scripts via <strong>XHR</strong>, and
-<code>text/coffeescript</code> script tags, source maps via data-URLs, and so on.
-</p>
+<code>text/coffeescript</code> script tags, source maps via data-URLs, and so on.</p>
</div>
- <div class="content"><div class='highlight'><pre>
-CoffeeScript = require <span class="string">'./coffee-script'</span>
-CoffeeScript.require = require
+ <div class="content"><div class='highlight'><pre>CoffeeScript = <span class="hljs-built_in">require</span> <span class="hljs-string">'./coffee-script'</span>
+CoffeeScript.<span class="hljs-built_in">require</span> = <span class="hljs-built_in">require</span>
compile = CoffeeScript.compile</pre></div></div>
</li>
@@ -130,13 +133,12 @@
<div class="pilwrap ">
<a class="pilcrow" href="#section-2">&#182;</a>
</div>
- <p>Use standard JavaScript <code>eval</code> to eval code.
-</p>
+ <p>Use standard JavaScript <code>eval</code> to eval code.</p>
</div>
- <div class="content"><div class='highlight'><pre>CoffeeScript.<span class="function"><span class="title">eval</span></span> = (code, options = {}) -&gt;
- options.bare ?= <span class="literal">on</span>
+ <div class="content"><div class='highlight'><pre>CoffeeScript.<span class="hljs-function"><span class="hljs-title">eval</span> = <span class="hljs-params">(code, options = {})</span> -&gt;</span>
+ options.bare ?= <span class="hljs-literal">on</span>
eval compile code, options</pre></div></div>
</li>
@@ -148,14 +150,13 @@
<div class="pilwrap ">
<a class="pilcrow" href="#section-3">&#182;</a>
</div>
- <p>Running code does not provide access to this scope.
-</p>
+ <p>Running code does not provide access to this scope.</p>
</div>
- <div class="content"><div class='highlight'><pre>CoffeeScript.<span class="function"><span class="title">run</span></span> = (code, options = {}) -&gt;
- options.bare = <span class="literal">on</span>
- options.shiftLine = <span class="literal">on</span>
+ <div class="content"><div class='highlight'><pre>CoffeeScript.<span class="hljs-function"><span class="hljs-title">run</span> = <span class="hljs-params">(code, options = {})</span> -&gt;</span>
+ options.bare = <span class="hljs-literal">on</span>
+ options.shiftLine = <span class="hljs-literal">on</span>
Function(compile code, options)()</pre></div></div>
</li>
@@ -167,12 +168,11 @@
<div class="pilwrap ">
<a class="pilcrow" href="#section-4">&#182;</a>
</div>
- <p>If we&#39;re not in a browser environment, we&#39;re finished with the public API.
-</p>
+ <p>If we&#39;re not in a browser environment, we&#39;re finished with the public API.</p>
</div>
- <div class="content"><div class='highlight'><pre><span class="keyword">return</span> <span class="keyword">unless</span> window?</pre></div></div>
+ <div class="content"><div class='highlight'><pre><span class="hljs-keyword">return</span> <span class="hljs-keyword">unless</span> <span class="hljs-built_in">window</span>?</pre></div></div>
</li>
@@ -185,17 +185,16 @@
</div>
<p>Include source maps where possible. If we&#39;ve got a base64 encoder, a
JSON serializer, and tools for escaping unicode characters, we&#39;re good to go.
-Ported from <a href="https://developer.mozilla.org/en-US/docs/DOM/window.btoa">https://developer.mozilla.org/en-US/docs/DOM/window.btoa</a>
-</p>
+Ported from <a href="https://developer.mozilla.org/en-US/docs/DOM/window.btoa">https://developer.mozilla.org/en-US/docs/DOM/window.btoa</a></p>
</div>
- <div class="content"><div class='highlight'><pre><span class="keyword">if</span> btoa? <span class="keyword">and</span> JSON? <span class="keyword">and</span> unescape? <span class="keyword">and</span> encodeURIComponent?
- <span class="function"><span class="title">compile</span></span> = (code, options = {}) -&gt;
- options.sourceMap = <span class="literal">true</span>
- options.inline = <span class="literal">true</span>
+ <div class="content"><div class='highlight'><pre><span class="hljs-keyword">if</span> btoa? <span class="hljs-keyword">and</span> JSON? <span class="hljs-keyword">and</span> unescape? <span class="hljs-keyword">and</span> encodeURIComponent?
+ <span class="hljs-function"><span class="hljs-title">compile</span> = <span class="hljs-params">(code, options = {})</span> -&gt;</span>
+ options.sourceMap = <span class="hljs-literal">true</span>
+ options.inline = <span class="hljs-literal">true</span>
{js, v3SourceMap} = CoffeeScript.compile code, options
- <span class="string">"<span class="subst">#{js}</span>\n//@ sourceMappingURL=data:application/json;base64,<span class="subst">#{btoa unescape encodeURIComponent v3SourceMap}</span>\n//@ sourceURL=coffeescript"</span></pre></div></div>
+ <span class="hljs-string">"<span class="hljs-subst">#{js}</span>\n//# sourceMappingURL=data:application/json;base64,<span class="hljs-subst">#{btoa unescape encodeURIComponent v3SourceMap}</span>\n//# sourceURL=coffeescript"</span></pre></div></div>
</li>
@@ -206,27 +205,27 @@
<div class="pilwrap ">
<a class="pilcrow" href="#section-6">&#182;</a>
</div>
- <p>Load a remote script from the current domain via XHR.
-</p>
+ <p>Load a remote script from the current domain via XHR.</p>
</div>
- <div class="content"><div class='highlight'><pre>CoffeeScript.<span class="function"><span class="title">load</span></span> = (url, callback, options = {}) -&gt;
+ <div class="content"><div class='highlight'><pre>CoffeeScript.<span class="hljs-function"><span class="hljs-title">load</span> = <span class="hljs-params">(url, callback, options = {}, hold = <span class="hljs-literal">false</span>)</span> -&gt;</span>
options.sourceFiles = [url]
- xhr = <span class="keyword">if</span> window.ActiveXObject
- <span class="keyword">new</span> window.ActiveXObject(<span class="string">'Microsoft.XMLHTTP'</span>)
- <span class="keyword">else</span>
- <span class="keyword">new</span> window.XMLHttpRequest()
- xhr.open <span class="string">'GET'</span>, url, <span class="literal">true</span>
- xhr.overrideMimeType <span class="string">'text/plain'</span> <span class="keyword">if</span> <span class="string">'overrideMimeType'</span> <span class="keyword">of</span> xhr
- xhr.<span class="function"><span class="title">onreadystatechange</span></span> = -&gt;
- <span class="keyword">if</span> xhr.readyState <span class="keyword">is</span> <span class="number">4</span>
- <span class="keyword">if</span> xhr.status <span class="keyword">in</span> [<span class="number">0</span>, <span class="number">200</span>]
- CoffeeScript.run xhr.responseText, options
- <span class="keyword">else</span>
- <span class="keyword">throw</span> <span class="keyword">new</span> Error <span class="string">"Could not load <span class="subst">#{url}</span>"</span>
- callback() <span class="keyword">if</span> callback
- xhr.send <span class="literal">null</span></pre></div></div>
+ xhr = <span class="hljs-keyword">if</span> <span class="hljs-built_in">window</span>.ActiveXObject
+ <span class="hljs-keyword">new</span> <span class="hljs-built_in">window</span>.ActiveXObject(<span class="hljs-string">'Microsoft.XMLHTTP'</span>)
+ <span class="hljs-keyword">else</span>
+ <span class="hljs-keyword">new</span> <span class="hljs-built_in">window</span>.XMLHttpRequest()
+ xhr.open <span class="hljs-string">'GET'</span>, url, <span class="hljs-literal">true</span>
+ xhr.overrideMimeType <span class="hljs-string">'text/plain'</span> <span class="hljs-keyword">if</span> <span class="hljs-string">'overrideMimeType'</span> <span class="hljs-keyword">of</span> xhr
+ xhr.<span class="hljs-function"><span class="hljs-title">onreadystatechange</span> = -&gt;</span>
+ <span class="hljs-keyword">if</span> xhr.readyState <span class="hljs-keyword">is</span> <span class="hljs-number">4</span>
+ <span class="hljs-keyword">if</span> xhr.status <span class="hljs-keyword">in</span> [<span class="hljs-number">0</span>, <span class="hljs-number">200</span>]
+ param = [xhr.responseText, options]
+ CoffeeScript.run param... <span class="hljs-keyword">unless</span> hold
+ <span class="hljs-keyword">else</span>
+ <span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> Error <span class="hljs-string">"Could not load <span class="hljs-subst">#{url}</span>"</span>
+ callback param <span class="hljs-keyword">if</span> callback
+ xhr.send <span class="hljs-literal">null</span></pre></div></div>
</li>
@@ -239,29 +238,38 @@
</div>
<p>Activate CoffeeScript in the browser by having it compile and evaluate
all script tags with a content-type of <code>text/coffeescript</code>.
-This happens on page load.
-</p>
+This happens on page load.</p>
</div>
- <div class="content"><div class='highlight'><pre><span class="function"><span class="title">runScripts</span></span> = -&gt;
- scripts = window.document.getElementsByTagName <span class="string">'script'</span>
- coffeetypes = [<span class="string">'text/coffeescript'</span>, <span class="string">'text/literate-coffeescript'</span>]
- coffees = (s <span class="keyword">for</span> s <span class="keyword">in</span> scripts <span class="keyword">when</span> s.type <span class="keyword">in</span> coffeetypes)
- index = <span class="number">0</span>
- length = coffees.length
- <span class="keyword">do</span> <span class="function"><span class="title">execute</span></span> = -&gt;
- script = coffees[index++]
- mediatype = script?.type
- <span class="keyword">if</span> mediatype <span class="keyword">in</span> coffeetypes
- options = {literate: mediatype <span class="keyword">is</span> <span class="string">'text/literate-coffeescript'</span>}
- <span class="keyword">if</span> script.src
- CoffeeScript.load script.src, execute, options
- <span class="keyword">else</span>
- options.sourceFiles = [<span class="string">'embedded'</span>]
- CoffeeScript.run script.innerHTML, options
- execute()
- <span class="literal">null</span></pre></div></div>
+ <div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">runScripts</span> = -&gt;</span>
+ scripts = <span class="hljs-built_in">window</span>.<span class="hljs-built_in">document</span>.getElementsByTagName <span class="hljs-string">'script'</span>
+ coffeetypes = [<span class="hljs-string">'text/coffeescript'</span>, <span class="hljs-string">'text/literate-coffeescript'</span>]
+ coffees = (s <span class="hljs-keyword">for</span> s <span class="hljs-keyword">in</span> scripts <span class="hljs-keyword">when</span> s.type <span class="hljs-keyword">in</span> coffeetypes)
+ index = <span class="hljs-number">0</span>
+
+ <span class="hljs-function"><span class="hljs-title">execute</span> = -&gt;</span>
+ param = coffees[index]
+ <span class="hljs-keyword">if</span> param <span class="hljs-keyword">instanceof</span> Array
+ CoffeeScript.run param...
+ index++
+ execute()
+
+ <span class="hljs-keyword">for</span> script, i <span class="hljs-keyword">in</span> coffees
+ <span class="hljs-keyword">do</span> <span class="hljs-function"><span class="hljs-params">(script, i)</span> -&gt;</span>
+ options = <span class="hljs-attribute">literate</span>: script.type <span class="hljs-keyword">is</span> coffeetypes[<span class="hljs-number">1</span>]
+ <span class="hljs-keyword">if</span> script.src
+ CoffeeScript.load script.src,
+ <span class="hljs-function"><span class="hljs-params">(param)</span> -&gt;</span>
+ coffees[i] = param
+ execute()
+ options
+ <span class="hljs-literal">true</span>
+ <span class="hljs-keyword">else</span>
+ options.sourceFiles = [<span class="hljs-string">'embedded'</span>]
+ coffees[i] = [script.innerHTML, options]
+
+ execute()</pre></div></div>
</li>
@@ -272,15 +280,14 @@
<div class="pilwrap ">
<a class="pilcrow" href="#section-8">&#182;</a>
</div>
- <p>Listen for window load, both in decent browsers and in IE.
-</p>
+ <p>Listen for window load, both in decent browsers and in IE.</p>
</div>
- <div class="content"><div class='highlight'><pre><span class="keyword">if</span> window.addEventListener
- window.addEventListener <span class="string">'DOMContentLoaded'</span>, runScripts, <span class="literal">no</span>
-<span class="keyword">else</span>
- window.attachEvent <span class="string">'onload'</span>, runScripts</pre></div></div>
+ <div class="content"><div class='highlight'><pre><span class="hljs-keyword">if</span> <span class="hljs-built_in">window</span>.addEventListener
+ <span class="hljs-built_in">window</span>.addEventListener <span class="hljs-string">'DOMContentLoaded'</span>, runScripts, <span class="hljs-literal">no</span>
+<span class="hljs-keyword">else</span>
+ <span class="hljs-built_in">window</span>.attachEvent <span class="hljs-string">'onload'</span>, runScripts</pre></div></div>
</li>
Oops, something went wrong.

0 comments on commit adbd09c

Please sign in to comment.