UNPKG

1.23 kBtext/coffeescriptView Raw
1
2fs = require 'fs'
3mecano = require '..'
4
5date = -> d = (new Date).toISOString()
6
7source = "#{__dirname}/mecano.coffee"
8destination = "#{__dirname}/../doc/index.md"
9docs = """
10---
11language: en
12layout: page
13title: "Node Mecano: Common functions for system deployment"
14date: #{date()}
15comments: false
16sharing: false
17footer: false
18github: https://github.com/wdavidw/node-mecano
19---
20"""
21
22fs.readFile source, 'ascii', (err, content) ->
23 re = /###\n([\s\S]*?)\n( *)###/g
24 re_code = /\n(\s{4}\s*?\w[\s\S]*?)\n(?!\s)/g
25 match = re.exec content
26 docs += match[1]
27 while match = re.exec content
28 match[1] = match[1].split('\n').map((line)->line.substr(2)).join('\n')
29 match[1] = match[1].replace re_code, (str, code) ->
30 code = code.split('\n').map((line)->line.substr(4)).join('\n')
31 "\n```coffeescript\n#{code}\n```"
32 docs += match[1]
33 fs.writeFile destination, docs, (err) ->
34 return console.log err.message if err
35 console.log 'Documentation generated'
36 destination = process.argv[2]
37 return unless destination
38 mecano.copy
39 source: "#{__dirname}/../doc/index.md"
40 destination: destination
41 force: true
42 , (err, copied) ->
43 console.log "Documentation published: #{destination}"
\No newline at end of file