Permalink
...
Comparing changes
Open a pull request
- 9 commits
- 55 files changed
- 0 commit comments
- 1 contributor
Unified
Split
Showing
with
462 additions
and 387 deletions.
- +8 −0 Cakefile
- +11 −0 Rakefile
- +85 −50 documentation/index.html.erb
- +1 −1 documentation/js/aliases.js
- +1 −1 documentation/js/arguments.js
- +1 −1 documentation/js/array_comprehensions.js
- +1 −1 documentation/js/assignment.js
- +1 −1 documentation/js/cake_tasks.js
- +1 −1 documentation/js/comparisons.js
- +1 −1 documentation/js/conditionals.js
- +1 −1 documentation/js/embedded.js
- +1 −1 documentation/js/existence.js
- +1 −1 documentation/js/expressions.js
- +1 −1 documentation/js/expressions_assignment.js
- +1 −1 documentation/js/expressions_comprehension.js
- +1 −1 documentation/js/expressions_try.js
- +1 −1 documentation/js/fat_arrow.js
- +1 −1 documentation/js/functions.js
- +1 −1 documentation/js/heredocs.js
- +1 −1 documentation/js/multiple_return_values.js
- +1 −1 documentation/js/object_comprehensions.js
- +1 −1 documentation/js/object_extraction.js
- +1 −1 documentation/js/objects_and_arrays.js
- +1 −1 documentation/js/overview.js
- +1 −1 documentation/js/parallel_assignment.js
- +1 −1 documentation/js/range_comprehensions.js
- +1 −1 documentation/js/scope.js
- +1 −1 documentation/js/slices.js
- +1 −1 documentation/js/soaks.js
- +1 −1 documentation/js/splats.js
- +1 −1 documentation/js/splices.js
- +1 −1 documentation/js/strings.js
- +1 −1 documentation/js/super.js
- +1 −1 documentation/js/switch.js
- +1 −1 documentation/js/try.js
- +1 −1 documentation/js/while.js
- +9 −1 extras/EXTRAS
- +1 −0 extras/coffee-script.js
- +83 −48 index.html
- +1 −1 lib/cake.js
- +12 −16 lib/coffee-script.js
- +64 −74 lib/command_line.js
- +1 −1 lib/grammar.js
- +1 −1 lib/lexer.js
- +1 −1 lib/narwhal.js
- +42 −42 lib/nodes.js
- +11 −17 lib/optparse.js
- +1 −1 lib/repl.js
- +1 −1 lib/rewriter.js
- +1 −1 lib/scope.js
- +1 −1 package.json
- +6 −6 src/coffee-script.coffee
- +43 −39 src/command_line.coffee
- +40 −40 src/nodes.coffee
- +6 −13 src/optparse.coffee
View
8
Cakefile
| @@ -38,6 +38,14 @@ task 'build:underscore', 'rebuild the Underscore.coffee documentation page', -> | ||
| exec 'uv -s coffeescript -t idle -h examples/underscore.coffee > documentation/underscore.html' | ||
| +task 'build:browser', 'rebuild the merged script for inclusion in the browser', -> | ||
| + exec 'rake browser' | ||
| + | ||
| + | ||
| +task 'doc', 'watch and continually rebuild the documentation', -> | ||
| + exec 'rake doc' | ||
| + | ||
| + | ||
| task 'test', 'run the CoffeeScript language test suite', -> | ||
| process.mixin require 'assert' | ||
| test_count: 0 | ||
View
11
Rakefile
| @@ -1,6 +1,8 @@ | ||
| require 'erb' | ||
| require 'fileutils' | ||
| require 'rake/testtask' | ||
| +require 'rubygems' | ||
| +require 'yui/compressor' | ||
| desc "Build the documentation page" | ||
| task :doc do | ||
| @@ -18,3 +20,12 @@ task :doc do | ||
| sleep 1 | ||
| end | ||
| end | ||
| + | ||
| +desc "Build the single concatenated and minified script for the browser" | ||
| +task :browser do | ||
| + sources = %w(rewriter.js lexer.js parser.js scope.js nodes.js coffee-script.js) | ||
| + code = sources.map {|s| File.read('lib/' + s) }.join('') | ||
| + code = YUI::JavaScriptCompressor.new.compress(code) | ||
| + File.open('extras/coffee-script.js', 'w+') {|f| f.write(code) } | ||
| +end | ||
| + | ||
View
135
documentation/index.html.erb
| @@ -1,7 +1,7 @@ | ||
| <% | ||
| require 'uv' | ||
| def code_for(file, executable=false) | ||
| - @stripper ||= /(\A\(function\(\)\{\n|\}\)\(\);\Z|^ )/ | ||
| + @stripper ||= /(\A\(function\(\)\{\n|\}\)\(\);\n*\Z|^ )/ | ||
| return '' unless File.exists?("documentation/js/#{file}.js") | ||
| cs = File.read("documentation/coffee/#{file}.coffee") | ||
| js = File.read("documentation/js/#{file}.js").gsub(@stripper, '') | ||
| @@ -60,6 +60,7 @@ | ||
| <a href="#comparisons">Chained Comparisons</a> | ||
| <a href="#strings">Multiline Strings and Heredocs</a> | ||
| <a href="#cake">Cake, and Cakefiles</a> | ||
| + <a href="#scripts">"text/coffeescript" Script Tags</a> | ||
| <a href="#resources">Resources</a> | ||
| <a href="#change_log">Change Log</a> | ||
| </div> | ||
| @@ -107,7 +108,7 @@ alert reverse '!tpircseeffoC'</textarea> | ||
| <p> | ||
| <b>Latest Version:</b> | ||
| - <a href="http://github.com/jashkenas/coffee-script/tarball/0.5.1">0.5.1</a> | ||
| + <a href="http://github.com/jashkenas/coffee-script/tarball/0.5.2">0.5.2</a> | ||
| </p> | ||
| <h2> | ||
| @@ -138,7 +139,7 @@ alert reverse '!tpircseeffoC'</textarea> | ||
| </h2> | ||
| <p> | ||
| - The CoffeeScript compiler is written in pure CoffeeScript, using a | ||
| + The CoffeeScript compiler is written in pure CoffeeScript, using a | ||
| <a href="http://github.com/jashkenas/coffee-script/blob/master/src/grammar.coffee">small DSL</a> | ||
| on top of the <a href="http://github.com/zaach/jison">Jison parser generator</a>, and is available | ||
| as a <a href="http://nodejs.org/">Node.js</a> utility. The core compiler however, | ||
| @@ -152,7 +153,7 @@ alert reverse '!tpircseeffoC'</textarea> | ||
| <a href="http://nodejs.org/">Node.js</a>, 0.1.30 or higher. Then clone the CoffeeScript | ||
| <a href="http://github.com/jashkenas/coffee-script">source repository</a> | ||
| from GitHub, or download the latest | ||
| - release: <a href="http://github.com/jashkenas/coffee-script/tarball/0.5.1">0.5.1</a>. | ||
| + release: <a href="http://github.com/jashkenas/coffee-script/tarball/0.5.2">0.5.2</a>. | ||
| To install the CoffeeScript compiler system-wide | ||
| under <tt>/usr/local</tt>, open the directory and run: | ||
| </p> | ||
| @@ -215,6 +216,14 @@ sudo bin/cake install</pre> | ||
| </td> | ||
| </tr> | ||
| <tr> | ||
| + <td><code>-s, --stdio</code></td> | ||
| + <td> | ||
| + Pipe in CoffeeScript to STDIN and get back JavaScript over STDOUT. | ||
| + Good for use with processes written in other languages. An example:<br /> | ||
| + <tt>cat src/cake.coffee | coffee -s</tt> | ||
| + </td> | ||
| + </tr> | ||
| + <tr> | ||
| <td><code>-e, --eval</code></td> | ||
| <td> | ||
| Compile and print a little snippet of CoffeeScript directly from the | ||
| @@ -718,6 +727,34 @@ coffee --print app/scripts/*.coffee > concatenation.js</pre> | ||
| <%= code_for('cake_tasks') %> | ||
| <h2> | ||
| + <span id="scripts" class="bookmark"></span> | ||
| + "text/coffeescript" Script Tags | ||
| + </h2> | ||
| + | ||
| + <p> | ||
| + While it's not recommended for serious use, CoffeeScripts may be included | ||
| + directly within the browser using <tt><script type="text/coffeescript"></tt> | ||
| + tags. The codebase includes a compressed and minified version of the compiler | ||
| + (<a href="extras/coffee-script.js">Download current version here, 43k when gzipped</a>). | ||
| + Include <tt>coffee-script.js</tt> on the page <b>after</b> any <tt>text/coffeescript</tt> tags | ||
| + with inline CoffeeScript, and it will compile and evaluate them in order. | ||
| + </p> | ||
| + | ||
| + <p> | ||
| + In fact, the little bit of glue script that runs "Try CoffeeScript" above, | ||
| + as well as jQuery for the menu, is implemented in just this way. | ||
| + View source and look at the bottom of the page to see the example. | ||
| + Including the script also gives you access to <tt>CoffeeScript.compile()</tt> | ||
| + so you can pop open Firebug and try compiling some strings. | ||
| + </p> | ||
| + | ||
| + <p> | ||
| + The usual caveats about CoffeeScript apply — your inline scripts will | ||
| + run within a closure wrapper, so if you want to expose global variables or | ||
| + functions, attach them to the <tt>window</tt> object. | ||
| + </p> | ||
| + | ||
| + <h2> | ||
| <span id="resources" class="bookmark"></span> | ||
| Resources | ||
| </h2> | ||
| @@ -746,6 +783,15 @@ coffee --print app/scripts/*.coffee > concatenation.js</pre> | ||
| </h2> | ||
| <p> | ||
| + <b class="header" style="margin-top: 20px;">0.5.2</b> | ||
| + Added a compressed version of the compiler for inclusion in web pages as | ||
| + <br /><tt>extras/coffee-script.js</tt>. It'll automatically run any script tags | ||
| + with type <tt>text/coffeescript</tt> for you. Added a <tt>--stdio</tt> option | ||
| + to the <tt>coffee</tt> command, for piped-in compiles. | ||
| + </p> | ||
| + | ||
| + | ||
| + <p> | ||
| <b class="header" style="margin-top: 20px;">0.5.1</b> | ||
| Improvements to null soaking with the existential operator, including | ||
| soaks on indexed properties. Added conditions to <tt>while</tt> loops, | ||
| @@ -915,53 +961,42 @@ coffee --print app/scripts/*.coffee > concatenation.js</pre> | ||
| </div> | ||
| - <script type="text/javascript" src="lib/rewriter.js"></script> | ||
| - <script type="text/javascript" src="lib/lexer.js"></script> | ||
| - <script type="text/javascript" src="lib/parser.js"></script> | ||
| - <script type="text/javascript" src="lib/scope.js"></script> | ||
| - <script type="text/javascript" src="lib/nodes.js"></script> | ||
| - <script type="text/javascript" src="lib/coffee-script.js"></script> | ||
| - | ||
| - <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> | ||
| - | ||
| - <script type="text/javascript"> | ||
| - window.repl_compile = function() { | ||
| - var source = $('#repl_source').val(); | ||
| - window.compiled_js = ''; | ||
| - try { | ||
| - window.compiled_js = CoffeeScript.compile(source, {no_wrap: true}); | ||
| - } catch(error) { | ||
| - alert(error); | ||
| - } | ||
| - $('#repl_results').html(window.compiled_js); | ||
| - }; | ||
| - window.repl_run = function() { | ||
| - try { | ||
| - eval(window.compiled_js); | ||
| - } catch(error) { | ||
| - alert(error); | ||
| - } | ||
| - }; | ||
| - | ||
| - var nav = $('.navigation'); | ||
| - var currentNav = null; | ||
| - var closeMenus = function() { | ||
| - if (currentNav) currentNav.removeClass('active'); | ||
| - currentNav = null; | ||
| - }; | ||
| - nav.click(function(e) { | ||
| - if (e.target.tagName.toLowerCase() == 'a') return; | ||
| - if (this !== (currentNav && currentNav[0])) { | ||
| - closeMenus(); | ||
| - currentNav = $(this); | ||
| - currentNav.addClass('active'); | ||
| - } | ||
| - return false; | ||
| - }); | ||
| - $(document.body).click(function() { | ||
| - closeMenus(); | ||
| - }); | ||
| + <script type="text/coffeescript"> | ||
| + | ||
| + window.repl_compile: -> | ||
| + source: $('#repl_source').val() | ||
| + window.compiled_js: '' | ||
| + try | ||
| + window.compiled_js: CoffeeScript.compile source, {no_wrap: true} | ||
| + catch error then alert error | ||
| + $('#repl_results').html window.compiled_js | ||
| + | ||
| + window.repl_run: -> | ||
| + try | ||
| + eval window.compiled_js | ||
| + catch error then alert error | ||
| + | ||
| + nav: $('.navigation') | ||
| + current_nav: null | ||
| + | ||
| + close_menus: -> | ||
| + current_nav.removeClass 'active' if current_nav | ||
| + current_nav: null | ||
| + | ||
| + nav.click (e) -> | ||
| + return if e.target.tagName.toLowerCase() is 'a' | ||
| + if this isnt (current_nav and current_nav[0]) | ||
| + close_menus(); | ||
| + current_nav: $(this) | ||
| + current_nav.addClass 'active' | ||
| + false | ||
| + | ||
| + $(document.body).click -> close_menus() | ||
| + | ||
| </script> | ||
| + <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> | ||
| + <script src="extras/coffee-script.js"></script> | ||
| + | ||
| </body> | ||
| </html> | ||
View
2
documentation/js/aliases.js
| @@ -11,4 +11,4 @@ | ||
| } | ||
| car.speed < speed_limit ? accelerate() : null; | ||
| print("My name is " + this.name); | ||
| -})(); | ||
| +})(); | ||
View
2
documentation/js/arguments.js
| @@ -5,4 +5,4 @@ | ||
| return alert(arguments.reverse()); | ||
| }; | ||
| backwards("stairway", "to", "heaven"); | ||
| -})(); | ||
| +})(); | ||
View
2
documentation/js/array_comprehensions.js
| @@ -23,4 +23,4 @@ | ||
| } | ||
| } | ||
| } | ||
| -})(); | ||
| +})(); | ||
View
2
documentation/js/assignment.js
| @@ -2,4 +2,4 @@ | ||
| var difficulty, greeting; | ||
| greeting = "Hello CoffeeScript"; | ||
| difficulty = 0.5; | ||
| -})(); | ||
| +})(); | ||
View
2
documentation/js/cake_tasks.js
| @@ -11,4 +11,4 @@ | ||
| } | ||
| return _a; | ||
| }); | ||
| -})(); | ||
| +})(); | ||
View
2
documentation/js/comparisons.js
| @@ -2,4 +2,4 @@ | ||
| var cholesterol, healthy; | ||
| cholesterol = 127; | ||
| healthy = (200 > cholesterol) && (cholesterol > 60); | ||
| -})(); | ||
| +})(); | ||
View
2
documentation/js/conditionals.js
| @@ -9,4 +9,4 @@ | ||
| } | ||
| date = friday ? sue : jill; | ||
| expensive = expensive || do_the_math(); | ||
| -})(); | ||
| +})(); | ||
View
2
documentation/js/embedded.js
| @@ -3,4 +3,4 @@ | ||
| hi = function() { | ||
| return [document.title, "Hello JavaScript"].join(": "); | ||
| }; | ||
| -})(); | ||
| +})(); | ||
View
2
documentation/js/existence.js
| @@ -4,4 +4,4 @@ | ||
| solipsism = true; | ||
| } | ||
| speed = (typeof speed !== "undefined" && speed !== null) ? speed : 140; | ||
| -})(); | ||
| +})(); | ||
View
2
documentation/js/expressions.js
| @@ -10,4 +10,4 @@ | ||
| } | ||
| }; | ||
| eldest = 24 > 21 ? "Liz" : "Ike"; | ||
| -})(); | ||
| +})(); | ||
View
2
documentation/js/expressions_assignment.js
| @@ -1,4 +1,4 @@ | ||
| (function(){ | ||
| var one, six, three, two; | ||
| six = ((one = 1)) + ((two = 2)) + ((three = 3)); | ||
| -})(); | ||
| +})(); |
View
2
documentation/js/expressions_comprehension.js
| @@ -9,4 +9,4 @@ | ||
| }} | ||
| return _a; | ||
| }).call(this).slice(0, 10); | ||
| -})(); | ||
| +})(); | ||
View
2
documentation/js/expressions_try.js
| @@ -6,4 +6,4 @@ | ||
| return "And the error is ... " + error; | ||
| } | ||
| }).call(this)); | ||
| -})(); | ||
| +})(); | ||
View
2
documentation/js/fat_arrow.js
| @@ -12,4 +12,4 @@ | ||
| }); | ||
| })(this)); | ||
| }; | ||
| -})(); | ||
| +})(); | ||
View
2
documentation/js/functions.js
| @@ -6,4 +6,4 @@ | ||
| cube = function cube(x) { | ||
| return square(x) * x; | ||
| }; | ||
| -})(); | ||
| +})(); | ||
View
2
documentation/js/heredocs.js
| @@ -1,4 +1,4 @@ | ||
| (function(){ | ||
| var html; | ||
| html = "<strong>\n cup of coffeescript\n</strong>"; | ||
| -})(); | ||
| +})(); |
View
2
documentation/js/multiple_return_values.js
| @@ -8,4 +8,4 @@ | ||
| city = _a[0]; | ||
| temp = _a[1]; | ||
| forecast = _a[2]; | ||
| -})(); | ||
| +})(); | ||
View
2
documentation/js/object_comprehensions.js
| @@ -14,4 +14,4 @@ | ||
| }} | ||
| return _a; | ||
| }).call(this); | ||
| -})(); | ||
| +})(); | ||
View
2
documentation/js/object_extraction.js
| @@ -14,4 +14,4 @@ | ||
| _c = _b.address; | ||
| street = _c[0]; | ||
| city = _c[1]; | ||
| -})(); | ||
| +})(); | ||
View
2
documentation/js/objects_and_arrays.js
| @@ -7,4 +7,4 @@ | ||
| tim: 11 | ||
| }; | ||
| matrix = [1, 0, 1, 0, 0, 1, 1, 1, 0]; | ||
| -})(); | ||
| +})(); | ||
View
2
documentation/js/overview.js
| @@ -40,4 +40,4 @@ | ||
| } | ||
| return _a; | ||
| }).call(this); | ||
| -})(); | ||
| +})(); | ||
View
2
documentation/js/parallel_assignment.js
| @@ -5,4 +5,4 @@ | ||
| _a = [and_switch, bait]; | ||
| bait = _a[0]; | ||
| and_switch = _a[1]; | ||
| -})(); | ||
| +})(); | ||
View
2
documentation/js/range_comprehensions.js
| @@ -18,4 +18,4 @@ | ||
| } | ||
| return _f; | ||
| }; | ||
| -})(); | ||
| +})(); | ||
Oops, something went wrong.