Permalink
Browse files

Make doc generation recursive

  • Loading branch information...
1 parent 66a51eb commit 1dacc7f67a2af8e2f9d58a0c4087c059cd32594c @jacobrask committed Dec 27, 2011
Showing with 19 additions and 9 deletions.
  1. +19 −9 Cakefile
View
@@ -1,12 +1,22 @@
task 'test', 'Run the test suite', ->
- require('nodeunit').reporters.default.run ['./test']
+ require('nodeunit').reporters.default.run ['./test']
task 'docs', 'Generate annotated source code with Docco', ->
- fs = require 'fs'
- {print} = require 'util'
- {spawn} = require 'child_process'
- fs.readdir 'lib', (err, contents) ->
- files = ("lib/#{file}" for file in contents when /\.coffee$/.test file)
- docco = spawn 'docco', files
- docco.stdout.on 'data', (data) -> print data.toString()
- docco.stderr.on 'data', (data) -> print data.toString()
+ async = require 'async'
+ fs = require 'fs'
+ {print} = require 'util'
+ {exec} = require 'child_process'
+ genDocs = (root) ->
+ fs.readdir root, (err, paths) ->
+ async.forEach paths,
+ (path, cb) ->
+ fs.stat "#{root}/#{path}", (err, stat) ->
+ if stat?.isDirectory()
+ genDocs "#{root}/#{path}"
+ else if /\.coffee$/.test path
+ exec "docco #{root}/#{path}"
+ cb()
+ (err) ->
+ console.error err if err?
+
+ genDocs 'lib'

0 comments on commit 1dacc7f

Please sign in to comment.