   (:import
    [org.pegdown PegDownProcessor
                 Extensions]))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; Utility Functions
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(defn default-renderer
+  "This is the function used by default to render templates, given data that
+  the template needs to render."
+  [template-file data]
+  (selmer/render-file template-file data))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; Routing Setup

  ([processor markdown]
   (.markdownToHtml processor markdown)))

(defn generate
  "Generates the API documentation HTML page from the markdown source.
  Args
  * page-title - The title to use in the generated documentation page.
  * docs-source - The file containing the markdown API documentation.
    Example: `api_docs.md`
  * docs-target - The file that will be generated with the API documentation.
    Example: `resources/public/site/api_docs.html`
  * render-fn - An optional 0-arity function that will replace the default
     render function."
  ([page-title docs-source docs-target]
    (let [data {:page-title page-title
                :page-content (md->html (slurp docs-source))}
          render-fn (fn [] (renderer data))]
      (generate page-title docs-source docs-target render-fn)))
  ([page-title docs-source docs-target render-fn]
   (println (format "Generating %s from %s ..." docs-target docs-source))
   (io/make-parents docs-target)
   (spit docs-target (render-fn))
   (println "Done."))
  ;; XXX The following clause is temporary for CMR-4093; with CMR-4094, it will
  ;; go away when the entire function is refactored to its final form.
  ([page-title docs-source docs-target template-file data]
    (generate page-title
              docs-source
              docs-target
              (fn []
                (selmer/render-file
                 template-file
                 data)))))

      (docs-routes public-protocol relative-root-url))))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Core API Documentation Functions
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

