Docs improvements (#4367)

* The generated JavaScript for the examples in the docs ends up within index.html, so we don’t need the intermediate generated .js files committed in the repo; also, even while .gitignored they should be under `docs`, with the rest of the generated files, not under `documentation`, where the source files are.

* Add “Existential Operator” to the table of contents. Closes #4361

* Updated output due to newer version of highlight.js

* Generated the JavaScript for the docs examples should be synchronous, so that index.html isn’t generated before the JavaScript is

* In “Try CoffeeScript,” if you press the tab key it should type a tab character. Closes #3342.

* Rename doc example folders from `js` and `coffee` to just `examples`

* Add missing `yield` to the list of keywords to highlight until highlight.js catches up; update the class used to match highlight.js’ `keyword`

* `cake doc:site` should watch the example files too, not just index.html.js

* Remove examples folder, including underscore.coffee; remove link to annotated underscore.coffee
This commit is contained in:
Geoffrey Booth 2016-11-20 17:05:19 -08:00 committed by GitHub
parent 073e14746e
commit cc3be717a0
115 changed files with 93 additions and 4330 deletions

View File

@ -1,9 +1,9 @@
fs = require 'fs'
path = require 'path'
_ = require 'underscore'
CoffeeScript = require './lib/coffee-script'
{spawn, exec} = require 'child_process'
helpers = require './lib/coffee-script/helpers'
fs = require 'fs'
path = require 'path'
_ = require 'underscore'
{ spawn, exec, execSync } = require 'child_process'
CoffeeScript = require './lib/coffee-script'
helpers = require './lib/coffee-script/helpers'
# ANSI Terminal Colors.
bold = red = green = reset = ''
@ -51,15 +51,16 @@ codeFor = ->
hljs.configure classPrefix: ''
(file, executable = false, showLoad = true) ->
counter++
return unless fs.existsSync "documentation/js/#{file}.js"
cs = fs.readFileSync "documentation/coffee/#{file}.coffee", 'utf-8'
js = fs.readFileSync "documentation/js/#{file}.js", 'utf-8'
return unless fs.existsSync "docs/v#{majorVersion}/examples/#{file}.js"
cs = fs.readFileSync "documentation/examples/#{file}.coffee", 'utf-8'
js = fs.readFileSync "docs/v#{majorVersion}/examples/#{file}.js", 'utf-8'
js = js.replace /^\/\/ generated.*?\n/i, ''
cshtml = "<pre><code>#{hljs.highlight('coffeescript', cs).value}</code></pre>"
# Temporary fix until highlight.js adds support for newer CoffeeScript reserved words
if file is 'modules'
cshtml = cshtml.replace /(import|export|from|as|default) /g, '<span class="reserved">$1</span> '
# Temporary fix until highlight.js adds support for newer CoffeeScript keywords
# Added in https://github.com/isagalaev/highlight.js/pull/1357, awaiting release
if file in ['generators', 'modules']
cshtml = cshtml.replace /(yield|import|export|from|as|default) /g, '<span class="keyword">$1</span> '
jshtml = "<pre><code>#{hljs.highlight('javascript', js).value}</code></pre>"
append = if executable is yes then '' else "alert(#{executable});"
if executable and executable isnt yes
@ -175,24 +176,30 @@ task 'build:browser', 'rebuild the merged script for inclusion in the browser',
task 'doc:site', 'watch and continually rebuild the documentation for the website', ->
source = 'documentation/index.html.js'
exec 'bin/coffee -bc -o documentation/js documentation/coffee/*.coffee'
examplesSourceFolder = 'documentation/examples'
examplesOutputFolder = "docs/v#{majorVersion}/examples"
fs.mkdirSync examplesOutputFolder unless fs.existsSync examplesOutputFolder
do renderExamples = ->
execSync "bin/coffee -bc -o #{examplesOutputFolder} #{examplesSourceFolder}/*.coffee"
indexFile = 'documentation/index.html.js'
do renderIndex = ->
render = _.template fs.readFileSync(source, 'utf-8')
render = _.template fs.readFileSync(indexFile, 'utf-8')
output = render
codeFor: codeFor()
releaseHeader: releaseHeader
fs.writeFileSync "docs/v#{majorVersion}/index.html", output
log 'compiled', green, "#{source} → docs/v#{majorVersion}/index.html"
log 'compiled', green, "#{indexFile} → docs/v#{majorVersion}/index.html"
fs.watchFile source, interval: 200, renderIndex
fs.watch examplesSourceFolder, interval: 200, ->
renderExamples()
renderIndex()
fs.watch indexFile, interval: 200, renderIndex
log 'watching...' , green
task 'doc:source', 'rebuild the annotated source documentation', ->
for source in ['src/*.*coffee', 'examples/underscore.coffee']
exec "node_modules/docco/bin/docco #{source} --output docs/v#{majorVersion}/annotated-source", (err) -> throw err if err
exec "node_modules/docco/bin/docco src/*.*coffee --output docs/v#{majorVersion}/annotated-source", (err) -> throw err if err
task 'bench', 'quick benchmark of compilation time', ->

1
docs/v1/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
examples/

File diff suppressed because it is too large Load Diff

View File

@ -304,6 +304,10 @@ div.code {
outline: none;
margin: 5px 0 20px;
color: #def;
-webkit-tab-size: 2;
-moz-tab-size: 2;
-o-tab-size: 2;
tab-size: 2;
}
#repl_results, #repl_source_wrap {
width: auto; height: auto;

View File

@ -33,6 +33,7 @@
<a href="#slices">Array Slicing and Splicing</a>
<a href="#expressions">Everything is an Expression</a>
<a href="#operators">Operators and Aliases</a>
<a href="#existential-operator">Existential Operator</a>
<a href="#classes">Classes, Inheritance, and Super</a>
<a href="#destructuring">Destructuring Assignment</a>
<a href="#fat-arrow">Bound and Generator Functions</a>
@ -170,9 +171,9 @@ square = <span class="function"><span class="keyword">function</span>(<span clas
list = [<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>];
math = {
root: <span class="built_in">Math</span>.sqrt,
square: square,
cube: <span class="function"><span class="keyword">function</span>(<span class="params">x</span>) </span>{
<span class="attr">root</span>: <span class="built_in">Math</span>.sqrt,
<span class="attr">square</span>: square,
<span class="attr">cube</span>: <span class="function"><span class="keyword">function</span>(<span class="params">x</span>) </span>{
<span class="keyword">return</span> x * square(x);
}
};
@ -624,20 +625,20 @@ kids =
song = [<span class="string">"do"</span>, <span class="string">"re"</span>, <span class="string">"mi"</span>, <span class="string">"fa"</span>, <span class="string">"so"</span>];
singers = {
Jagger: <span class="string">"Rock"</span>,
Elvis: <span class="string">"Roll"</span>
<span class="attr">Jagger</span>: <span class="string">"Rock"</span>,
<span class="attr">Elvis</span>: <span class="string">"Roll"</span>
};
bitlist = [<span class="number">1</span>, <span class="number">0</span>, <span class="number">1</span>, <span class="number">0</span>, <span class="number">0</span>, <span class="number">1</span>, <span class="number">1</span>, <span class="number">1</span>, <span class="number">0</span>];
kids = {
brother: {
name: <span class="string">"Max"</span>,
age: <span class="number">11</span>
<span class="attr">brother</span>: {
<span class="attr">name</span>: <span class="string">"Max"</span>,
<span class="attr">age</span>: <span class="number">11</span>
},
sister: {
name: <span class="string">"Ida"</span>,
age: <span class="number">9</span>
<span class="attr">sister</span>: {
<span class="attr">name</span>: <span class="string">"Ida"</span>,
<span class="attr">age</span>: <span class="number">9</span>
}
};
</code></pre><script>window.example4 = "song = [\"do\", \"re\", \"mi\", \"fa\", \"so\"]\n\nsingers = {Jagger: \"Rock\", Elvis: \"Roll\"}\n\nbitlist = [\n 1, 0, 1\n 0, 0, 1\n 1, 1, 0\n]\n\nkids =\n brother:\n name: \"Max\"\n age: 11\n sister:\n name: \"Ida\"\n age: 9\n"</script><div class='minibutton load' onclick='javascript: loadConsole(example4);'>load</div><div class='minibutton ok' onclick='javascript: var bitlist, kids, singers, song;
@ -965,9 +966,9 @@ ages = <span class="keyword">for</span> child, age <span class="keyword">of</spa
</code></pre><pre><code><span class="keyword">var</span> age, ages, child, yearsOld;
yearsOld = {
max: <span class="number">10</span>,
ida: <span class="number">9</span>,
tim: <span class="number">11</span>
<span class="attr">max</span>: <span class="number">10</span>,
<span class="attr">ida</span>: <span class="number">9</span>,
<span class="attr">tim</span>: <span class="number">11</span>
};
ages = (<span class="function"><span class="keyword">function</span>(<span class="params"></span>) </span>{
@ -1403,6 +1404,7 @@ print(inspect(<span class="string">"My name is "</span> + <span class="keyword">
</code></pre><script>window.example21 = "launch() if ignition is on\n\nvolume = 10 if band isnt SpinalTap\n\nletTheWildRumpusBegin() unless answer is no\n\nif car.speed < limit then accelerate()\n\nwinner = yes if pick in [47, 92, 13]\n\nprint inspect \"My name is #{@name}\"\n"</script><div class='minibutton load' onclick='javascript: loadConsole(example21);'>load</div><br class='clear' /></div>
<p>
<span id="existential-operator" class="bookmark"></span>
<b class="header">The Existential Operator</b>
It's a little difficult to check for the existence of a variable in
JavaScript. <code>if (variable) ...</code> comes close, but fails for zero,
@ -1721,11 +1723,11 @@ ref = weatherReport("Berkeley, CA"), city = ref[0], temp = ref[1], forecast = re
</code></pre><pre><code><span class="keyword">var</span> city, futurists, name, ref, ref1, street;
futurists = {
sculptor: <span class="string">"Umberto Boccioni"</span>,
painter: <span class="string">"Vladimir Burliuk"</span>,
poet: {
name: <span class="string">"F.T. Marinetti"</span>,
address: [<span class="string">"Via Roma 42R"</span>, <span class="string">"Bellagio, Italy 22021"</span>]
<span class="attr">sculptor</span>: <span class="string">"Umberto Boccioni"</span>,
<span class="attr">painter</span>: <span class="string">"Vladimir Burliuk"</span>,
<span class="attr">poet</span>: {
<span class="attr">name</span>: <span class="string">"F.T. Marinetti"</span>,
<span class="attr">address</span>: [<span class="string">"Via Roma 42R"</span>, <span class="string">"Bellagio, Italy 22021"</span>]
}
};
@ -1802,8 +1804,8 @@ Person = (<span class="function"><span class="keyword">function</span>(<span cla
})();
tim = <span class="keyword">new</span> Person({
name: <span class="string">'Tim'</span>,
age: <span class="number">4</span>
<span class="attr">name</span>: <span class="string">'Tim'</span>,
<span class="attr">age</span>: <span class="number">4</span>
});
</code></pre><script>window.example31 = "class Person\n constructor: (options) ->\n {@name, @age, @height = 'average'} = options\n\ntim = new Person name: 'Tim', age: 4\n"</script><div class='minibutton load' onclick='javascript: loadConsole(example31);'>load</div><div class='minibutton ok' onclick='javascript: var Person, tim;
@ -1885,7 +1887,7 @@ Account = <span class="function"><span class="keyword">function</span>(<span cla
num = <span class="number">0</span>
<span class="keyword">loop</span>
num += <span class="number">1</span>
yield num * num
<span class="keyword">yield</span> num * num
<span class="keyword">return</span>
<span class="built_in">window</span>.ps <span class="keyword">or</span>= perfectSquares()
@ -2183,28 +2185,28 @@ OPERATOR = <span class="regexp">/^(?:[-=]&gt;|[-+*\/%&lt;&gt;&amp;|^!?=]=|&gt;&g
ES2015 modules are supported in CoffeeScript, with very similar <code>import</code>
and <code>export</code> syntax:
</p>
<div class='code'><pre><code><span class="reserved">import</span> <span class="string">'local-file.coffee'</span>
<span class="reserved">import</span> <span class="string">'coffee-script'</span>
<div class='code'><pre><code><span class="keyword">import</span> <span class="string">'local-file.coffee'</span>
<span class="keyword">import</span> <span class="string">'coffee-script'</span>
<span class="reserved">import</span> _ <span class="reserved">from</span> <span class="string">'underscore'</span>
<span class="reserved">import</span> * <span class="reserved">as</span> underscore <span class="reserved">from</span> <span class="string">'underscore'</span>
<span class="keyword">import</span> _ <span class="keyword">from</span> <span class="string">'underscore'</span>
<span class="keyword">import</span> * <span class="keyword">as</span> underscore <span class="keyword">from</span> <span class="string">'underscore'</span>
<span class="reserved">import</span> { now } <span class="reserved">from</span> <span class="string">'underscore'</span>
<span class="reserved">import</span> { now <span class="reserved">as</span> currentTimestamp } <span class="reserved">from</span> <span class="string">'underscore'</span>
<span class="reserved">import</span> { first, last } <span class="reserved">from</span> <span class="string">'underscore'</span>
<span class="reserved">import</span> utilityBelt, { each } <span class="reserved">from</span> <span class="string">'underscore'</span>
<span class="keyword">import</span> { now } <span class="keyword">from</span> <span class="string">'underscore'</span>
<span class="keyword">import</span> { now <span class="keyword">as</span> currentTimestamp } <span class="keyword">from</span> <span class="string">'underscore'</span>
<span class="keyword">import</span> { first, last } <span class="keyword">from</span> <span class="string">'underscore'</span>
<span class="keyword">import</span> utilityBelt, { each } <span class="keyword">from</span> <span class="string">'underscore'</span>
<span class="reserved">export</span> <span class="reserved">default</span> Math
<span class="reserved">export</span> square = <span class="function"><span class="params">(x)</span> -&gt;</span> x * x
<span class="reserved">export</span> <span class="class"><span class="keyword">class</span> <span class="title">Mathematics</span></span>
<span class="keyword">export</span> <span class="keyword">default</span> Math
<span class="keyword">export</span> square = <span class="function"><span class="params">(x)</span> -&gt;</span> x * x
<span class="keyword">export</span> <span class="class"><span class="keyword">class</span> <span class="title">Mathematics</span></span>
least: <span class="function"><span class="params">(x, y)</span> -&gt;</span> <span class="keyword">if</span> x &lt; y <span class="keyword">then</span> x <span class="keyword">else</span> y
<span class="reserved">export</span> { sqrt }
<span class="reserved">export</span> { sqrt <span class="reserved">as</span> squareRoot }
<span class="reserved">export</span> { Mathematics <span class="reserved">as</span> default, sqrt <span class="reserved">as</span> squareRoot }
<span class="keyword">export</span> { sqrt }
<span class="keyword">export</span> { sqrt <span class="keyword">as</span> squareRoot }
<span class="keyword">export</span> { Mathematics <span class="keyword">as</span> default, sqrt <span class="keyword">as</span> squareRoot }
<span class="reserved">export</span> * <span class="reserved">from</span> <span class="string">'underscore'</span>
<span class="reserved">export</span> { max, min } <span class="reserved">from</span> <span class="string">'underscore'</span>
<span class="keyword">export</span> * <span class="keyword">from</span> <span class="string">'underscore'</span>
<span class="keyword">export</span> { max, min } <span class="keyword">from</span> <span class="string">'underscore'</span>
</code></pre><pre><code><span class="keyword">import</span> <span class="string">'local-file.coffee'</span>;
<span class="keyword">import</span> <span class="string">'coffee-script'</span>;
@ -2509,11 +2511,6 @@ task(<span class="string">'build:parser'</span>, <span class="string">'rebuild t
<b>assaf</b>'s <a href="http://zombie.labnotes.org/">Zombie.js</a>,
a headless, full-stack, faux-browser testing library for Node.js.
</li>
<li>
<b>jashkenas</b>' <a href="v1/annotated-source/underscore.html">Underscore.coffee</a>, a port
of the <a href="http://documentcloud.github.com/underscore/">Underscore.js</a>
library of helper functions.
</li>
<li>
<b>stephank</b>'s <a href="https://github.com/stephank/orona">Orona</a>, a remake of
the Bolo tank game for modern browsers.
@ -3890,6 +3887,16 @@ six = -&gt;
# Listen for keypresses and recompile.
$('#repl_source').keyup -> compileSource()
# Use tab key to insert tabs
$('#repl_source').keydown (e) ->
if e.keyCode is 9
e.preventDefault()
textbox = e.target
# Insert tab character at caret or in selection
textbox.value = textbox.value[0...textbox.selectionStart] + "\t" + textbox.value[textbox.selectionEnd...]
# Put caret in correct position
textbox.selectionEnd = ++textbox.selectionStart
# Eval the compiled js.
evalJS = ->
try

View File

@ -33,6 +33,7 @@
<a href="#slices">Array Slicing and Splicing</a>
<a href="#expressions">Everything is an Expression</a>
<a href="#operators">Operators and Aliases</a>
<a href="#existential-operator">Existential Operator</a>
<a href="#classes">Classes, Inheritance, and Super</a>
<a href="#destructuring">Destructuring Assignment</a>
<a href="#fat-arrow">Bound and Generator Functions</a>
@ -716,6 +717,7 @@ Block
<%= codeFor('aliases') %>
<p>
<span id="existential-operator" class="bookmark"></span>
<b class="header">The Existential Operator</b>
It's a little difficult to check for the existence of a variable in
JavaScript. <code>if (variable) ...</code> comes close, but fails for zero,
@ -1183,11 +1185,6 @@ Block
<b>assaf</b>'s <a href="http://zombie.labnotes.org/">Zombie.js</a>,
a headless, full-stack, faux-browser testing library for Node.js.
</li>
<li>
<b>jashkenas</b>' <a href="v1/annotated-source/underscore.html">Underscore.coffee</a>, a port
of the <a href="http://documentcloud.github.com/underscore/">Underscore.js</a>
library of helper functions.
</li>
<li>
<b>stephank</b>'s <a href="https://github.com/stephank/orona">Orona</a>, a remake of
the Bolo tank game for modern browsers.
@ -2315,6 +2312,16 @@ six = -&gt;
# Listen for keypresses and recompile.
$('#repl_source').keyup -> compileSource()
# Use tab key to insert tabs
$('#repl_source').keydown (e) ->
if e.keyCode is 9
e.preventDefault()
textbox = e.target
# Insert tab character at caret or in selection
textbox.value = textbox.value[0...textbox.selectionStart] + "\t" + textbox.value[textbox.selectionEnd...]
# Put caret in correct position
textbox.selectionEnd = ++textbox.selectionStart
# Eval the compiled js.
evalJS = ->
try

View File

@ -1,24 +0,0 @@
// Generated by CoffeeScript 1.11.1
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));

View File

@ -1,24 +0,0 @@
// Generated by CoffeeScript 1.11.1
var courses, dish, food, foods, i, j, k, l, len, len1, len2, ref;
ref = ['toast', 'cheese', 'wine'];
for (j = 0, len = ref.length; j < len; j++) {
food = ref[j];
eat(food);
}
courses = ['greens', 'caviar', 'truffles', 'roast', 'cake'];
for (i = k = 0, len1 = courses.length; k < len1; i = ++k) {
dish = courses[i];
menu(i + 1, dish);
}
foods = ['broccoli', 'spinach', 'chocolate'];
for (l = 0, len2 = foods.length; l < len2; l++) {
food = foods[l];
if (food !== 'chocolate') {
eat(food);
}
}

View File

@ -1,7 +0,0 @@
// Generated by CoffeeScript 1.11.1
/*
SkinnyMochaHalfCaffScript Compiler v1.0
Released under the MIT License
*/

View File

@ -1,14 +0,0 @@
// Generated by CoffeeScript 1.11.1
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,4 +0,0 @@
// Generated by CoffeeScript 1.11.1
$('body').click(function(e) {
return $('.box').fadeIn('fast').addClass('.active');
}).css('background', 'white');

View File

@ -1,57 +0,0 @@
// Generated by CoffeeScript 1.11.1
var Animal, Horse, Snake, sam, tom,
extend = 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; },
hasProp = {}.hasOwnProperty;
Animal = (function() {
function Animal(name) {
this.name = name;
}
Animal.prototype.move = function(meters) {
return alert(this.name + (" moved " + meters + "m."));
};
return Animal;
})();
Snake = (function(superClass) {
extend(Snake, superClass);
function Snake() {
return Snake.__super__.constructor.apply(this, arguments);
}
Snake.prototype.move = function() {
alert("Slithering...");
return Snake.__super__.move.call(this, 5);
};
return Snake;
})(Animal);
Horse = (function(superClass) {
extend(Horse, superClass);
function Horse() {
return Horse.__super__.constructor.apply(this, arguments);
}
Horse.prototype.move = function() {
alert("Galloping...");
return Horse.__super__.move.call(this, 45);
};
return Horse;
})(Animal);
sam = new Snake("Sammy the Python");
tom = new Horse("Tommy the Palomino");
sam.move();
tom.move();

View File

@ -1,6 +0,0 @@
// Generated by CoffeeScript 1.11.1
var cholesterol, healthy;
cholesterol = 127;
healthy = (200 > cholesterol && cholesterol > 60);

View File

@ -1,15 +0,0 @@
// Generated by CoffeeScript 1.11.1
var date, mood;
if (singing) {
mood = greatlyImproved;
}
if (happy && knowsIt) {
clapsHands();
chaChaCha();
} else {
showIt();
}
date = friday ? sue : jill;

View File

@ -1,17 +0,0 @@
// Generated by CoffeeScript 1.11.1
var Person, tim;
Person = (function() {
function Person(options) {
var ref;
this.name = options.name, this.age = options.age, this.height = (ref = options.height) != null ? ref : 'average';
}
return Person;
})();
tim = new Person({
name: 'Tim',
age: 4
});

View File

@ -1,9 +0,0 @@
// Generated by CoffeeScript 1.11.1
var fill;
fill = function(container, liquid) {
if (liquid == null) {
liquid = "coffee";
}
return "Filling the " + container + " with " + liquid + "...";
};

View File

@ -1,12 +0,0 @@
// Generated by CoffeeScript 1.11.1
var filename, fn, i, len;
fn = function(filename) {
return fs.readFile(filename, function(err, contents) {
return compile(filename, contents.toString());
});
};
for (i = 0, len = list.length; i < len; i++) {
filename = list[i];
fn(filename);
}

View File

@ -1,6 +0,0 @@
// Generated by CoffeeScript 1.11.1
var hi;
hi = function() {
return [document.title, "Hello JavaScript"].join(": ");
};

View File

@ -1,14 +0,0 @@
// Generated by CoffeeScript 1.11.1
var footprints, solipsism, speed;
if ((typeof mind !== "undefined" && mind !== null) && (typeof world === "undefined" || world === null)) {
solipsism = true;
}
speed = 0;
if (speed == null) {
speed = 15;
}
footprints = typeof yeti !== "undefined" && yeti !== null ? yeti : "bear";

View File

@ -1,6 +0,0 @@
// Generated by CoffeeScript 1.11.1
var first, last, ref, text;
text = "Every literary critic believes he will outwit history and have the last word";
ref = text.split(" "), first = ref[0], last = ref[ref.length - 1];

View File

@ -1,18 +0,0 @@
// Generated by CoffeeScript 1.11.1
var eldest, grade;
grade = function(student) {
if (student.excellentWork) {
return "A+";
} else if (student.okayStuff) {
if (student.triedHard) {
return "B";
} else {
return "B-";
}
} else {
return "C";
}
};
eldest = 24 > 21 ? "Liz" : "Ike";

View File

@ -1,4 +0,0 @@
// Generated by CoffeeScript 1.11.1
var one, six, three, two;
six = (one = 1) + (two = 2) + (three = 3);

View File

@ -1,11 +0,0 @@
// Generated by CoffeeScript 1.11.1
var globals, name;
globals = ((function() {
var results;
results = [];
for (name in window) {
results.push(name);
}
return results;
})()).slice(0, 10);

View File

@ -1,11 +0,0 @@
// Generated by CoffeeScript 1.11.1
var error;
alert((function() {
try {
return nonexistent / void 0;
} catch (error1) {
error = error1;
return "And the error is ... " + error;
}
})());

View File

@ -1,12 +0,0 @@
// Generated by CoffeeScript 1.11.1
var Account;
Account = function(customer, cart) {
this.customer = customer;
this.cart = cart;
return $('.shopping_cart').on('click', (function(_this) {
return function(event) {
return _this.customer.purchase(_this.cart);
};
})(this));
};

View File

@ -1,10 +0,0 @@
// Generated by CoffeeScript 1.11.1
var cube, square;
square = function(x) {
return x * x;
};
cube = function(x) {
return square(x) * x;
};

View File

@ -1,13 +0,0 @@
// Generated by CoffeeScript 1.11.1
var perfectSquares;
perfectSquares = function*() {
var num;
num = 0;
while (true) {
num += 1;
yield num * num;
}
};
window.ps || (window.ps = perfectSquares());

View File

@ -1,4 +0,0 @@
// Generated by CoffeeScript 1.11.1
var html;
html = "<strong>\n cup of coffeescript\n</strong>";

View File

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

View File

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

View File

@ -1,66 +0,0 @@
// Generated by CoffeeScript 1.11.1
import 'local-file.coffee';
import 'coffee-script';
import _ from 'underscore';
import * as underscore from 'underscore';
import {
now
} from 'underscore';
import {
now as currentTimestamp
} from 'underscore';
import {
first,
last
} from 'underscore';
import utilityBelt, {
each
} from 'underscore';
export default Math;
export var square = function(x) {
return x * x;
};
export var Mathematics = (function() {
function Mathematics() {}
Mathematics.prototype.least = function(x, y) {
if (x < y) {
return x;
} else {
return y;
}
};
return Mathematics;
})();
export {
sqrt
};
export {
sqrt as squareRoot
};
export {
Mathematics as default,
sqrt as squareRoot
};
export * from 'underscore';
export {
max,
min
} from 'underscore';

View File

@ -1,8 +0,0 @@
// Generated by CoffeeScript 1.11.1
var modulo = function(a, b) { return (+a % (b = +b) + b) % b; };
-7 % 5 === -2;
modulo(-7, 5) === 3;
tabs.selectTabAtIndex(modulo(tabs.currentIndex - count, tabs.length));

View File

@ -1,8 +0,0 @@
// Generated by CoffeeScript 1.11.1
var city, forecast, ref, temp, weatherReport;
weatherReport = function(location) {
return [location, 72, "Mostly Sunny"];
};
ref = weatherReport("Berkeley, CA"), city = ref[0], temp = ref[1], forecast = ref[2];

View File

@ -1,18 +0,0 @@
// Generated by CoffeeScript 1.11.1
var age, ages, child, yearsOld;
yearsOld = {
max: 10,
ida: 9,
tim: 11
};
ages = (function() {
var results;
results = [];
for (child in yearsOld) {
age = yearsOld[child];
results.push(child + " is " + age);
}
return results;
})();

View File

@ -1,13 +0,0 @@
// Generated by CoffeeScript 1.11.1
var city, futurists, name, ref, ref1, street;
futurists = {
sculptor: "Umberto Boccioni",
painter: "Vladimir Burliuk",
poet: {
name: "F.T. Marinetti",
address: ["Via Roma 42R", "Bellagio, Italy 22021"]
}
};
ref = futurists.poet, name = ref.name, (ref1 = ref.address, street = ref1[0], city = ref1[1]);

View File

@ -1,22 +0,0 @@
// Generated by CoffeeScript 1.11.1
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",
age: 11
},
sister: {
name: "Ida",
age: 9
}
};

View File

@ -1,6 +0,0 @@
// Generated by CoffeeScript 1.11.1
$('.account').attr({
"class": 'active'
});
log(object["class"]);

View File

@ -1,45 +0,0 @@
// Generated by CoffeeScript 1.11.1
var cubes, list, math, num, number, opposite, race, square,
slice = [].slice;
number = 42;
opposite = true;
if (opposite) {
number = -42;
}
square = function(x) {
return x * x;
};
list = [1, 2, 3, 4, 5];
math = {
root: Math.sqrt,
square: square,
cube: function(x) {
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!");
}
cubes = (function() {
var i, len, results;
results = [];
for (i = 0, len = list.length; i < len; i++) {
num = list[i];
results.push(math.cube(num));
}
return results;
})();

View File

@ -1,8 +0,0 @@
// Generated by CoffeeScript 1.11.1
var ref, theBait, theSwitch;
theBait = 1000;
theSwitch = 0;
ref = [theSwitch, theBait], theBait = ref[0], theSwitch = ref[1];

View File

@ -1,7 +0,0 @@
// Generated by CoffeeScript 1.11.1
var close, contents, i, open, ref, tag,
slice = [].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++];

View File

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

View File

@ -1,11 +0,0 @@
// Generated by CoffeeScript 1.11.1
var countdown, num;
countdown = (function() {
var i, results;
results = [];
for (num = i = 10; i >= 1; num = --i) {
results.push(num);
}
return results;
})();

View File

@ -1,12 +0,0 @@
// Generated by CoffeeScript 1.11.1
var changeNumbers, inner, outer;
outer = 1;
changeNumbers = function() {
var inner;
inner = -1;
return outer = 10;
};
inner = changeNumbers();

View File

@ -1,12 +0,0 @@
// Generated by CoffeeScript 1.11.1
var copy, end, middle, numbers, start;
numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9];
start = numbers.slice(0, 3);
middle = numbers.slice(3, -2);
end = numbers.slice(-2);
copy = numbers.slice(0);

View File

@ -1,4 +0,0 @@
// Generated by CoffeeScript 1.11.1
var ref, zip;
zip = typeof lottery.drawWinner === "function" ? (ref = lottery.drawWinner().address) != null ? ref.zipcode : void 0 : void 0;

View File

@ -1,23 +0,0 @@
// Generated by CoffeeScript 1.11.1
var awardMedals, contenders, gold, rest, silver,
slice = [].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) : [];
gold = first;
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);

View File

@ -1,6 +0,0 @@
// Generated by CoffeeScript 1.11.1
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;

View File

@ -1,4 +0,0 @@
// Generated by CoffeeScript 1.11.1
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...";

View File

@ -1,24 +0,0 @@
// Generated by CoffeeScript 1.11.1
switch (day) {
case "Mon":
go(work);
break;
case "Tue":
go(relax);
break;
case "Thu":
go(iceFishing);
break;
case "Fri":
case "Sat":
if (day === bingoDay) {
go(bingo);
go(dancing);
}
break;
case "Sun":
go(church);
break;
default:
go(work);
}

View File

@ -1,19 +0,0 @@
// Generated by CoffeeScript 1.11.1
var grade, score;
score = 76;
grade = (function() {
switch (false) {
case !(score < 60):
return 'F';
case !(score < 70):
return 'D';
case !(score < 80):
return 'C';
case !(score < 90):
return 'B';
default:
return 'A';
}
})();

View File

@ -1,12 +0,0 @@
// Generated by CoffeeScript 1.11.1
var error;
try {
allHellBreaksLoose();
catsAndDogsLivingTogether();
} catch (error1) {
error = error1;
print(error);
} finally {
cleanUp();
}

View File

@ -1,22 +0,0 @@
// Generated by CoffeeScript 1.11.1
var lyrics, num;
if (this.studyingEconomics) {
while (supply > demand) {
buy();
}
while (!(supply > demand)) {
sell();
}
}
num = 6;
lyrics = (function() {
var results;
results = [];
while (num -= 1) {
results.push(num + " little monkeys, jumping on the bed. One fell out and bumped his head.");
}
return results;
})();

View File

@ -1,16 +0,0 @@
# Beautiful Code, Chapter 6.
# The implementation of binary search that is tested.
# Return the index of an element in a sorted list. (or -1, if not present)
index = (list, target) ->
[low, high] = [0, list.length]
while low < high
mid = (low + high) >> 1
val = list[mid]
return mid if val is target
if val < target then low = mid + 1 else high = mid
return -1
console.log 2 is index [10, 20, 30, 40, 50], 30
console.log 4 is index [-97, 35, 67, 88, 1200], 1200
console.log 0 is index [0, 45, 70], 0

View File

@ -1,13 +0,0 @@
# Beautiful Code, Chapter 3.
# Produces the expected runtime of Quicksort, for every integer from 1 to N.
runtime = (N) ->
[sum, t] = [0, 0]
for n in [1..N]
sum += 2 * t
t = n - 1 + sum / n
t
console.log runtime(3) is 2.6666666666666665
console.log runtime(5) is 7.4
console.log runtime(8) is 16.92142857142857

Some files were not shown because too many files have changed in this diff Show More