Skip to content

Commit ed3a0f0

Browse files
committed
[mod] [BREAKING] Omit defn_/fn_ prefix for named fns
1 parent b72f776 commit ed3a0f0

File tree

2 files changed

+29
-26
lines changed

2 files changed

+29
-26
lines changed

src/taoensso/tufte.cljc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,10 @@
524524
base-id
525525
(if ?meta-id
526526
(enc/as-qname ?meta-id)
527-
(str *ns* "/" (if def? "defn_" "fn_") (name fn-sym)))
527+
(str *ns* "/"
528+
(if ?fn-sym
529+
(name ?fn-sym)
530+
(str (if def? "defn_" "fn_") (name fn-sym)))))
528531

529532
get-ids
530533
(if single-arity?

test/taoensso/tufte_tests.cljc

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -546,15 +546,15 @@
546546
;;;; Util macros
547547

548548
(do
549-
(tufte/defnp fn1 [x] x) ; Line 549
550-
(tufte/defnp fn2 [x] x)
551-
(tufte/defnp ^{:tufte/id :__fn3} fn3 [x] x)
552-
(tufte/defnp ^{:tufte/id "__fn4"} fn4 ([x] x) ([x y] [x y]))
553-
(tufte/defnp- fn5 [x] x)
549+
(tufte/defnp fn1 [x] x) ; Line 549
550+
(tufte/defnp fn2 [x] x)
551+
(tufte/defnp ^{:tufte/id :my-fn3} fn3 [x] x)
552+
(tufte/defnp ^{:tufte/id "my-fn4"} fn4 ([x] x) ([x y] [x y]))
553+
(tufte/defnp- fn5 [x] x)
554554

555555
(defn run-test-fns []
556-
(let [fn6 (tufte/fnp fn6 [x] x)
557-
fn7 (tufte/fnp ^{:tufte/id :__fn7} fn7 [x] x)]
556+
(let [fn6 (tufte/fnp fn6 [x] x)
557+
fn7 (tufte/fnp ^{:tufte/id :my-fn7} fn7 [x] x)]
558558
[(fn1 "fn1")
559559
(fn2 "fn2")
560560
(fn3 "fn3")
@@ -569,15 +569,15 @@
569569
[(let [[r ps] (profiled {} (run-test-fns))]
570570
[(is (= r ["fn1" "fn2" "fn3" "fn4_1" ["fn4_2x" "fn4_2y"] "fn5" "fn6" "fn7" "fn1+2"]))
571571
(is (enc/submap? @ps
572-
{:stats {::defn_fn1 {:n 2},
573-
::defn_fn2 {:n 2},
574-
:__fn3 {:n 1},
575-
:__fn4 {:n 2}
576-
:__fn4_1 {:n 1}
577-
:__fn4_2 {:n 1}
578-
::defn_fn5 {:n 1}
579-
::fn_fn6 {:n 1}
580-
:__fn7 {:n 1}}}))])])
572+
{:stats {::fn1 {:n 2},
573+
::fn2 {:n 2},
574+
:my-fn3 {:n 1},
575+
:my-fn4 {:n 2}
576+
:my-fn4_1 {:n 1}
577+
:my-fn4_2 {:n 1}
578+
::fn5 {:n 1}
579+
::fn6 {:n 1}
580+
:my-fn7 {:n 1}}}))])])
581581

582582
;;;; Location info
583583

@@ -614,15 +614,15 @@
614614
[(is
615615
(enc/submap? @ps
616616
(let [nref 549]
617-
{:stats {::defn_fn1 {:loc {:line nref}}
618-
::defn_fn2 {:loc {:line (+ nref 1)}}
619-
:__fn3 {:loc {:line (+ nref 2)}}
620-
:__fn4 {:loc {:line (+ nref 3)}}
621-
:__fn4_1 {:loc {:line (+ nref 3)}}
622-
:__fn4_2 {:loc {:line (+ nref 3)}}
623-
::defn_fn5 {:loc {:line (+ nref 4)}}
624-
::fn_fn6 {:loc {:line (+ nref 7)}}
625-
:__fn7 {:loc {:line (+ nref 8)}}}})))])])
617+
{:stats {::fn1 {:loc {:line nref}}
618+
::fn2 {:loc {:line (+ nref 1)}}
619+
:my-fn3 {:loc {:line (+ nref 2)}}
620+
:my-fn4 {:loc {:line (+ nref 3)}}
621+
:my-fn4_1 {:loc {:line (+ nref 3)}}
622+
:my-fn4_2 {:loc {:line (+ nref 3)}}
623+
::fn5 {:loc {:line (+ nref 4)}}
624+
::fn6 {:loc {:line (+ nref 7)}}
625+
:my-fn7 {:loc {:line (+ nref 8)}}}})))])])
626626

627627
(comment (let [f1 (tufte/fnp foo [x] x #_(p :x x))]))
628628

0 commit comments

Comments
 (0)