Reverting "Fix handling of ::keywords using aliases"

Evaluating ns forms which :use some symbols gets as in trouble unless
we also evaluate the relevant definitions in the other namespace. This
leads to the issue of loading the namespaces in the correct order etc.
So, if we want to be able to generate docs without compiling the whole
project, the "eval ns forms" approach is a no-go. :-(
This commit is contained in:
Michał Marczyk 2011-09-17 07:15:12 +02:00
parent 3fff515edb
commit f7f63b1149
2 changed files with 2 additions and 16 deletions

View file

@ -15,9 +15,6 @@
(def top-level-comments (atom [])) (def top-level-comments (atom []))
(def sub-level-comments (atom [])) (def sub-level-comments (atom []))
(def user-ns (the-ns 'user))
(def current-namespace (atom user-ns))
(def *comments* nil) (def *comments* nil)
(defn read-comment [reader semicolon] (defn read-comment [reader semicolon]
@ -52,14 +49,6 @@
(recur (.read rdr)) (recur (.read rdr))
:else (.unread rdr c)))) :else (.unread rdr c))))
(defn maybe-change-namespace [form]
(when (and (seq? form)
('#{ns in-ns require use alias} (first form)))
(binding [*ns* @current-namespace]
(eval form))
(when ('#{ns in-ns} (first form))
(reset! current-namespace (the-ns (second form))))))
(defn parse* [reader] (defn parse* [reader]
(take-while (take-while
:form :form
@ -69,14 +58,12 @@
(binding [*comments* top-level-comments] (binding [*comments* top-level-comments]
(skip-spaces-and-comments reader)) (skip-spaces-and-comments reader))
(let [start (.getLineNumber reader) (let [start (.getLineNumber reader)
form (binding [*comments* sub-level-comments form (binding [*comments* sub-level-comments]
*ns* @current-namespace]
(. clojure.lang.LispReader (. clojure.lang.LispReader
(read reader false nil false))) (read reader false nil false)))
end (.getLineNumber reader) end (.getLineNumber reader)
code {:form form :start start :end end} code {:form form :start start :end end}
comments @top-level-comments] comments @top-level-comments]
(maybe-change-namespace form)
(swap! top-level-comments (constantly [])) (swap! top-level-comments (constantly []))
(if (empty? comments) (if (empty? comments)
[code] [code]

View file

@ -8,5 +8,4 @@
;(is (= (count (marginalia.parser/parse "(ns test)\n123")) 1)) still failing ;(is (= (count (marginalia.parser/parse "(ns test)\n123")) 1)) still failing
(is (= (count (marginalia.parser/parse "(ns test)\n123\n")) 1)) (is (= (count (marginalia.parser/parse "(ns test)\n123\n")) 1))
(is (= (count (marginalia.parser/parse "(ns test)\n\"string\"")) 1)) (is (= (count (marginalia.parser/parse "(ns test)\n\"string\"")) 1))
(is (= (count (marginalia.parser/parse "(ns test)\n\"some string\"")) 1)) (is (= (count (marginalia.parser/parse "(ns test)\n\"some string\"")) 1)))
(is (= (count (marginalia.parser/parse "(ns test (:require [marginalia.parser :as parser]))\n(defn foo [] ::parser/foo)")) 1)))