     [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 dump-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)

  )


(defn ref-link
  [full-name]
  (when full-name
    (let [item (get-in *result* [:symbols full-name])]
      {:display-name (cond-> (md-escape (get-full-display-name full-name))
                       (:removed item) md-strikethru)
       :link (when item (str (encode/encode-fullname full-name) ".md"))})))

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