Fixed metadoc on ns. Added a line number reporting error on parse problem.

This commit is contained in:
fogus 2012-02-08 11:04:40 -05:00
parent 7efe1c4666
commit 8780370415
2 changed files with 26 additions and 20 deletions

View file

@ -112,8 +112,10 @@
(skip-spaces-and-comments reader))
(let [start (.getLineNumber reader)
form (binding [*comments* sub-level-comments]
(. clojure.lang.LispReader
(read reader false nil false)))
(try (. clojure.lang.LispReader
(read reader false nil false))
(catch Exception ex
(throw (Exception. (str "Problem parsing near line " start))))))
end (.getLineNumber reader)
code {:form form :start start :end end}
comments @top-level-comments]
@ -149,22 +151,27 @@
[form raw nspace-sym]
(let [sym (second form)]
(if (symbol? sym)
(do
(when (= 'ns (first form))
(try (require sym)
(catch Exception _)))
(let [nspace (find-ns sym)
[maybe-ds remainder] (let [[_ _ ? & more?] form] [? more?])
docstring (if (and (string? maybe-ds) remainder)
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 (or (= 'ns (first form)) nspace) sym nspace-sym)]))
(let [maybe-metadocstring (:doc (meta sym))]
(do
(when (= 'ns (first form))
(try (require sym)
(catch Exception _)))
(let [nspace (find-ns sym)
[maybe-ds remainder] (let [[_ _ ? & more?] form] [? more?])
docstring (if (and (string? maybe-ds) remainder)
maybe-ds
(if (= (first form) 'ns)
(if (not maybe-metadocstring)
maybe-ds
maybe-metadocstring)
(if-let [ds maybe-metadocstring]
ds
(when nspace
(-> nspace meta :doc)
(get-var-docstring nspace-sym sym)))))]
[docstring
(strip-docstring docstring raw)
(if (or (= 'ns (first form)) nspace) sym nspace-sym)])))
[nil raw nspace-sym])))
(defn- extract-impl-docstring

View file

@ -1,6 +1,5 @@
(ns problem-cases.general
"A place to examine poor parser behavior. These should go in tests when they get written."
)
"A place to examine poor parser behavior. These should go in tests when they get written.")
::foo