Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Make doc generation recursive

  • Loading branch information...
commit 1dacc7f67a2af8e2f9d58a0c4087c059cd32594c 1 parent 66a51eb
Jacob Rask authored December 27, 2011

Showing 1 changed file with 19 additions and 9 deletions. Show diff stats Hide diff stats

  1. 28  Cakefile
28  Cakefile
... ...
@@ -1,12 +1,22 @@
1 1
 task 'test', 'Run the test suite', ->
2  
-    require('nodeunit').reporters.default.run ['./test']
  2
+  require('nodeunit').reporters.default.run ['./test']
3 3
     
4 4
 task 'docs', 'Generate annotated source code with Docco', ->
5  
-    fs            = require 'fs'
6  
-    {print}       = require 'util'
7  
-    {spawn} = require 'child_process'
8  
-    fs.readdir 'lib', (err, contents) ->
9  
-        files = ("lib/#{file}" for file in contents when /\.coffee$/.test file)
10  
-        docco = spawn 'docco', files
11  
-        docco.stdout.on 'data', (data) -> print data.toString()
12  
-        docco.stderr.on 'data', (data) -> print data.toString()
  5
+  async = require 'async'
  6
+  fs = require 'fs'
  7
+  {print} = require 'util'
  8
+  {exec} = require 'child_process'
  9
+  genDocs = (root) ->
  10
+    fs.readdir root, (err, paths) ->
  11
+      async.forEach paths,
  12
+        (path, cb) ->
  13
+          fs.stat "#{root}/#{path}", (err, stat) ->
  14
+            if stat?.isDirectory()
  15
+              genDocs "#{root}/#{path}"
  16
+            else if /\.coffee$/.test path
  17
+              exec "docco #{root}/#{path}"
  18
+              cb()
  19
+        (err) ->
  20
+          console.error err if err?
  21
+
  22
+  genDocs 'lib'

0 notes on commit 1dacc7f

Please sign in to comment.
Something went wrong with that request. Please try again.