Closed vbauer closed 10 years ago
How are you using Codox? At first glance it looks like you might be executing it from the REPL.
I do the following things:
vbauer@vladislav-bauer:~/workspace/clojure/ziggurat$ lein clean
vbauer@vladislav-bauer:~/workspace/clojure/ziggurat$ lein doc
Compiling ziggurat.db
2014-Mar-22 18:16:12 +0700 vladislav-bauer INFO [ziggurat.db] - Init Lua scripts
2014-Mar-22 18:16:12 +0700 vladislav-bauer INFO [ziggurat.db] - Init Lua script: create-post
2014-Mar-22 18:16:12 +0700 vladislav-bauer INFO [ziggurat.db] - Init Lua script: find-all-tags
2014-Mar-22 18:16:12 +0700 vladislav-bauer INFO [ziggurat.db] - Init Lua script: find-all-posts
Compiling ziggurat.ui.handler
Compiling ziggurat.ui.routes
Compiling ziggurat.app
Compiling ziggurat.rules.output
Compiling ziggurat.rules.data
Compiling ziggurat.rules.engine
Compiling ziggurat.core
Exception in thread "main" java.lang.IllegalArgumentException: /tmp/form-init9096339398177041302.clj is not a relative path
at clojure.java.io$as_relative_path.invoke(io.clj:404)
at clojure.java.io$file.invoke(io.clj:415)
at codox.utils$find_file_in_repo$fn__32.invoke(utils.clj:23)
at clojure.core$map$fn__4207.invoke(core.clj:2485)
at clojure.lang.LazySeq.sval(LazySeq.java:42)
at clojure.lang.LazySeq.seq(LazySeq.java:60)
...
Subprocess failed
My project.clj is very simple (it's a sandbox project):
(defproject
ziggurat
"0.1.0-SNAPSHOT"
:dependencies
[[ring-server "0.3.1"]
[ring/ring-json "0.2.0"]
[com.taoensso/timbre "3.1.5"]
[http-kit "2.1.17"]
[com.taoensso/tower "2.0.1"]
[org.clojure/clojure "1.5.1"]
[compojure "1.1.6"]
[lib-noir "0.7.9"]
[com.postspectacular/rotor "0.1.0"]
[com.taoensso/carmine "2.4.6"]
[org.drools/drools-compiler "6.0.1.Final"]
[org.drools/knowledge-api "6.0.1.Final"]
[clj-http "0.9.0"]
[com.sun.xml/jaxb-xjc "2.0EA3"]
[org.jsoup/jsoup "1.7.3"]
[org.apache.commons/commons-lang3 "3.3"]
[ch.qos.logback/logback-classic "1.1.1"]
[com.ibm.icu/icu4j "52.1"]
[com.googlecode.juniversalchardet/juniversalchardet "1.0.3"]]
:url "http://example.com/FIXME"
:main ziggurat.app
:aot :all
:plugins [[lein-kibit "0.0.8"] [codox "0.6.7"]]
:description "FIXME: write description"
:min-lein-version "2.0.0")
Okay, so it looks like there's a var created in ziggurat.core that has some odd metadata. Instead of having a :path
of ziggurat/core.clj
, it's /tmp/form-init9096339398177041302.clj
, something you'd typically see from a form created in the REPL.
Could I see the ziggurat.core
namespace?
Yes, ofc:
(ns ziggurat.core
^{:author "Vladislav Bauer"}
(:import (org.apache.commons.lang3 StringUtils)
(com.ibm.icu.text CharsetDetector)
(org.mozilla.universalchardet UniversalDetector)
(java.io BufferedOutputStream FileOutputStream))
(:require [clj-http.client :as client]
[clojure.string :as string]
[taoensso.timbre :as timbre]))
; Configuration
(def config {:dev-mode true
:http-port 8080
:screenshot-service "http://localhost:8081/"
:images-directory "data/images/"
:width 800
:height 600
:default-charset "UTF-8"
:http-client-params {:insecure? true
:follow-redirects true
:max-redirects 5
:socket-timeout 10000
:conn-timeout 10000
:decode-body-headers true
:as :byte-array}})
; Core macros and functions
(defmacro safe [& body]
`(try ~@body
(catch Throwable e#
;(timbre/error e#)
nil)))
(defn defval [v d] (if (nil? v) d v))
(defn lower-case-map [data]
(into {} (for [[k v] data] [(string/lower-case k) v])))
(defn has-part [content-type & types]
(some #(.contains content-type %) types))
; Character & encodings
(defn- detect-charset-icu [data]
(let [detector (doto (CharsetDetector.)
(.setText data)
(.enableInputFilter true))]
(.getName (.detect detector))))
(defn- detect-charset-universal [data]
(let [detector (doto (UniversalDetector. nil)
(.handleData data 0 (count data))
(.dataEnd))]
(.getDetectedCharset detector)))
(defn detect-charset [data]
(let [processor #(StringUtils/upperCase (% data))
detectors [detect-charset-universal]
charsets (remove nil? (map processor detectors))]
(if (= 1 (count charsets))
(first charsets)
(:default-charset config))))
(defn as-utf8 [data] (String. data (detect-charset data)))
; Network functions
(defn parse-query-params [url]
(let [query (.getQuery url)
params (string/split (StringUtils/trimToEmpty query) #"&")
kv (map #(string/split % #"=") params)]
(try (into {} kv) (catch Exception ex nil))))
(defn send-request [url]
(client/get url (:http-client-params config)))
; File functions
(defn write-file [file data]
(with-open [writer (BufferedOutputStream. (FileOutputStream. file))]
(.write writer data)))
Looking it over, nothing strikes me as hugely unusual, except:
^{:author "Vladislav Bauer"}
Which should be:
{:author "Vladislav Bauer"}
I'm not sure whether that's causing the issue, but you could try it.
I'll try adding the code to a local project and see if I can reproduce the error.
It looks like http://en.wikibooks.org/wiki/Learning_Clojure/Meta_Data contains wrong information about "^{:author ""}".
Thank you for idea, I tried to:
but it didn't help me..
It's a little bit strange that I see twice the following logs:
2014-Mar-23 14:05:57 +0700 vladislav-bauer INFO [ziggurat.db] - Init Lua scripts
2014-Mar-23 14:05:57 +0700 vladislav-bauer INFO [ziggurat.db] - Init Lua script: create-post
2014-Mar-23 14:05:57 +0700 vladislav-bauer INFO [ziggurat.db] - Init Lua script: find-all-tags
2014-Mar-23 14:05:57 +0700 vladislav-bauer INFO [ziggurat.db] - Init Lua script: find-all-posts
I write this messages in ziggurat.db, but only once:
(def lua-scripts (atom (reload-lua-scripts lua-files)))
The wikibook is correct. It advocates writing:
(ns ^{:author "Vladislav Bauer"} ziggurat.core)
This is because you're placing the metadata on the namespace symbol. In later versions of Clojure, you can also write:
(ns ziggurat.core {:author "Vladislav Bauer"})
Regarding the error, I've tried reproducing it with the code you provided, but everything works fine for me. However, I notice you have :aot :all
in your project file. With AOT you have to be careful, as it can result in obsolete class files cluttering up your namespace. This may be what's causing your strange error.
Try running:
lein clean
And then see if lein doc
works after that.
If that doesn't work, try removing the target
directory entirely, and then trying lein doc
.
Thank you for information!
As I said before I've tried to make clean:
vbauer@vladislav-bauer:~/workspace/clojure/ziggurat$ lein clean
vbauer@vladislav-bauer:~/workspace/clojure/ziggurat$ lein doc
(I also tried to remove target directory instead of cleaning)
I've tried to change ":aot" parameter, but it did not help:
:main ziggurat.app
:aot [ziggurat.rules.data ziggurat.rules.output ziggurat.app]
It looks like I found problem.. In the namespace ziggurat.db I have atom with list of some data. The value for this atom is retrieved using function "reload-lua-scripts". I also create some functions in this namespace in run-time using specific macros. When I comment this code (def lua-scripts (atom (reload-lua-scripts lua-files))) and all calls to this "created in runtime" functions - everything works fine.
ziggurat.db:
(ns ziggurat.db
(:require [taoensso.timbre :as timbre]
[taoensso.carmine :as car :refer (wcar)]
[cheshire.core :as json]))
; Common Redis
(def server-connection {:pool {} :spec {}})
(defmacro wcar* [& body]
`(car/wcar server-connection ~@body))
; Common Lua
(declare lua-scripts)
(declare run-lua-script)
(defmacro def-lua-script [name]
(timbre/info (str "Init Lua script: " name))
`(defn ~(symbol name) [& argv#] (run-lua-script ~name argv#)))
(defn- load-lua-script [name]
(let [fname (str "db/" name ".lua")
source (slurp (clojure.java.io/resource fname))
checksum (car/script-hash source)]
{:name name :source source :checksum checksum}))
(defn- reload-lua-scripts [files]
(timbre/info "Init Lua scripts")
(let [scripts (map load-lua-script files)]
(wcar*
(car/redis-call [:script "flush"])
(doseq [script scripts]
(car/redis-call [:script "load" (:source script)])
(let [sn (:name script)]
(eval `(def-lua-script ~sn)))))
scripts))
(defn- run-lua-script [name & argv]
(let [script (first (filter #(= (:name %) name) @lua-scripts))
checksum (:checksum script)
args (flatten argv)]
(timbre/debug "Run script" name "with arguments" args)
(json/parse-string (wcar* (apply car/evalsha checksum 0 args)))))
(def lua-files ["create-post" "find-all-tags" "find-all-posts"])
(def lua-scripts (atom (reload-lua-scripts lua-files)))
I hope that I explained it clearly..
I've got this exception during documentation generation:
PS: As result I got CSS and JS files in the "doc" directory without HTML files.