   (println "\nCloning or updating repos...")
   (clone-or-fetch-repos)
 
-  (mkdir "output")
+  (make-docs-repo!)
 
   (let [[latest history] (get-symbol-history)
-        versions (get-versions-since latest)]
+        [past-versions versions] (get-versions-to-parse latest)]
+
+    (println "\nVerifying docs-repo is in sync with symbol-history...")
+    (verify-docs-repo-sync! past-versions versions)
+
     (doseq [version versions]
 
       (println "\nChecking out" version "...")
       (checkout-version! version)
 
-      (binding [*output-dir* (str "output/" version)
+      (binding [*output-dir* docs-repo-dir
                 *repo-version* {"clojurescript" version
                                 "clojure" (get-repo-version "clojure")}]
 


;; location of the clojure & clojurescript repos to parse
(def repo-dir "repos")

;; location of the documents generated by this program
(def ^:dynamic *output-dir* nil)

          (println "\nWriting docs to" *output-dir*)
          (mkdir (str *output-dir* "/" docs-dir))
          (let [parsed (attach-history-to-items parsed (:version-map @history))]
            (dump-api-docs! parsed))

          (commit-docs-repo! version))

        (println "\nDone."))))

