 # Generate the documentation for a source file by reading it in, splitting it
 # up into comment/code sections, highlighting them for the appropriate language,
 # and merging them into an HTML template.
-generate_documentation: (source) ->
-  ensure_directory ->
-    set_language source
-    code: fs.readFile source, (error, code) ->
-      throw error if error
-      sections: parse code
-      highlight source, sections, ->
-        generate_html source, sections
+generate_documentation: (source, callback) ->
+  fs.readFile source, (error, code) ->
+    throw error if error
+    sections: parse source, code
+    highlight source, sections, ->
+      generate_html source, sections
+      callback()
 
 # Given a string of source code, parse out each comment and the code that
 # follows it, and create an individual **section** for it.

#       code_html: ...
#     }
#
parse: (code) ->
  lines: code.split '\n'
  sections: []
  has_code: docs_text: code_text: ''

  save: (docs, code) ->

# For each source file passed in as an argument, generate the documentation.
sources: process.ARGV.sort()
if sources.length
  ensure_directory ->
    fs.writeFile 'docs/docco.css', docco_styles
    files: sources.slice(0)
    next_file: -> generate_documentation files.shift(), next_file if files.length
    next_file()
