HTML5 Zone is brought to you in partnership with:

Chris Smith writes coffeescriptlove.com, a fan blog dedicated to that devastatingly elegant "little language that compiles into JavaScript." He loves programming, and software development in general, with a career arc that traces the ascendance of Java, then that of Ruby on Rails, and is now aligning with the power and possibilities of today's browser technologies. He is currently writing an interactive ebook on Backbone.js and CoffeeScript (backbonecoffeescript.com). Chris is a DZone MVB and is not an employee of DZone and has posted 18 posts at DZone. You can read more from them at their website. View Full User Profile

Literate CoffeeScript

02.28.2013
| 2542 views |
  • submit to reddit

  CoffeeScript 1.5.0 was released Monday! Although CoffeeScript Love is still anxiously awaiting support for source maps, this release contains something really cool.

Version 1.5 introduces Literate CoffeeScript, an implementation of literate programming, which now enables you to generate plush, Markdown-based documentation from your CoffeeScript programming code. That CoffeeScript creator Jeremy Ashkenas enthusiastically pushed through this feature should come as no surprise. It is a natural extension of his earlier Docco project. Docco uses a side-by-side layout for commentary and code, whereas Literate CoffeeScript appears to be inline, but they both look fabulous. I really admire Jeremy's attention to aesthetics in these projects.

Just take a look at this initial example from the CoffeeScript compiler.



This is how the source for the same output looks in a text editor with syntax highlighting.



So, if you're writing a library in CoffeeScript, consider doing it literate-style. And if that isn't enough excitement for one day, for item in list by -1 now enables you to iterate backwards!
Published at DZone with permission of Chris Smith, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)