Skip to content

Commit

Permalink
Merge pull request jashkenas#181 from neocotic/windows
Browse files Browse the repository at this point in the history
Windows Support
  • Loading branch information
jashkenas committed Mar 30, 2013
2 parents 4a00b30 + 9a18bf4 commit eb11637
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 34 deletions.
39 changes: 24 additions & 15 deletions docco.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 20 additions & 19 deletions docco.litcoffee
Expand Up @@ -80,14 +80,16 @@ out in an HTML template.
document = (options = {}, callback) ->
configure options
exec "mkdir -p #{config.output}", ->
fs.mkdirs config.output, ->
callback or= (error) -> throw error if error
copyAsset = (file, callback) ->
fs.copy file, path.join(config.output, path.basename(file)), callback
complete = ->
exec [
"cp -f #{config.css} #{config.output}"
"cp -fR #{config.public} #{config.output}" if fs.existsSync config.public
].join(' && '), callback
copyAsset config.css, (error) ->
if error then callback error
else if fs.existsSync config.public then copyAsset config.public, callback
else callback()
files = config.sources.slice()
Expand Down Expand Up @@ -190,7 +192,7 @@ options.

config =
layout: 'parallel'
output: 'docs/'
output: 'docs'
template: null
css: null
extension: null
Expand All @@ -205,10 +207,10 @@ source files for languages for which we have definitions.
if options.template
config.layout = null
else
dir = config.layout = "#{__dirname}/resources/#{config.layout}"
config.public = "#{dir}/public" if fs.existsSync "#{dir}/public"
config.template = "#{dir}/docco.jst"
config.css = options.css or "#{dir}/docco.css"
dir = config.layout = path.join __dirname, 'resources', config.layout
config.public = path.join dir, 'public' if fs.existsSync path.join dir, 'public'
config.template = path.join dir, 'docco.jst'
config.css = options.css or path.join dir, 'docco.css'
config.template = _.template fs.readFileSync(config.template).toString()
config.sources = options.args.filter((source) ->
Expand All @@ -223,20 +225,19 @@ Helpers & Initial Setup

Require our external dependencies.

_ = require 'underscore'
fs = require 'fs'
path = require 'path'
marked = require 'marked'
commander = require 'commander'
{highlight} = require 'highlight.js'
{spawn, exec} = require 'child_process'
_ = require 'underscore'
fs = require 'fs-extra'
path = require 'path'
marked = require 'marked'
commander = require 'commander'
{highlight} = require 'highlight.js'
Languages are stored in JSON in the file `resources/languages.json`.
Each item maps the file extension to the name of the language and the
`symbol` that indicates a line comment. To add support for a new programming
language to Docco, just add it to the file.

languages = JSON.parse fs.readFileSync("#{__dirname}/resources/languages.json")
languages = JSON.parse fs.readFileSync(path.join(__dirname, 'resources', 'languages.json'))
Build out the appropriate matchers and delimiters for each language.

Expand Down Expand Up @@ -264,7 +265,7 @@ file extension. Detect and tag "literate" `.ext.md` variants.
Keep it DRY. Extract the docco **version** from `package.json`

version = JSON.parse(fs.readFileSync("#{__dirname}/package.json")).version
version = JSON.parse(fs.readFileSync(path.join(__dirname, 'package.json'))).version

Command Line Interface
Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -14,6 +14,7 @@
"dependencies": {
"commander": ">= 0.5.2",
"marked": ">= 0.2.7",
"fs-extra": ">= 0.6.0",
"underscore": ">= 1.0.0",
"highlight.js": ">= 7.3.0"
},
Expand Down

0 comments on commit eb11637

Please sign in to comment.