   ], cb
 
 
+# Generates JSON Schema representation for given array type node.
 handleArray = (arrayType, simpleTypeSpec, options, cb) ->
   cb null, type: 'array'
 
 
+# Generates JSON Schema representation for given primitive
+# type node (string, number, etc.).
 handlePrimitiveType = (primitiveType, simpleTypeSpec, options, cb) ->
   cb null, type: simpleTypeSpec.name
 
 
+# Generates JSON Schema representation for given type node.
 handleType = (type, options, cb) ->
   resolveType type, (err, simpleTypeSpec) ->
     return cb err if err

  cb null, schema


handleObject = (objectType, simpleTypeSpec, options, cb) ->
  async.waterfall [
    (next) -> listProperties objectType, next

        handlePrimitiveType type, simpleTypeSpec, options, cb


# Adds JSON Schema declaration to given schema object.
addSchemaDeclaration = (schema, cb) ->
  schema["$schema"] = "http://json-schema.org/draft-04/schema#"
  cb null, schema


# Transforms given MSON AST into JSON Schema.
transform = (ast, options, cb) ->
  async.waterfall [
    (next) -> handleType ast, options, next
