clerk/show! the user ns?
hoclun-rigsep opened this issue · comments
If I just fire up a repl and run
(require '[nextjournal.clerk :as clerk])
(clerk/serve!)
(clerk/show! (find-ns 'user))
it doesn't work:
nextjournal.clerk/show!
could not find a resource on the classpath for:user
I have a feeling this is expected but was curious if there is a workaround or so.
It works for me here. If I had to guess I'd say the user namespace file can't be found on the classpath. What does the following return for you?
(some (fn [ext] (clojure.java.io/resource (str "user" ext))) [".clj" ".cljc"])
;; => #object[java.net.URL 0x480f9816 "file:/Users/mk/dev/clerk/dev/user.clj"]
Thanks @mk. That expression returns nil for me. I started the repl with clj -A:lib/clerk
and the alias is defined in $HOME/clojure/deps.edn thus:
:lib/clerk
{:extra-deps {io.github.nextjournal/clerk {:mvn/version "0.13.842"}}}
This isn't actually stopping me doing anything important I was just curious if it could be used ad-hoc without saving a file somewhere.
If that returns nil
it means Clerk can't find the namespace on the classpath.
You can use clerk without a file by passing a StringReader or a URL like so:
(nextjournal.clerk/show! (java.io.StringReader. ";; # Notebook from String 👋\n(+ 41 1)"))
(nextjournal.clerk/show! "https://raw.githubusercontent.com/nextjournal/clerk-demo/main/notebooks/rule_30.clj")
Hope this helps, I'll go ahead and close the issue.