mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-01-14 01:07:55 -05:00
* Replace tiny bitmaps with base64-encoded URIs
* Optimize SVGs; replace logo PNG with SVG
* Modernize favicon
* Embed CSS; a bit unorthodox, but we’re a single page so there’s no point in separate .css files and their separate HTTP requests
* Documentation is now markdown, converted to HTML on compilation
* Render the examples when we’re rendering index.html; they compile so quickly that there’s no need to pre-render them and save the intermediate .js files
* Split apart index.html into components that Cakefile assembles, so that we can add in logic to include different files for v1 versus v2
* Split building index.html and building test.html into two tasks; collapse the parts of `releaseHeader` into one compact function
* Move include logic into templates
* Get error messages tests to work in the browser
* Update output index.html
* Split body into nav and body
* Watch subtemplates
* Revert "Split body into nav and body"
This reverts commit ec9e559ec0.
* Add marked
* Update gitignore
* Use idiomatic markdown output for code blocks (<pre><code>)
* Handle ids within the template, not in the Cakefile; remove marked’s auto-generated and conflicting ids
* Move the `codeFor` function into versioned folders, so that v1 and v2 docs can have different example code blocks/editors
* Update packages, including new highlight.js which supports our newer keywords and triple backticks (docs output is unchanged)
26 lines
1.3 KiB
CoffeeScript
26 lines
1.3 KiB
CoffeeScript
fs = require 'fs'
|
|
CoffeeScript = require '../../lib/coffee-script'
|
|
|
|
|
|
module.exports = ->
|
|
counter = 0
|
|
hljs = require 'highlight.js'
|
|
hljs.configure classPrefix: ''
|
|
(file, executable = no, showLoad = yes) ->
|
|
counter++
|
|
cs = fs.readFileSync "documentation/examples/#{file}.coffee", 'utf-8'
|
|
js = CoffeeScript.compile cs, bare: yes
|
|
js = js.replace /^\/\/ generated.*?\n/i, ''
|
|
|
|
cshtml = "<pre><code>#{hljs.highlight('coffeescript', cs).value}</code></pre>"
|
|
jshtml = "<pre><code>#{hljs.highlight('javascript', js).value}</code></pre>"
|
|
append = if executable is yes then '' else "alert(#{executable});".replace /"/g, '"'
|
|
if executable and executable isnt yes
|
|
cs.replace /(\S)\s*\Z/m, "$1\n\nalert #{executable}"
|
|
run = if executable is yes then 'run' else "run: #{executable}"
|
|
name = "example#{counter}"
|
|
script = "<script>window.#{name} = #{JSON.stringify cs}</script>"
|
|
load = if showLoad then "<div class='minibutton load' onclick='javascript: loadConsole(#{name});'>load</div>" else ''
|
|
button = if executable then """<div class="minibutton ok" onclick="javascript: #{js.replace /"/g, '"'};#{append}">#{run}</div>""" else ''
|
|
"<div class='code'>#{cshtml}#{jshtml}#{script}#{load}#{button}<br class='clear' /></div>"
|