From 844c7569400539fca2e54831a1924af73b007bfa Mon Sep 17 00:00:00 2001 From: Jeremy Ashkenas Date: Sat, 13 Feb 2010 16:23:03 -0500 Subject: [PATCH] working 'Try CoffeeScript' in the docs --- documentation/css/docs.css | 17 ++++++++++++--- documentation/index.html.erb | 33 ++++++++++++++++++++++++++++++ index.html | 33 ++++++++++++++++++++++++++++++ lib/coffee_script/coffee-script.js | 5 +++++ src/coffee-script.coffee | 9 ++++---- 5 files changed, 90 insertions(+), 7 deletions(-) diff --git a/documentation/css/docs.css b/documentation/css/docs.css index b105dd83..9b455e45 100644 --- a/documentation/css/docs.css +++ b/documentation/css/docs.css @@ -43,7 +43,7 @@ table { td { padding: 9px 15px 9px 0; } -code, pre, tt { +code, pre, tt, textarea { font-family: Monaco, Consolas, "Lucida Console", monospace; font-size: 12px; line-height: 18px; @@ -75,7 +75,7 @@ div.code { position: absolute; right: 8px; bottom: 8px; } - div.code pre { + div.code pre, div.code textarea { float: left; width: 450px; border-left: 1px dotted #559; @@ -84,4 +84,15 @@ div.code { } div.code pre:first-child { border-left: 0; - } \ No newline at end of file + } + +#repl_source { + border: 0; + padding: 5px 7px; + margin-left: 5px; + height: 250px; + resize: none; +} +#repl_results { + height: 260px; +} \ No newline at end of file diff --git a/documentation/index.html.erb b/documentation/index.html.erb index 1d339828..70bb5d37 100644 --- a/documentation/index.html.erb +++ b/documentation/index.html.erb @@ -59,6 +59,7 @@

Mini Overview
Installation and Usage
+ Try CoffeeScript
Significant Whitespace
Functions and Invocation
Assignment
@@ -224,6 +225,25 @@ coffee --interactive coffee --watch --lint experimental.coffee coffee --print app/scripts/*.coffee > concatenation.js +

Try CoffeeScript

+ +

+ Here's a live version of the CoffeeScript compiler, running within + your browser.
Hit the compile button to generate JavaScript + on the right-hand side. + You can also paste in any of the examples from below. +

+ +
+ +

+      
+      
+
+

Language Reference

@@ -832,5 +852,18 @@ coffee --print app/scripts/*.coffee > concatenation.js + + diff --git a/index.html b/index.html index 12a24f77..4919d90a 100644 --- a/index.html +++ b/index.html @@ -45,6 +45,7 @@

Mini Overview
Installation and Usage
+ Try CoffeeScript
Significant Whitespace
Functions and Invocation
Assignment
@@ -321,6 +322,25 @@ coffee --interactive coffee --watch --lint experimental.coffee coffee --print app/scripts/*.coffee > concatenation.js +

Try CoffeeScript

+ +

+ Here's a live version of the CoffeeScript compiler, running within + your browser.
Hit the compile button to generate JavaScript + on the right-hand side. + You can also paste in any of the examples from below. +

+ +
+ +

+      
+      
+
+

Language Reference

@@ -1703,5 +1723,18 @@ html = &q + + diff --git a/lib/coffee_script/coffee-script.js b/lib/coffee_script/coffee-script.js index 35846069..4df4dcaf 100644 --- a/lib/coffee_script/coffee-script.js +++ b/lib/coffee_script/coffee-script.js @@ -1,5 +1,6 @@ (function(){ var compiler, lexer, parser, path; + // Set up for both the browser and the server. if ((typeof process !== "undefined" && process !== null)) { process.mixin(require('./nodes')); path = require('path'); @@ -31,6 +32,10 @@ return this.pos; } }; + // Improved error messages. + parser.parseError = function parseError(message, hash) { + throw new Error('Unexpected ' + hash.token + ' on line ' + hash.line); + }; exports.VERSION = '0.5.0'; // Compile CoffeeScript to JavaScript, using the Coffee/Jison compiler. exports.compile = function compile(code, options) { diff --git a/src/coffee-script.coffee b/src/coffee-script.coffee index 4a03d1a7..ac8cfbc8 100644 --- a/src/coffee-script.coffee +++ b/src/coffee-script.coffee @@ -1,3 +1,4 @@ +# Set up for both the browser and the server. if process? process.mixin require './nodes' path: require('path') @@ -23,6 +24,10 @@ parser.lexer: { showPosition: -> @pos } +# Improved error messages. +parser.parseError: (message, hash) -> + throw new Error 'Unexpected ' + hash.token + ' on line ' + hash.line + exports.VERSION: '0.5.0' # Compile CoffeeScript to JavaScript, using the Coffee/Jison compiler. @@ -78,7 +83,3 @@ exports.ruby_compile_files: (paths, callback) -> return unless message puts message throw new Error "CoffeeScript compile error" - - - -