Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
...
  • 9 commits
  • 55 files changed
  • 0 commit comments
  • 1 contributor
Commits on Feb 24, 2010
@jashkenas upgrading the optparse library to avoid having to register callbacks …
…for each argument. It just returns a simple options hash.
aba8cb1
@jashkenas adding compilation over stdin/stdout. Use --stdio or -s, and pipe away. 9f8710b
@jashkenas adding documentation for --stdio b26e577
@jashkenas moving print_tokens (the pretty printer) from coffee_script to comman…
…d_line
2a46e13
Commits on Feb 25, 2010
@jashkenas adding a minified combined coffee-script.js. Include it on the page, …
…after any text/coffeescript tags, and call CoffeeScript.activate(); to run it
c1427d6
@jashkenas implementing the inline javascript in the documentation page in text/…
…coffeescript, switching from the closure compiler to the yui compressor for building the browser version -- the closure compiler had a bug for our input -- fixable by hand but not worth the tiny savings
c14869f
@jashkenas call it 'CoffeeScript' in the command_line, so that --run scripts may…
… access it as such
23c5ebb
@jashkenas removing CoffeeScript.activate() simply including the tag will do for…
… text/coffeescript
22674bc
@jashkenas docs for CoffeeScript 0.5.2, which is now out. 05d95ac
Showing with 462 additions and 387 deletions.
  1. +8 −0 Cakefile
  2. +11 −0 Rakefile
  3. +85 −50 documentation/index.html.erb
  4. +1 −1 documentation/js/aliases.js
  5. +1 −1 documentation/js/arguments.js
  6. +1 −1 documentation/js/array_comprehensions.js
  7. +1 −1 documentation/js/assignment.js
  8. +1 −1 documentation/js/cake_tasks.js
  9. +1 −1 documentation/js/comparisons.js
  10. +1 −1 documentation/js/conditionals.js
  11. +1 −1 documentation/js/embedded.js
  12. +1 −1 documentation/js/existence.js
  13. +1 −1 documentation/js/expressions.js
  14. +1 −1 documentation/js/expressions_assignment.js
  15. +1 −1 documentation/js/expressions_comprehension.js
  16. +1 −1 documentation/js/expressions_try.js
  17. +1 −1 documentation/js/fat_arrow.js
  18. +1 −1 documentation/js/functions.js
  19. +1 −1 documentation/js/heredocs.js
  20. +1 −1 documentation/js/multiple_return_values.js
  21. +1 −1 documentation/js/object_comprehensions.js
  22. +1 −1 documentation/js/object_extraction.js
  23. +1 −1 documentation/js/objects_and_arrays.js
  24. +1 −1 documentation/js/overview.js
  25. +1 −1 documentation/js/parallel_assignment.js
  26. +1 −1 documentation/js/range_comprehensions.js
  27. +1 −1 documentation/js/scope.js
  28. +1 −1 documentation/js/slices.js
  29. +1 −1 documentation/js/soaks.js
  30. +1 −1 documentation/js/splats.js
  31. +1 −1 documentation/js/splices.js
  32. +1 −1 documentation/js/strings.js
  33. +1 −1 documentation/js/super.js
  34. +1 −1 documentation/js/switch.js
  35. +1 −1 documentation/js/try.js
  36. +1 −1 documentation/js/while.js
  37. +9 −1 extras/EXTRAS
  38. +1 −0 extras/coffee-script.js
  39. +83 −48 index.html
  40. +1 −1 lib/cake.js
  41. +12 −16 lib/coffee-script.js
  42. +64 −74 lib/command_line.js
  43. +1 −1 lib/grammar.js
  44. +1 −1 lib/lexer.js
  45. +1 −1 lib/narwhal.js
  46. +42 −42 lib/nodes.js
  47. +11 −17 lib/optparse.js
  48. +1 −1 lib/repl.js
  49. +1 −1 lib/rewriter.js
  50. +1 −1 lib/scope.js
  51. +1 −1 package.json
  52. +6 −6 src/coffee-script.coffee
  53. +43 −39 src/command_line.coffee
  54. +40 −40 src/nodes.coffee
  55. +6 −13 src/optparse.coffee
View
@@ -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
@@ -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
+
@@ -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>&lt;script type="text/coffeescript"&gt;</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 &mdash; 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>
@@ -11,4 +11,4 @@
}
car.speed < speed_limit ? accelerate() : null;
print("My name is " + this.name);
-})();
+})();
@@ -5,4 +5,4 @@
return alert(arguments.reverse());
};
backwards("stairway", "to", "heaven");
-})();
+})();
@@ -23,4 +23,4 @@
}
}
}
-})();
+})();
@@ -2,4 +2,4 @@
var difficulty, greeting;
greeting = "Hello CoffeeScript";
difficulty = 0.5;
-})();
+})();
@@ -11,4 +11,4 @@
}
return _a;
});
-})();
+})();
@@ -2,4 +2,4 @@
var cholesterol, healthy;
cholesterol = 127;
healthy = (200 > cholesterol) && (cholesterol > 60);
-})();
+})();
@@ -9,4 +9,4 @@
}
date = friday ? sue : jill;
expensive = expensive || do_the_math();
-})();
+})();
@@ -3,4 +3,4 @@
hi = function() {
return [document.title, "Hello JavaScript"].join(": ");
};
-})();
+})();
@@ -4,4 +4,4 @@
solipsism = true;
}
speed = (typeof speed !== "undefined" && speed !== null) ? speed : 140;
-})();
+})();
@@ -10,4 +10,4 @@
}
};
eldest = 24 > 21 ? "Liz" : "Ike";
-})();
+})();
@@ -1,4 +1,4 @@
(function(){
var one, six, three, two;
six = ((one = 1)) + ((two = 2)) + ((three = 3));
-})();
+})();
@@ -9,4 +9,4 @@
}}
return _a;
}).call(this).slice(0, 10);
-})();
+})();
@@ -6,4 +6,4 @@
return "And the error is ... " + error;
}
}).call(this));
-})();
+})();
@@ -12,4 +12,4 @@
});
})(this));
};
-})();
+})();
@@ -6,4 +6,4 @@
cube = function cube(x) {
return square(x) * x;
};
-})();
+})();
@@ -1,4 +1,4 @@
(function(){
var html;
html = "<strong>\n cup of coffeescript\n</strong>";
-})();
+})();
@@ -8,4 +8,4 @@
city = _a[0];
temp = _a[1];
forecast = _a[2];
-})();
+})();
@@ -14,4 +14,4 @@
}}
return _a;
}).call(this);
-})();
+})();
@@ -14,4 +14,4 @@
_c = _b.address;
street = _c[0];
city = _c[1];
-})();
+})();
@@ -7,4 +7,4 @@
tim: 11
};
matrix = [1, 0, 1, 0, 0, 1, 1, 1, 0];
-})();
+})();
@@ -40,4 +40,4 @@
}
return _a;
}).call(this);
-})();
+})();
@@ -5,4 +5,4 @@
_a = [and_switch, bait];
bait = _a[0];
and_switch = _a[1];
-})();
+})();
@@ -18,4 +18,4 @@
}
return _f;
};
-})();
+})();
Oops, something went wrong.

No commit comments for this range