Files
logseq/src/main/frontend/debug.clj
Gabriel Horner 1f0e22275d Add ns docstrings for most ns in src/main
- Added to CI now that it passes
- Added no-doc for docstrings that don't add any more than what's in the
ns name or for ones where I didn't know the ns that well
2022-09-27 13:55:16 +08:00

28 lines
1022 B
Clojure

(ns frontend.debug
"Macros that are useful for debugging"
(:refer-clojure :rename {defn core-defn}))
(defmacro defn [name & fdecl]
(let [fdecl (if (string? (first fdecl))
(next fdecl)
fdecl)
fdecl (if (map? (first fdecl))
(next fdecl)
fdecl)
fdecl (if (vector? (first fdecl))
(list fdecl)
fdecl)
fdecl (if (map? (last fdecl))
(butlast fdecl)
fdecl)
fdecl (map (fn [decl]
(let [params (first decl)
body (next decl)]
`(~params
(let [start# (cljs.core/system-time)
ret# (do ~@body)
elapsed# (.toFixed (- (cljs.core/system-time) start#) 6)]
(println (str "[" '~name "] " elapsed# " msecs"))
ret#)))) fdecl)]
`(core-defn ~@(cons name fdecl))))