#!/usr/bin/env coffee
path = require 'path'
fs = require 'fs'
jade = require 'jade'
_ = require 'underscore'
md = require('node-markdown').Markdown
paths =
bin: __dirname
root: path.join __dirname, '..'
docs: path.join __dirname, '../docs'
srcs: path.join __dirname, '../docs/doc_files'
jade: path.join __dirname, '../docs/templates'
# Hash to store any variable needed in our template
locals = {}
# Create a hash of title => html for every doc source file
docFiles = {}
sources = fs.readdirSync paths.srcs
for file in sources.sort()
source = fs.readFileSync(path.join(paths.srcs, file)).toString()
title = source.split("\n")[0].replace(/#/g, '').trim()
link = "
"
docFiles[title] =
ref: file
source: [link, md source].join "\n"
locals.docs = _(docFiles).chain().values().map((val)-> val.source).value().join "\n"
# Create a table of contents array
toc = []
for title, docObj of docFiles
toc.push "