Permalink
Browse files

Merge remote-tracking branch 'justind/windows'

  • Loading branch information...
2 parents 9fe9d5f + 2b2641e commit 0fcc55c08c18e88dbf524d573a57405b3659b62b @justindujardin justindujardin committed Oct 31, 2012
Showing with 58 additions and 36 deletions.
  1. +2 −1 Cakefile
  2. +9 −4 README
  3. +13 −22 lib/docco.js
  4. +5 −1 package.json
  5. +9 −2 src/docco.coffee
  6. +20 −6 test/tests.coffee
View
@@ -8,8 +8,9 @@ option '-p', '--prefix [DIR]', 'set the installation prefix for `cake install`'
option '-w', '--watch', 'continually build the docco library'
task 'build', 'build the docco library', (options) ->
- coffee = spawn 'coffee', ['-c' + (if options.watch then 'w' else ''), '-o', 'lib', 'src']
+ coffee = spawn 'node', ['./node_modules/coffee-script/bin/coffee','-c' + (if options.watch then 'w' else ''), '-o', 'lib', 'src']
coffee.stdout.on 'data', (data) -> console.log data.toString().trim()
+ coffee.stderr.on 'data', (data) -> console.log data.toString().trim()
task 'install', 'install the `docco` command into /usr/local (or --prefix)', (options) ->
base = options.prefix or '/usr/local'
View
13 README
@@ -12,14 +12,19 @@ documentation generator. For more information, see:
http://jashkenas.github.com/docco/
-$ docco
-
- Usage: docco [options] <filePattern ...>
+Usage: docco [options] <filePattern ...>
Options:
-h, --help output usage information
-V, --version output the version number
-c, --css [file] use a custom css file
-o, --output [path] use a custom output path
- -t, --template [file] use a custom .jst template
+ -t, --template [file] use a custom .jst template
+
+Building and Testing:
+
+ npm install
+ cake build
+ cake test
+
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -15,7 +15,11 @@
"lib" : "./lib"
},
"dependencies": {
- "commander" : ">=0.5.2"
+ "commander": ">=0.5.2"
+ },
+ "devDependencies": {
+ "coffee-script": "1.1.3",
+ "rimraf" :">=2.0.2"
},
"main" : "./lib/docco",
"bin": {
View
@@ -216,8 +216,14 @@ for ext, l of languages
getLanguage = (source) -> languages[path.extname(source)]
# Ensure that the destination directory exists.
-ensureDirectory = (dir, callback) ->
- exec "mkdir -p #{dir}", -> callback()
+ensureDirectory = (dir, cb, made=null) ->
+ mode = parseInt '0777', 8
+ fs.mkdir dir, mode, (er) ->
+ return cb null, made || dir if not er
+ if er.code == 'ENOENT'
+ return ensureDirectory path.dirname(dir), (er, made) ->
+ if er then cb er, made else ensureDirectory dir, cb, made
+ cb er, made
# Micro-templating, originally by John Resig, borrowed by way of
# [Underscore.js](http://documentcloud.github.com/underscore/).
@@ -328,4 +334,5 @@ exports[key] = value for key, value of {
version : version
defaults : defaults
languages : languages
+ ensureDirectory: ensureDirectory
}
View
@@ -1,7 +1,7 @@
-{spawn, exec} = require 'child_process'
path = require 'path'
fs = require 'fs'
+rimraf = require 'rimraf'
# Determine the test and resources paths
testPath = path.dirname fs.realpathSync(__filename)
@@ -12,8 +12,9 @@ resourcesPath = path.normalize path.join(testPath,"/../resources")
# is equal to what is expected.
testDoccoRun = (testName,sources,options=null,callback=null) ->
destPath = path.join dataPath, testName
- cleanup = (callback) -> exec "rm -rf #{destPath}", callback
- cleanup ->
+ cleanup = (callback) -> rimraf destPath, callback
+ cleanup (error) ->
+ eq not error, true, "path cleaned up properly"
options?.output = destPath
Docco.document sources, options, ->
files = []
@@ -83,12 +84,12 @@ test "single line comment parsing", ->
# *Kick off the first language test*
testNextLanguage languageKeys.slice()
-
+
# **URL references should resolve across sections**
#
# Resolves [Issue 100](https://github.com/jashkenas/docco/issues/100)
test "url references", ->
- exec "mkdir -p #{dataPath}", ->
+ Docco.ensureDirectory dataPath, ->
sourceFile = "#{dataPath}/_urlref.coffee"
fs.writeFileSync sourceFile, [
"# Look at this link to [Google][]!",
@@ -99,8 +100,21 @@ test "url references", ->
].join('\n')
outPath = path.join dataPath, "_urlreferences"
outFile = "#{outPath}/_urlref.html"
- exec "rm -rf #{outPath}", ->
+ rimraf outPath, (error) ->
+ eq not error, true
Docco.document [sourceFile], output: outPath, ->
contents = fs.readFileSync(outFile).toString()
count = contents.match ///<a\shref="http://www.google.com">Google</a>///g
eq count.length, 2, "find expected (2) resolved url references"
+# **Paths should be recursively created if needed**
+#
+# ensureDirectory should properly create complex output paths.
+test "create complex paths that do not exist", ->
+ exist = fs.existsSync or path.existsSync
+ outputPath = path.join dataPath, 'complex/path/that/doesnt/exist'
+ rimraf outputPath, (error) ->
+ eq not error, true
+ Docco.ensureDirectory outputPath, ->
+ equal exist(outputPath), true, 'created output path'
+ stat = fs.statSync outputPath
+ equal stat.isDirectory(), true, "target is directory"

0 comments on commit 0fcc55c

Please sign in to comment.