Skip to content

Commit

Permalink
v0.6.3
Browse files Browse the repository at this point in the history
  • Loading branch information
philoskim committed Jan 29, 2020
1 parent 26fb2f8 commit cc44f71
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 18 deletions.
46 changes: 41 additions & 5 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ To include `debux` in your project for development, simply add the following to

[source]
....
[philoskim/debux "0.6.2"]
[philoskim/debux "0.6.3"]
....

and this to your *production* dependencies.

[source]
....
[philoskim/debux-stubs "0.6.2"]
[philoskim/debux-stubs "0.6.3"]
....


Expand All @@ -65,6 +65,10 @@ and this to your *production* dependencies.
NOTE: You can see _All change logs since v0.3.0_
https://github.com/philoskim/debux/tree/master/doc/change-logs.adoc[here].

* v0.6.3
** The printed format of evaluating the multiple forms in `dbg`/`clog` is chanaged for
readability. See the detalis <<eval-multiple-forms, here>>.
* v0.6.2
** The namespace and line number of the source code are relocated to the top line for
readability.
Expand Down Expand Up @@ -174,7 +178,9 @@ dbg: (+ 10 20) =>
| 30
----
Sometimes you need to see several forms evaluated. To do so, a literal vector
[#eval-multiple-forms]
Sometimes you need to see multiple forms evaluated. To do so, a literal vector
form can be used like this.
[source]
Expand All @@ -192,7 +198,37 @@ form can be used like this.
----
{:ns examples.demo, :line 13}
dbg: [a b c d e f g h] =>
| [(0 1 2 3 4) 20 50 100 "a" "b" "c" ("d" "e")]
| {:a (0 1 2 3 4),
| :b 20,
| :c 50,
| :d 100,
| :e "a",
| :f "b",
| :g "c",
| :h ("d" "e")}
----
NOTE: Notice that the printed value is a map, not a vector and the form is prepended with
a colon to distinguish the form from the evaluated value.
Further examples:
[source]
....
(def a 10)
(def b 20)
(dbg [a b [a b] :c])
; => [10 20 [10 20] :c]
....
[listing]
.REPL output
----
{:ns examples.demo, :line 18}
dbg: [a b [a b] :c] =>
| {:a 10, :b 20, :[a b] [10 20], ::c :c}
----
Expand Down Expand Up @@ -2825,7 +2861,7 @@ an example about running the link:https://github.com/bhauman/lein-figwheel[figwh
(defproject examples "0.1.0-SNAPSHOT"
:dependencies [[org.clojure/clojure "1.8.0"]
[org.clojure/clojurescript "1.10.238"]
[philoskim/debux "0.6.2"]]
[philoskim/debux "0.6.3"]]
:plugins [[lein-cljsbuild "1.1.6"]
[lein-figwheel "0.5.10"]]
:source-paths ["src/clj"]
Expand Down
4 changes: 4 additions & 0 deletions doc/change-logs.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
:source-highlighter: coderay
:sectnums:

* v0.6.3
** The printed format of evaluating the multiple forms in `dbg`/`clog` is chanaged for
readability.
* v0.6.2
** The namespace and line number of the source code are relocated to the top line for
readability.
Expand Down
2 changes: 1 addition & 1 deletion examples/project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
:dependencies [[org.clojure/clojure "1.8.0"]
[org.clojure/clojurescript "1.10.238"]
[org.clojure/core.async "0.3.465"]
[philoskim/debux "0.6.2"]]
[philoskim/debux "0.6.3"]]
:plugins [[lein-cljsbuild "1.1.7"]
[lein-figwheel "0.5.18"]]
:source-paths ["src/clj" "src/cljc"]
Expand Down
2 changes: 0 additions & 2 deletions examples/src/clj/examples/lab.clj
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
(ns examples.lab)

(use 'debux.core)

; (dbg (+ 2 3) :unknown)
6 changes: 1 addition & 5 deletions examples/src/cljs/examples/clog.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,14 @@
; => 60


; Sometimes you need to see several forms evaluated. To do so, a literal vector
; Sometimes you need to see several forms evaluated. To do so, a literal vector
; form can be used like this.

(defn my-fun
[a {:keys [b c d] :or {d 10 b 20 c 30}} [e f g & h]]
(clog [a b c d e f g h]))

(my-fun (take 5 (range)) {:c 50 :d 100} ["a" "b" "c" "d" "e"])
; => [(0 1 2 3 4) 20 50 100 "a" "b" "c" ("d" "e")]


; Notice that the printed value is a map, not a vector and the form
; is prepended with colon to differenciate the form from the evaluated value.

Expand All @@ -33,7 +30,6 @@
(def b 20)

(clog [a b [a b] :c])
; => [10 20 [10 20] :c]


; (-> {:a [1 2]}
Expand Down
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(defproject philoskim/debux "0.6.2"
(defproject philoskim/debux "0.6.3"
:description "A trace-based debugging library for Clojure and ClojureScript"
:url "https://github.com/philoskim/debux"
:license {:name "Eclipse Public License - v 1.0"
Expand Down
11 changes: 11 additions & 0 deletions src/debux/common/util.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,17 @@
(defn vec->map [v]
(apply hash-map v))

(defn vec->kw-map
"Transsub-forms a vector into an array-map with key/value pairs.
(def a 10)
(def b 20)
(vec-map [a b :c [30 40]])
=> {:a 10 :b 20 ::c :c :[30 40] [30 40]}"
[v]
(apply array-map
(mapcat (fn [elem]
`[~(keyword (str elem)) ~elem])
v) ))

;;; zipper
(defn sequential-zip [root]
Expand Down
5 changes: 3 additions & 2 deletions src/debux/cs/clog.clj
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,11 @@
(defmacro clog-others
[form {:keys [js] :as opts}]
`(clog-base ~form ~opts
(let [result# ~form]
(let [result# ~form
form2# ~(if (vector? form) (ut/vec->kw-map form) form)]
(if-let [print# ~(:print opts)]
(cs.ut/clog-result-with-indent (print# result#) ~js)
(cs.ut/clog-result-with-indent result# ~js))
(cs.ut/clog-result-with-indent form2# ~js))
result#) ))

(defmacro clog-once
Expand Down
5 changes: 3 additions & 2 deletions src/debux/dbg.clj
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,11 @@
(defmacro dbg-others
[form opts]
`(dbg-base ~form ~opts
(let [result# ~form]
(let [result# ~form
form2# ~(if (vector? form) (ut/vec->kw-map form) form)]
(if-let [print# ~(:print opts)]
(ut/pprint-result-with-indent (print# result#))
(ut/pprint-result-with-indent result#))
(ut/pprint-result-with-indent form2#))
result#) ))


Expand Down

0 comments on commit cc44f71

Please sign in to comment.