Fixed parsing of ns and vars that couldn't be resolved. Added processing of CLJS files. More thought around presentation of CLJS v CLJ is needed.
This commit is contained in:
parent
36aecf7cdf
commit
1b97660357
3 changed files with 27 additions and 20 deletions
|
@ -1,6 +1,6 @@
|
|||
(defproject marginalia "0.7.0-SNAPSHOT"
|
||||
:description "lightweight literate programming for clojure -- inspired by [docco](http://jashkenas.github.com/docco/)"
|
||||
:main marginalia.main
|
||||
;; :main marginalia.main
|
||||
:dependencies
|
||||
[[org.clojure/clojure "1.3.0"]
|
||||
[org.clojure/tools.namespace "0.1.1"]
|
||||
|
|
|
@ -74,12 +74,12 @@
|
|||
[path]
|
||||
(.isDirectory (java.io.File. path)))
|
||||
|
||||
(defn find-clojure-file-paths
|
||||
(defn find-processable-file-paths
|
||||
"Returns a seq of clojure file paths (strings) in alphabetical order."
|
||||
[dir]
|
||||
[dir matching-re]
|
||||
(->> (io/file dir)
|
||||
(file-seq)
|
||||
(filter #(re-find #"\.clj$" (.getCanonicalPath %)))
|
||||
(filter #(re-find matching-re (.getCanonicalPath %)))
|
||||
(map #(.getCanonicalPath %))
|
||||
(sort)))
|
||||
|
||||
|
@ -208,10 +208,14 @@
|
|||
for .clj files."
|
||||
[sources]
|
||||
(if (nil? sources)
|
||||
(find-clojure-file-paths "./src")
|
||||
(concat
|
||||
(find-processable-file-paths "./src" #"\.clj$")
|
||||
(find-processable-file-paths "./src" #"\.cljs$"))
|
||||
(->> sources
|
||||
(mapcat #(if (dir? %)
|
||||
(find-clojure-file-paths %)
|
||||
(concat
|
||||
(find-processable-file-paths % #"\.clj$")
|
||||
(find-processable-file-paths % #"\.cljs$"))
|
||||
[(.getCanonicalPath (io/file %))])))))
|
||||
|
||||
(defn split-deps [deps]
|
||||
|
|
|
@ -134,10 +134,13 @@
|
|||
(replace #"\n\s*\)" ")")))
|
||||
|
||||
(defn get-var-docstring [nspace-sym sym]
|
||||
(try
|
||||
(-> `(var ~(symbol (str nspace-sym) (str sym))) eval meta :doc)
|
||||
;; HACK: to handle types
|
||||
(catch Exception _)))
|
||||
(let [s (if nspace-sym
|
||||
(symbol (str nspace-sym) (str sym))
|
||||
(symbol (str sym)))]
|
||||
(try
|
||||
(-> `(var ~s) eval meta :doc)
|
||||
;; HACK: to handle types
|
||||
(catch Exception _))))
|
||||
|
||||
(defmulti dispatch-form (fn [form _ _]
|
||||
(if (seq? form) (first form) form)))
|
||||
|
@ -151,12 +154,17 @@
|
|||
(try (require sym)
|
||||
(catch Exception _)))
|
||||
(let [nspace (find-ns sym)
|
||||
docstring (if nspace
|
||||
(-> nspace meta :doc)
|
||||
(get-var-docstring nspace-sym sym))]
|
||||
maybe-ds (let [[_ _ ? & _] form] ?)
|
||||
docstring (if (string? maybe-ds)
|
||||
maybe-ds
|
||||
(if-let [ds (:doc (meta (second form)))]
|
||||
ds
|
||||
(when nspace
|
||||
(-> nspace meta :doc)
|
||||
(get-var-docstring nspace-sym sym))))]
|
||||
[docstring
|
||||
(strip-docstring docstring raw)
|
||||
(if nspace sym nspace-sym)]))
|
||||
(if (or (= 'ns (first form)) nspace) sym nspace-sym)]))
|
||||
[nil raw nspace-sym])))
|
||||
|
||||
(defn- extract-impl-docstring
|
||||
|
@ -180,12 +188,7 @@
|
|||
|
||||
(defmethod dispatch-form 'ns
|
||||
[form raw nspace-sym]
|
||||
(let [[ds r s] (extract-common-docstring form raw nspace-sym)]
|
||||
(let [[_ _ ds & _] form
|
||||
ds (when (string? ds) ds)]
|
||||
[ds
|
||||
(strip-docstring ds r)
|
||||
s])))
|
||||
(extract-common-docstring form raw nspace-sym))
|
||||
|
||||
(defmethod dispatch-form 'def
|
||||
[form raw nspace-sym]
|
||||
|
|
Loading…
Reference in a new issue