Add support for cljx reader tags #+clj and #+cljs to make it possible to generate marginalia docs in projects using cljx to target Clojure and ClojureScript.

This commit is contained in:
Martin Bilski 2015-01-06 15:43:13 +01:00
parent a21cd992c4
commit 0e43f515a9

View file

@ -391,9 +391,16 @@
(defn cljs-file? [filepath]
(.endsWith (lower-case filepath) "cljs"))
(defn cljx-file? [filepath]
(.endsWith (lower-case filepath) "cljx"))
(def cljx-data-readers {'+clj identity
'+cljs identity})
(defn parse-file [file]
(let [readers (if (cljs-file? file)
(->> default-data-readers (merge *cljs-data-readers*))
(let [readers (merge {}
(when (cljs-file? file) *cljs-data-readers*)
(when (cljx-file? file) cljx-data-readers)
default-data-readers)]
(binding [*data-readers* readers
*comments-enabled* (atom true)]