     [stencil.core :as stencil]
     ))
 
+(def ^:dynamic *result*
+  "The current result that we are writing."
+  nil)
+
 (def ns-descriptions
   "FIXME: put this in the official docstrings if missing (patch request)"
 

(defn ref-link
  [full-name]
  (when full-name
    {:display-name (get-full-display-name full-name)
     :link (str (encode/encode-fullname full-name) ".md")}))

(defn add-related-links
  [{:keys [related] :as item}]

;;--------------------------------------------------------------------------------

(defn dump-result! [result]
  (binding [*result* result]

    (mkdir *output-dir*)
    (mkdir (str *output-dir* "/" refs-dir))

    (println "writing edn...")
    (dump-edn-file! result)

    (println "writing ref files...")
    (doseq [item (vals (:symbols result))]
      (dump-ref-file! item))

    (println "writing readme...")
    (dump-readme! result)

    (println "writing history...")
    (dump-history! result)

    (println "writing unported...")
    (dump-unported! result)

    (println "writing unfinished...")
    (dump-unfinished! result))
  )

