 # Compute the destination HTML path for an input source file path. If the source
 # is `lib/example.coffee`, the HTML will be at `docs/example.html`
 destination = (filepath) ->
-  'docs/' + path.basename(filepath, path.extname(filepath)) + '.html'
+  basename = path.basename filepath, path.extname filepath
+  "docs/#{basename}.html"
 
 # Ensure that the destination directory exists.
 ensure_directory = (dir, callback) ->

# up into comment/code sections, highlighting them for the appropriate language,
# and merging them into an HTML template.
generate_documentation = (source, callback) ->
  fs.readFile source, "utf-8", (error, code) ->
    throw error if error
    sections = parse source, code
    highlight source, sections, ->

generate_html = (source, sections) ->
  title = path.basename source
  dest  = destination source
  html  = docco_template {title, sections, sources, path, destination}
  console.log "docco: #{source} -> #{dest}"
  fs.writeFile dest, html

