Fork me on GitHub
#hyperfiddle
<
2022-04-28
>
Daniel Jomphe11:04:58

A potentially very nice minor convention with RCF to document our intentions when building small utils.

👍 2
Daniel Jomphe11:04:10

Of course we should write a docstring too.

Daniel Jomphe11:04:17

Something like this.

(defn join-not-blank
  "Like clojure's str/join but does not separate str/blank? vals in coll.
   
   `(join-not-blank \"🧱\" [\"a\" \"\" nil \"b\"]) := \"a🧱\"`"
  ([coll]
   (str/join (remove str/blank? coll)))
  ([separator coll]
   (str/join separator (remove str/blank? coll))))

(rcf/tests
 ;; What we didn't like about str/join...
 (str/join       "🧱" ["a" "" nil "b"]) := "a🧱🧱🧱"
 ;; So we built this...
 (join-not-blank "🧱" ["a" "" nil "b"]) := "a🧱b"
 (join-not-blank       ["a" "" nil "b"]) := "ab"
 (join-not-blank "🧱" []) := ""
 (join-not-blank       []) := ""
 ;;
 )

Daniel Jomphe12:04:59

Gotta make time to create an utility to auto-append RCF tests to the end of function docstrings!

Dustin Getz12:04:01

Yeah it would be great to integrate with docstrings etc; it also might be possible to get editors to offer an interface for examples, RCF could set :tests meta on vars

Daniel Jomphe12:04:04

I will explore solutions external to RCF. If I reach some learnings about IDE UIs that might be useful to RCF too, I might ping you in e.g. #calva where I'll show some things to these folks.

Ben Sless09:04:42

Could be worth looking at now CIDER for example can display specs alongside docstrings

👀 1
Daniel Jomphe20:05:50

Geoffrey is already up to date on this but here's the entire code of my current prototype. I'm stopping improving it for a number of weeks (focusing on something else), but we're already satisfied with the following... With this, RCF tests can now (still) be auto-executed, but also auto-added to VS Code Calva's doc hover tooltips. https://clojurians.slack.com/archives/CBE668G4R/p1651609025359479?thread_ts=1651259227.960969&amp;cid=CBE668G4R

Daniel Jomphe12:04:59

Gotta make time to create an utility to auto-append RCF tests to the end of function docstrings!