diff --git a/Cakefile b/Cakefile index 4d8af3c1..00fa5bfc 100644 --- a/Cakefile +++ b/Cakefile @@ -131,13 +131,9 @@ task 'doc:site', 'watch and continually rebuild the documentation for the websit # Constants indexFile = 'documentation/index.html' bodyFile = "documentation/v#{majorVersion}/body.html" - testFile = 'documentation/test.html' sectionsSourceFolder = 'documentation/sections' examplesSourceFolder = 'documentation/examples' - testsSourceFolder = 'test' outputFolder = "docs/v#{majorVersion}" - monthNames = ['January', 'February', 'March', 'April', 'May', 'June', - 'July', 'August', 'September', 'October', 'November', 'December'] jQueryVersion = if majorVersion is 1 then '1.12.4' else '3.1.1' # Included in index.html @@ -155,10 +151,23 @@ task 'doc:site', 'watch and continually rebuild the documentation for the websit docsScript = fs.readFileSync "documentation/v#{majorVersion}/docs.coffee", 'utf-8' - # Included in test.html - testHelpers = fs.readFileSync('test/support/helpers.coffee', 'utf-8').replace /exports\./g, '@' - # Helpers + releaseHeader = (date, version, prevVersion) -> + monthNames = ['January', 'February', 'March', 'April', 'May', 'June', + 'July', 'August', 'September', 'October', 'November', 'December'] + + formatDate = (date) -> + date.replace /^(\d\d\d\d)-(\d\d)-(\d\d)$/, (match, $1, $2, $3) -> + "#{monthNames[$2 - 1]} #{+$3}, #{$1}" + + """ +
+

+ #{prevVersion and "#{version}" or version} + +

+ """ + codeFor = -> counter = 0 hljs = require 'highlight.js' @@ -185,18 +194,6 @@ task 'doc:site', 'watch and continually rebuild the documentation for the websit button = if executable then """
#{run}
""" else '' "
#{cshtml}#{jshtml}#{script}#{load}#{button}
" - formatDate = (date) -> - date.replace /^(\d\d\d\d)-(\d\d)-(\d\d)$/, (match, $1, $2, $3) -> - "#{monthNames[$2 - 1]} #{+$3}, #{$1}" - - releaseHeader = (date, version, prevVersion) -> """ -
-

- #{prevVersion and "#{version}" or version} - -

- """ - htmlFor = -> marked = require 'marked' markdownRenderer = new marked.Renderer() @@ -227,10 +224,40 @@ task 'doc:site', 'watch and continually rebuild the documentation for the websit htmlFor: htmlFor() codeFor: codeFor() + # Task + do renderIndex = -> + render = _.template fs.readFileSync(indexFile, 'utf-8') + output = render + css: css + body: body() + script: docsScript + jQueryVersion: jQueryVersion + majorVersion: majorVersion + fs.writeFileSync "#{outputFolder}/index.html", output + log 'compiled', green, "#{indexFile} → #{outputFolder}/index.html" + try + fs.symlinkSync "v#{majorVersion}/index.html", 'docs/index.html' + catch exception + + for target in [indexFile, examplesSourceFolder, sectionsSourceFolder] + fs.watch target, interval: 200, renderIndex + log 'watching...' , green + + +task 'doc:test', 'watch and continually rebuild the browser-based tests', -> + # Constants + testFile = 'documentation/test.html' + testsSourceFolder = 'test' + outputFolder = "docs/v#{majorVersion}" + + # Included in test.html + testHelpers = fs.readFileSync('test/support/helpers.coffee', 'utf-8').replace /exports\./g, '@' + + # Helpers testsInScriptBlocks = -> output = '' excludedTestFiles = ['error_messages.coffee'] - for filename in fs.readdirSync 'test' + for filename in fs.readdirSync testsSourceFolder continue if filename in excludedTestFiles if filename.indexOf('.coffee') isnt -1 @@ -250,20 +277,6 @@ task 'doc:site', 'watch and continually rebuild the documentation for the websit output # Task - do renderIndex = -> - render = _.template fs.readFileSync(indexFile, 'utf-8') - output = render - css: css - body: body() - script: docsScript - jQueryVersion: jQueryVersion - majorVersion: majorVersion - fs.writeFileSync "#{outputFolder}/index.html", output - log 'compiled', green, "#{indexFile} → #{outputFolder}/index.html" - try - fs.symlinkSync "v#{majorVersion}/index.html", 'docs/index.html' - catch exception - do renderTest = -> render = _.template fs.readFileSync(testFile, 'utf-8') output = render @@ -273,8 +286,6 @@ task 'doc:site', 'watch and continually rebuild the documentation for the websit fs.writeFileSync "#{outputFolder}/test.html", output log 'compiled', green, "#{testFile} → #{outputFolder}/test.html" - for target in [indexFile, examplesSourceFolder, sectionsSourceFolder] - fs.watch target, interval: 200, renderIndex for target in [testFile, testsSourceFolder] fs.watch target, interval: 200, renderTest log 'watching...' , green