2015-06-01 12:52:33 -06:00
|
|
|
#!/usr/bin/env coffee
|
|
|
|
|
|
|
|
# Dependencies
|
|
|
|
Handlebars = require('handlebars')
|
|
|
|
Beautifiers = require("../src/beautifiers")
|
|
|
|
fs = require('fs')
|
|
|
|
|
|
|
|
console.log('Generating options...')
|
|
|
|
beautifier = new Beautifiers()
|
2015-06-01 13:50:09 -06:00
|
|
|
languageOptions = beautifier.options
|
|
|
|
packageOptions = require('../src/config.coffee')
|
2015-06-01 12:52:33 -06:00
|
|
|
|
|
|
|
console.log('Loading options template...')
|
2015-06-01 13:50:09 -06:00
|
|
|
optionsTemplatePath = __dirname + '/options-template.md'
|
|
|
|
optionTemplatePath = __dirname + '/option-template.md'
|
2015-06-01 12:52:33 -06:00
|
|
|
optionsPath = __dirname + '/options.md'
|
2015-06-01 13:50:09 -06:00
|
|
|
optionsTemplate = fs.readFileSync(optionsTemplatePath).toString()
|
|
|
|
optionTemplate = fs.readFileSync(optionTemplatePath).toString()
|
|
|
|
|
2015-06-01 12:52:33 -06:00
|
|
|
console.log('Building documentation from template and options...')
|
2015-06-01 13:50:09 -06:00
|
|
|
Handlebars.registerPartial('option', optionTemplate)
|
|
|
|
template = Handlebars.compile(optionsTemplate)
|
2015-06-01 12:52:33 -06:00
|
|
|
context = {
|
2015-06-01 13:50:09 -06:00
|
|
|
packageOptions: packageOptions
|
|
|
|
languageOptions: languageOptions
|
2015-06-01 12:52:33 -06:00
|
|
|
}
|
|
|
|
result = template(context)
|
|
|
|
|
|
|
|
console.log('Writing documentation to file...')
|
|
|
|
fs.writeFileSync(optionsPath, result)
|
|
|
|
|
|
|
|
console.log('Done.')
|