1
0
Fork 0
mirror of https://github.com/jashkenas/coffeescript.git synced 2022-11-09 12:23:24 -05:00

merging in the try coffeescript linking patch from Jeremy Banks, and regen-ing source. The newline patch makes a *huge* difference on the documentation page.

This commit is contained in:
Jeremy Ashkenas 2011-09-20 22:42:19 -05:00
parent 4c0b2372c7
commit 65b3bf0d4c
41 changed files with 498 additions and 174 deletions

View file

@ -172,7 +172,7 @@ npm install -g coffee-script</pre>
<p>
(Leave off the <tt>-g</tt> if you don't wish to install globally.)
</p>
<p>
If you'd prefer to install the latest master version of CoffeeScript, you
can clone the CoffeeScript
@ -191,7 +191,7 @@ sudo bin/cake install</pre>
<a href="http://opinionated-programmer.com/2010/12/installing-coffeescript-on-debian-or-ubuntu/">be
careful not to use the existing out-of-date package</a>. If installing on
Windows, your best bet is probably to run Node.js under Cygwin. If you'd
just like to experiment, you can try the
just like to experiment, you can try the
<a href="https://github.com/alisey/CoffeeScript-Compiler-for-Windows">CoffeeScript Compiler For Windows</a>.
</p>
@ -229,7 +229,7 @@ sudo bin/cake install</pre>
<td><code>-j, --join [FILE]</code></td>
<td>
Before compiling, concatenate all scripts together in the order they
were passed, and write them into the specified file.
were passed, and write them into the specified file.
Useful for building large projects.
</td>
</tr>
@ -933,17 +933,17 @@ Expressions
<span id="resources" class="bookmark"></span>
Books and Screencasts
</h2>
<p>
There are a number of excellent books and screencasts to help you get
There are a number of excellent books and screencasts to help you get
started with CoffeeScript, some of which are freely available online.
</p>
<ul>
<li>
<a href="http://arcturo.github.com/library/coffeescript/">The Little Book on CoffeeScript</a>
is a brief 5-chapter introduction to CoffeeScript, written with great
clarity and precision by
clarity and precision by
<a href="http://alexmaccaw.co.uk/">Alex MacCaw</a>.
</li>
<li>
@ -956,7 +956,7 @@ Expressions
</li>
<li>
<a href="http://pragprog.com/book/tbcoffee/coffeescript">CoffeeScript: Accelerated JavaScript Development</a>
is <a href="http://trevorburnham.com/">Trevor Burnham</a>'s thorough
is <a href="http://trevorburnham.com/">Trevor Burnham</a>'s thorough
introduction to the language. By the end of the book, you'll have built
a fast-paced multiplayer word game, writing both the client-side and Node.js
portions in CoffeeScript.
@ -974,7 +974,7 @@ Expressions
in 11 minutes.
</li>
</ul>
<h2>
Examples
</h2>
@ -1041,7 +1041,7 @@ Expressions
<li>
<a href="http://github.com/jashkenas/coffee-script/wiki">The CoffeeScript Wiki</a><br />
If you've ever learned a neat CoffeeScript tip or trick, or ran into a gotcha &mdash; share it on the wiki.
The wiki also serves as a directory of handy
The wiki also serves as a directory of handy
<a href="http://github.com/jashkenas/coffee-script/wiki/Text-editor-plugins">text editor extensions</a>,
<a href="http://github.com/jashkenas/coffee-script/wiki/Web-framework-plugins">web framework plugins</a>,
and general <a href="http://github.com/jashkenas/coffee-script/wiki/Build-tools">CoffeeScript build tools</a>.
@ -1071,7 +1071,7 @@ Expressions
<span id="change_log" class="bookmark"></span>
Change Log
</h2>
<p>
<b class="header" style="margin-top: 20px;">
<a href="https://github.com/jashkenas/coffee-script/compare/1.1.1...1.1.2">1.1.2</a>
@ -1081,24 +1081,24 @@ Expressions
against control structures, implicit invocation of a try/catch block,
variadic arguments leaking from local scope, line numbers in syntax errors
following heregexes, property access on parenthesized number literals,
bound class methods and super with reserved names, a REPL overhaul,
bound class methods and super with reserved names, a REPL overhaul,
consecutive compiled semicolons, block comments in implicitly called objects,
and a Chrome bug.
</p>
<p>
<b class="header" style="margin-top: 20px;">1.1.1
<span class="timestamp"> &ndash; <small>May 10, 2011</small></span>
</b>
Bugfix release for classes with external constructor functions, see
Bugfix release for classes with external constructor functions, see
issue #1182.
</p>
<p>
<b class="header" style="margin-top: 20px;">1.1.0
<span class="timestamp"> &ndash; <small>May 1, 2011</small></span>
</b>
When running via the <tt>coffee</tt> executable, <tt>process.argv</tt> and
When running via the <tt>coffee</tt> executable, <tt>process.argv</tt> and
friends now report <tt>coffee</tt> instead of <tt>node</tt>.
Better compatibility with <b>Node.js 0.4.x</b> module lookup changes.
The output in the REPL is now colorized, like Node's is.
@ -1578,7 +1578,7 @@ Expressions
</div>
<script type="text/coffeescript">
source_fragment_prefix = "try_src:"
sourceFragment = "try:"
# Set up the compilation function, to run when you stop typing.
compileSource = ->
@ -1596,7 +1596,7 @@ Expressions
$('#error').text(error.message).show()
# Update permalink
$('#repl_permalink').attr 'href', "##{source_fragment_prefix}#{encodeURIComponent source}"
$('#repl_permalink').attr 'href', "##{sourceFragment}#{encodeURIComponent source}"
# Listen for keypresses and recompile.
$('#repl_source').keyup -> compileSource()
@ -1650,8 +1650,8 @@ Expressions
# If source code is included in location.hash, display it.
hash = decodeURIComponent location.hash.replace(/^#/, '')
if hash.indexOf(source_fragment_prefix) == 0
src = hash.substr source_fragment_prefix.length
if hash.indexOf(sourceFragment) == 0
src = hash.substr sourceFragment.length
loadConsole src
compileSource()

View file

@ -1,17 +1,13 @@
var volume, winner;
if (ignition === true) {
launch();
}
if (band !== SpinalTap) {
volume = 10;
}
if (answer !== false) {
letTheWildRumpusBegin();
}
if (car.speed < limit) {
accelerate();
}
if (pick === 47 || pick === 92 || pick === 13) {
winner = true;
}
print(inspect("My name is " + this.name));
if (ignition === true) launch();
if (band !== SpinalTap) volume = 10;
if (answer !== false) letTheWildRumpusBegin();
if (car.speed < limit) accelerate();
if (pick === 47 || pick === 92 || pick === 13) winner = true;
print(inspect("My name is " + this.name));

View file

@ -1,6 +1,21 @@
var food, _i, _len, _ref;
var course, courses, dish, food, foods, _i, _j, _len, _len2, _len3, _ref;
_ref = ['toast', 'cheese', 'wine'];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
food = _ref[_i];
eat(food);
}
}
courses = ['salad', 'entree', 'dessert'];
for (course = 0, _len2 = courses.length; course < _len2; course++) {
dish = courses[course];
menu(course + 1, dish);
}
foods = ['broccoli', 'spinach', 'chocolate'];
for (_j = 0, _len3 = foods.length; _j < _len3; _j++) {
food = foods[_j];
if (food !== 'chocolate') eat(food);
}

View file

@ -1,4 +1,7 @@
/*
CoffeeScript Compiler v1.1.2
Released under the MIT License
*/
*/

View file

@ -1,10 +1,13 @@
var fs;
fs = require('fs');
option('-o', '--output [DIR]', 'directory for compiled code');
task('build:parser', 'rebuild the Jison parser', function(options) {
var code, dir;
require('jison');
code = require('./lib/grammar').parser.generate();
dir = options.output || 'lib';
return fs.writeFile("" + dir + "/parser.js", code);
});
});

View file

@ -1,44 +1,58 @@
var Animal, Horse, Snake, sam, tom;
var __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) {
for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; }
function ctor() { this.constructor = child; }
ctor.prototype = parent.prototype;
child.prototype = new ctor;
child.__super__ = parent.prototype;
return child;
};
var __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };
Animal = (function() {
function Animal(name) {
this.name = name;
}
Animal.prototype.move = function(meters) {
return alert(this.name + (" moved " + meters + "m."));
};
return Animal;
})();
Snake = (function() {
__extends(Snake, Animal);
function Snake() {
Snake.__super__.constructor.apply(this, arguments);
}
Snake.prototype.move = function() {
alert("Slithering...");
return Snake.__super__.move.call(this, 5);
};
return Snake;
})();
Horse = (function() {
__extends(Horse, Animal);
function Horse() {
Horse.__super__.constructor.apply(this, arguments);
}
Horse.prototype.move = function() {
alert("Galloping...");
return Horse.__super__.move.call(this, 45);
};
return Horse;
})();
sam = new Snake("Sammy the Python");
tom = new Horse("Tommy the Palomino");
sam.move();
tom.move();
tom.move();

View file

@ -1,3 +1,5 @@
var cholesterol, healthy;
cholesterol = 127;
healthy = (200 > cholesterol && cholesterol > 60);
healthy = (200 > cholesterol && cholesterol > 60);

View file

@ -1,12 +1,14 @@
var date, mood;
if (singing) {
mood = greatlyImproved;
}
if (singing) mood = greatlyImproved;
if (happy && knowsIt) {
clapsHands();
chaChaCha();
} else {
showIt();
}
date = friday ? sue : jill;
options || (options = defaults);
options || (options = defaults);

View file

@ -1,7 +1,6 @@
var fill;
fill = function(container, liquid) {
if (liquid == null) {
liquid = "coffee";
}
if (liquid == null) liquid = "coffee";
return "Filling the " + container + " with " + liquid + "...";
};
};

View file

@ -1,4 +1,5 @@
var filename, _fn, _i, _len;
_fn = function(filename) {
return fs.readFile(filename, function(err, contents) {
return compile(filename, contents.toString());
@ -7,4 +8,4 @@ _fn = function(filename) {
for (_i = 0, _len = list.length; _i < _len; _i++) {
filename = list[_i];
_fn(filename);
}
}

View file

@ -1,4 +1,5 @@
var hi;
hi = function() {
return [document.title, "Hello JavaScript"].join(": ");
};
};

View file

@ -1,8 +1,9 @@
var footprints, solipsism;
if ((typeof mind !== "undefined" && mind !== null) && !(typeof world !== "undefined" && world !== null)) {
solipsism = true;
}
if (typeof speed === "undefined" || speed === null) {
speed = 75;
}
footprints = typeof yeti !== "undefined" && yeti !== null ? yeti : "bear";
if (typeof speed === "undefined" || speed === null) speed = 75;
footprints = typeof yeti !== "undefined" && yeti !== null ? yeti : "bear";

View file

@ -1,4 +1,5 @@
var eldest, grade;
grade = function(student) {
if (student.excellentWork) {
return "A+";
@ -12,4 +13,5 @@ grade = function(student) {
return "C";
}
};
eldest = 24 > 21 ? "Liz" : "Ike";
eldest = 24 > 21 ? "Liz" : "Ike";

View file

@ -1,2 +1,3 @@
var one, six, three, two;
six = (one = 1) + (two = 2) + (three = 3);
six = (one = 1) + (two = 2) + (three = 3);

View file

@ -1,4 +1,5 @@
var globals, name;
globals = ((function() {
var _results;
_results = [];
@ -6,4 +7,4 @@ globals = ((function() {
_results.push(name);
}
return _results;
})()).slice(0, 10);
})()).slice(0, 10);

View file

@ -1,7 +1,8 @@
alert((function() {
try {
return nonexistent / void 0;
} catch (error) {
return "And the error is ... " + error;
}
})());
})());

View file

@ -1,9 +1,10 @@
var Account;
var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
Account = function(customer, cart) {
this.customer = customer;
this.cart = cart;
return $('.shopping_cart').bind('click', __bind(function(event) {
return this.customer.purchase(this.cart);
}, this));
};
};

View file

@ -1,7 +1,9 @@
var cube, square;
square = function(x) {
return x * x;
};
cube = function(x) {
return square(x) * x;
};
};

View file

@ -1,2 +1,3 @@
var html;
html = '<strong>\n cup of coffeescript\n</strong>';
html = '<strong>\n cup of coffeescript\n</strong>';

View file

@ -1,2 +1,3 @@
var OPERATOR;
OPERATOR = /^(?:[-=]>|[-+*\/%<>&|^!?=]=|>>>=?|([-+:])\1|([&|<>])\2=?|\?\.|\.{2,3})/;
OPERATOR = /^(?:[-=]>|[-+*\/%<>&|^!?=]=|>>>=?|([-+:])\1|([&|<>])\2=?|\?\.|\.{2,3})/;

View file

@ -1,4 +1,7 @@
var author, quote, sentence;
author = "Wittgenstein";
quote = "A picture is a fact. -- " + author;
sentence = "" + (22 / 7) + " is a decent approximation of π";
sentence = "" + (22 / 7) + " is a decent approximation of π";

View file

@ -1,5 +1,7 @@
var city, forecast, temp, weatherReport, _ref;
weatherReport = function(location) {
return [location, 72, "Mostly Sunny"];
};
_ref = weatherReport("Berkeley, CA"), city = _ref[0], temp = _ref[1], forecast = _ref[2];
_ref = weatherReport("Berkeley, CA"), city = _ref[0], temp = _ref[1], forecast = _ref[2];

View file

@ -1,9 +1,11 @@
var age, ages, child, yearsOld;
yearsOld = {
max: 10,
ida: 9,
tim: 11
};
ages = (function() {
var _results;
_results = [];
@ -12,4 +14,4 @@ ages = (function() {
_results.push("" + child + " is " + age);
}
return _results;
})();
})();

View file

@ -1,4 +1,5 @@
var city, futurists, name, street, _ref, _ref2;
futurists = {
sculptor: "Umberto Boccioni",
painter: "Vladimir Burliuk",
@ -7,4 +8,5 @@ futurists = {
address: ["Via Roma 42R", "Bellagio, Italy 22021"]
}
};
_ref = futurists.poet, name = _ref.name, _ref2 = _ref.address, street = _ref2[0], city = _ref2[1];
_ref = futurists.poet, name = _ref.name, (_ref2 = _ref.address, street = _ref2[0], city = _ref2[1]);

View file

@ -1,10 +1,14 @@
var bitlist, kids, singers, song;
song = ["do", "re", "mi", "fa", "so"];
singers = {
Jagger: "Rock",
Elvis: "Roll"
};
bitlist = [1, 0, 1, 0, 0, 1, 1, 1, 0];
kids = {
brother: {
name: "Max",
@ -14,4 +18,4 @@ kids = {
name: "Ida",
age: 9
}
};
};

View file

@ -1,4 +1,6 @@
$('.account').attr({
"class": 'active'
});
log(object["class"]);
log(object["class"]);

View file

@ -1,14 +1,18 @@
var cubes, list, math, num, number, opposite, race, square;
var __slice = Array.prototype.slice;
number = 42;
opposite = true;
if (opposite) {
number = -42;
}
if (opposite) number = -42;
square = function(x) {
return x * x;
};
list = [1, 2, 3, 4, 5];
math = {
root: Math.sqrt,
square: square,
@ -16,14 +20,15 @@ math = {
return x * square(x);
}
};
race = function() {
var runners, winner;
winner = arguments[0], runners = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
return print(winner, runners);
};
if (typeof elvis !== "undefined" && elvis !== null) {
alert("I knew it!");
}
if (typeof elvis !== "undefined" && elvis !== null) alert("I knew it!");
cubes = (function() {
var _i, _len, _results;
_results = [];
@ -32,4 +37,4 @@ cubes = (function() {
_results.push(math.cube(num));
}
return _results;
})();
})();

View file

@ -1,4 +1,7 @@
var theBait, theSwitch, _ref;
theBait = 1000;
theSwitch = 0;
_ref = [theSwitch, theBait], theBait = _ref[0], theSwitch = _ref[1];
_ref = [theSwitch, theBait], theBait = _ref[0], theSwitch = _ref[1];

View file

@ -1,4 +1,6 @@
var close, contents, open, tag, _i, _ref;
var __slice = Array.prototype.slice;
tag = "<impossible>";
_ref = tag.split(""), open = _ref[0], contents = 3 <= _ref.length ? __slice.call(_ref, 1, _i = _ref.length - 1) : (_i = 1, []), close = _ref[_i++];
_ref = tag.split(""), open = _ref[0], contents = 3 <= _ref.length ? __slice.call(_ref, 1, _i = _ref.length - 1) : (_i = 1, []), close = _ref[_i++];

View file

@ -1,3 +1,4 @@
String.prototype.dasherize = function() {
return this.replace(/_/g, "-");
};
};

View file

@ -1,4 +1,5 @@
var countdown, num;
countdown = (function() {
var _results;
_results = [];
@ -6,4 +7,4 @@ countdown = (function() {
_results.push(num);
}
return _results;
})();
})();

View file

@ -1,8 +1,11 @@
var changeNumbers, inner, outer;
outer = 1;
changeNumbers = function() {
var inner;
inner = -1;
return outer = 10;
};
inner = changeNumbers();
inner = changeNumbers();

View file

@ -1,4 +1,7 @@
var copy, middle, numbers;
numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
copy = numbers.slice(0, numbers.length);
middle = copy.slice(3, 7);
middle = copy.slice(3, 7);

View file

@ -1,2 +1,3 @@
var zip, _ref;
zip = typeof lottery.drawWinner === "function" ? (_ref = lottery.drawWinner().address) != null ? _ref.zipcode : void 0 : void 0;
zip = typeof lottery.drawWinner === "function" ? (_ref = lottery.drawWinner().address) != null ? _ref.zipcode : void 0 : void 0;

View file

@ -1,6 +1,8 @@
var awardMedals, contenders, gold, rest, silver;
var __slice = Array.prototype.slice;
gold = silver = rest = "unknown";
awardMedals = function() {
var first, others, second;
first = arguments[0], second = arguments[1], others = 3 <= arguments.length ? __slice.call(arguments, 2) : [];
@ -8,8 +10,13 @@ awardMedals = function() {
silver = second;
return rest = others;
};
contenders = ["Michael Phelps", "Liu Xiang", "Yao Ming", "Allyson Felix", "Shawn Johnson", "Roman Sebrle", "Guo Jingjing", "Tyson Gay", "Asafa Powell", "Usain Bolt"];
awardMedals.apply(null, contenders);
alert("Gold: " + gold);
alert("Silver: " + silver);
alert("The Field: " + rest);
alert("The Field: " + rest);

View file

@ -1,3 +1,5 @@
var numbers, _ref;
numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
[].splice.apply(numbers, [3, 4].concat(_ref = [-3, -4, -5, -6])), _ref;
[].splice.apply(numbers, [3, 4].concat(_ref = [-3, -4, -5, -6])), _ref;

View file

@ -1,2 +1,3 @@
var mobyDick;
mobyDick = "Call me Ishmael. Some years ago -- never mind how long precisely -- having little or no money in my purse, and nothing particular to interest me on shore, I thought I would sail about a little and see the watery part of the world...";
mobyDick = "Call me Ishmael. Some years ago -- never mind how long precisely -- having little or no money in my purse, and nothing particular to interest me on shore, I thought I would sail about a little and see the watery part of the world...";

View file

@ -1,3 +1,4 @@
switch (day) {
case "Mon":
go(work);
@ -20,4 +21,4 @@ switch (day) {
break;
default:
go(work);
}
}

View file

@ -1,3 +1,4 @@
try {
allHellBreaksLoose();
catsAndDogsLivingTogether();
@ -5,4 +6,4 @@ try {
print(error);
} finally {
cleanUp();
}
}

View file

@ -1,4 +1,5 @@
var lyrics, num;
if (this.studyingEconomics) {
while (supply > demand) {
buy();
@ -7,7 +8,9 @@ if (this.studyingEconomics) {
sell();
}
}
num = 6;
lyrics = (function() {
var _results;
_results = [];
@ -15,4 +18,4 @@ lyrics = (function() {
_results.push("" + num + " little monkeys, jumping on the bed. One fell out and bumped his head.");
}
return _results;
})();
})();

File diff suppressed because it is too large Load diff