Skip to content

Commit

Permalink
v0.8.3
Browse files Browse the repository at this point in the history
README.adoc updated for Electric support
  • Loading branch information
philoskim committed Apr 10, 2023
1 parent a5ea7a7 commit 0af7402
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 43 deletions.
148 changes: 109 additions & 39 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.8.2"]
[philoskim/debux "0.8.3"]
....

and this to your *production* dependencies.

[source]
....
[philoskim/debux-stubs "0.8.2"]
[philoskim/debux-stubs "0.8.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.8.3
** link:https://github.com/hyperfiddle/electric[Electric] support added. See the details
<<electric, here>>.
* v0.8.2
** A bug fixed: pull request link:https://github.com/philoskim/debux/pull/26[#26]
Expand Down Expand Up @@ -440,7 +444,7 @@ See more examples <<dbg-last, here>>.
### Debugging the thread macro `pass:q[some->]` or `pass:q[some->>]`

The thread macro `pass:q[some->]` and `pass:q[some->>]` are supported in `dbg` and `clog`.

[source]
.Example 1
....
Expand Down Expand Up @@ -2041,7 +2045,7 @@ dbgn: (* a b (+ c d (- e f (* g h)))) =>
| 10
| b =>
| 9
|{:ns example.demo, :line 15}
|dbg: (+ c d (- e f (* g h))) =>
|| 4
Expand Down Expand Up @@ -2188,7 +2192,7 @@ own separate units, not mixed by one another.
{:ns examples.lab, :line 45}
dbg: (* 2 5) =>
| 10
{:ns examples.lab, :line 26}
dbg: (-> "a b c d" .toUpperCase (.replace "A" "X") (.split " ") first) <thread-no: 1> =>
| "a b c d" =>
Expand All @@ -2201,7 +2205,7 @@ dbg: (-> "a b c d" .toUpperCase (.replace "A" "X") (.split " ") first) <thread
| ["X", "B", "C", "D"]
| first =>
| "X"
{:ns examples.lab, :line 26}
dbg: (-> "a b c d" .toUpperCase (.replace "A" "X") (.split " ") first) <thread-no: 3> =>
| "a b c d" =>
Expand All @@ -2214,7 +2218,7 @@ dbg: (-> "a b c d" .toUpperCase (.replace "A" "X") (.split " ") first) <thread
| ["X", "B", "C", "D"]
| first =>
| "X"
{:ns examples.lab, :line 26}
dbg: (-> "a b c d" .toUpperCase (.replace "A" "X") (.split " ") first) <thread-no: 2> =>
| "a b c d" =>
Expand Down Expand Up @@ -2257,16 +2261,16 @@ Cantin] for the idea and inspiration for my writing these macros.
dbgt: (filter odd?)
|> 0
|< []
|> 1
|< [1]
|> 2
|< [1]
|> 3
|< [1 3]
|> 4
|< [1 3]
----
Expand All @@ -2289,22 +2293,22 @@ dbgt: (comp (map inc) (filter odd?))
||> 1
||< [1]
|< [1]
|> 1
||> 2
||< [1]
|< [1]
|> 2
||> 3
||< [1 3]
|< [1 3]
|> 3
||> 4
||< [1 3]
|< [1 3]
|> 4
||> 5
||< [1 3 5]
Expand All @@ -2330,7 +2334,7 @@ dbgt: (comp (map inc) (filter odd?))
| :locals or :l | O | O | O | O | O | O | X
| :print or :p | O | X | O | X | X | X | X
| :dup | X | 0 | X | 0 | X | X | X
| :level | O | O | O | O | O | O | X
| :level | O | O | O | O | O | O | X
| :style or :s | X | X | O | O | X | O | X
| :once or :o | X | X | O | X | X | X | X
| :js | X | X | O | O | X | X | X
Expand Down Expand Up @@ -2396,15 +2400,15 @@ multi-threads programming like this.
{:ns examples.lab, :line 20}
dbg: (* 10 5) =>
| 50
{:ns examples.lab, :line 6}
dbg: (* thread-no (+ 10 20)) <thread-no: 2> =>
| 60
{:ns examples.lab, :line 6}
dbg: (* thread-no (+ 10 20)) <thread-no: 3> =>
| 90
{:ns examples.lab, :line 6}
dbg: (* thread-no (+ 10 20)) <thread-no: 1> =>
| 30
Expand Down Expand Up @@ -2588,7 +2592,7 @@ dbg: i =>

The `:locals` option is added, according to the request
link:https://github.com/philoskim/debux/issues/19[#issue 19].

[source]
....
(let [x 10 y 20]
Expand All @@ -2605,26 +2609,26 @@ link:https://github.com/philoskim/debux/issues/19[#issue 19].
dbg: (+ x y) =>
| :locals =>
| {x 10, y 20}
| 30
{:ns examples.lab, :line 12}
dbg: (-> 100 inc inc) =>
| :locals =>
| {x 10, y 20}
| 100 =>
| 100
| inc =>
| 101
| inc =>
| 102
{:ns examples.lab, :line 14}
dbgn: (-> 200 inc inc) =>
| :locals =>
| {x 10, y 20}
| (inc 200) =>
| 201
| (inc (inc 200)) =>
Expand Down Expand Up @@ -2917,7 +2921,7 @@ dbg: (+ 10 20 5) =>
{:ns examples.lab, :line 12}
dbg: (+ 10 20 3) =>
| 33
{:ns examples.lab, :line 13}
dbg: (+ 10 20 5) =>
| 35
Expand Down Expand Up @@ -3096,7 +3100,7 @@ to wrap the form by the parentheses any more, if you want.
....
{:ns examples.lab, :line 5}
dbg: (+ 1 2 (* 3 4)) =>
|{:ns examples.lab, :line 5}
|dbg: (* 3 4) =>
|| 12
Expand All @@ -3118,7 +3122,7 @@ dbg: (+ 1 2 (* 3 4)) =>
dbgn: (+ (* 2 5) (+ 10 (* 3 4))) =>
| (* 2 5) =>
| 10
|{:ns examples.lab, :line 7}
|dbg: (+ 10 (* 3 4)) =>
|| 22
Expand All @@ -3139,7 +3143,7 @@ dbgn: (+ (* 2 5) (+ 10 (* 3 4))) =>
....
{:ns examples.lab, :line 9}
dbg: (+ (* 2 5) (+ 10 (* 3 4))) =>
|{:ns examples.lab, :line 9}
|dbgn: (+ 10 (* 3 4)) =>
|| (* 3 4) =>
Expand Down Expand Up @@ -3242,7 +3246,7 @@ See the detailed explaination link:doc/macro-debugging-in-clojurescript.adoc[her


[[cljs-devtools]]
## Support for `cljs-devtools`
## Support for `cljs-devtools` added

* The `clog`/`clogn` of `debux` supports
link:https://github.com/binaryage/cljs-devtools[cljs-devtools] since the version
Expand Down Expand Up @@ -3301,6 +3305,72 @@ image::chrome-devtools-settings.png[title="Enable custom formatters on Chrome De
configuration].


[[electric]]
## Support for `Electric` added

* link:https://github.com/hyperfiddle/electric[Electric] has some problems on expanding
the user-defined macros. See
link:https://github.com/hyperfiddle/electric/issues/38[here] for the related issue.

* So according to the advice of dustingetz, the author of _Electric_, I created the new
namespaces and wrote some macros for _Electric_ in _Debux_ as follows.
+
[listing]
----
;;; The server side macros for Electric
debux.electric namespace:
dbg, dbgn, dbgt, dbg-last, dbg_, dbgn_, dbgt_, dbg-last_
;;; The client side macros for Electric
debux.cs.electric namespace
clog, clogn, clogt, clog-last, clog_, clogn_, clogt_, clog-last_
dbg, dbgn, dbgt, dbg-last, dbg_, dbgn_, dbgt_, dbg-last_
----

* The following is the examples for Electric.
+
[source]
....
(ns user.demo-toggle
(:require [hyperfiddle.electric :as e]
[hyperfiddle.electric-dom2 :as dom]
[hyperfiddle.electric-ui4 :as ui]
#?(:cljs [debux.cs.electric :refer-macros [clog clogn clogt clog-last
clog_ clogn_ clogt_ clog-last_
dbg dbgn dbgt dbg-last
dbg_ dbgn_ dbgt_ dbg-last_]]) ))
#?(:clj (use 'debux.electric))
#?(:clj (defonce !x (atom true))) ; server state
(e/def x (e/server (e/watch !x))) ; reactive signal derived from atom
(e/defn Toggle []
(e/client
(dom/h1 (dom/text "Toggle Client/Server"))
(dom/div
(dom/text "number type here is: "
(case x
true (e/client (clogn (pr-str (type 1)))) ;; <-- Here
false (e/server (dbgn (pr-str (type 1))) )))) ;; <-- Here
(dom/div (dom/text "current site: "
(case x
true "ClojureScript (client)"
false "Clojure (server)")))
(ui/button (e/fn []
(e/server
(swap! !x not)))
(dom/text "toggle client/server"))))
....







## `break` examples (CLJS only)

Expand Down Expand Up @@ -3366,7 +3436,7 @@ image:break-4.png[]
If you want to turn off the source info line printing in the `debux` macros, use
`(set-source-info-mode! false)`. The `:ns` and `:line` source info line will not be
printed.

[source]
....
(set-source-info-mode! false)
Expand All @@ -3385,17 +3455,17 @@ printed.
----
dbg: (+ 2 3) =>
| 5
dbgn: (* 10 (+ 2 3)) =>
| (+ 2 3) =>
| 5
| (* 10 (+ 2 3)) =>
| 50
{:ns examples.lab, :line 11}
dbg: (+ 20 30) =>
| 50
{:ns examples.lab, :line 12}
dbgn: (* 10 (+ 2 3)) =>
| (+ 2 3) =>
Expand Down Expand Up @@ -3428,18 +3498,18 @@ You can change the default line bullet "`|`" by using `set-line-bullet!` as foll
{:ns examples.lab, :line 11}
dbg: (+ 20 30) =>
; 50
{:ns examples.lab, :line 12}
dbgn: (* 10 (+ 2 3)) =>
; (+ 2 3) =>
; 5
; (* 10 (+ 2 3)) =>
; 50
{:ns examples.lab, :line 17}
dbg: (+ 20 30) =>
50
{:ns examples.lab, :line 18}
dbgn: (* 10 (+ 2 3)) =>
(+ 2 3) =>
Expand Down Expand Up @@ -3473,7 +3543,7 @@ debux macro names or turn off the tagged literals by appending `pass:q[_]` after
| clog-last | clog-last_ | |

| break | break_ | |

|===


Expand Down Expand Up @@ -3617,7 +3687,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.8.2"]]
[philoskim/debux "0.8.3"]]
:plugins [[lein-cljsbuild "1.1.6"]
[lein-figwheel "0.5.10"]]
:source-paths ["src/clj"]
Expand Down Expand Up @@ -3796,4 +3866,4 @@ When you double-click on one of the open parentheses and the following string is
## License
Copyright © 2015--2022 Young Tae Kim

Distributed under the Eclipse Public License either version 1.0 or any later version.
Distributed under the Eclipse Public License either version 1.0 or any later version.
4 changes: 1 addition & 3 deletions examples/project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +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.8.2"]]
:plugins [[lein-cljsbuild "1.1.7"]
[lein-figwheel "0.5.18"]]
[philoskim/debux "0.8.3"]]
:source-paths ["src/clj" "src/cljc"]
:main examples.core
:clean-targets ^{:protect false}
Expand Down
Loading

0 comments on commit 0af7402

Please sign in to comment.