This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-02-21
Channels
- # announcements (6)
- # bangalore-clj (1)
- # beginners (46)
- # cider (21)
- # cljs-dev (30)
- # cljsjs (3)
- # clojure (131)
- # clojure-dev (20)
- # clojure-europe (2)
- # clojure-italy (12)
- # clojure-nl (11)
- # clojure-russia (4)
- # clojure-spec (55)
- # clojure-uk (57)
- # clojurebridge (1)
- # clojured (1)
- # clojurescript (55)
- # cursive (11)
- # data-science (1)
- # datomic (23)
- # duct (1)
- # emacs (1)
- # events (1)
- # figwheel-main (2)
- # fulcro (219)
- # graphql (16)
- # immutant (1)
- # jackdaw (3)
- # java (6)
- # juxt (30)
- # kaocha (8)
- # mount (3)
- # nyc (1)
- # off-topic (16)
- # pathom (48)
- # pedestal (1)
- # re-frame (71)
- # reagent (17)
- # ring-swagger (3)
- # shadow-cljs (96)
- # spacemacs (21)
- # specter (8)
- # speculative (20)
- # sql (21)
- # test-check (2)
- # tools-deps (12)
- # vim (6)
What tools do people use for generating docs from clojure code?
cljdoc generates the documentation part automatically if you put your project on Clojar I believe
I heard about marginalia also
Never tried it, it seems to be kind of documentation generation/ literate programming type of library
On a tangent, I wonder if these tools could at some point make use of specs to enhance the documentation
It's goal is to try to do something akin to Hoogle => https://www.haskell.org/hoogle/
Research function based on their signature
Really cool feature for Haskell
That could probably be recreated for Clojure with the help of Spec
So many times while browsing docs, I ask "ok, but what does this opts map look like?"
Martin Klepsch advocates to use table in docstring to help understand what keys goes into opts map
It's funny because every questions you have here, I read about it like 2h ago
Do you have this week's lottery numbers too?
28 26 19 18 41 14
A couple days ago I came here asking for help with exception handling happening within futures. I wrote up a little code to show what I was working with and I mistakingly didn't replicate the actual code verbatim. The real code looks like this
(def list-names '("Tom" "Harry" "Richard"))
(defn throw-func
[nme]
(str "hello " nme)
(throw (Exception. "I just threw you an error")))
(defn tc-test
[]
(let [futures (map (fn [name]
(let [sample (fn [name]
(try
(println "Sanity Check")
#(throw-func name)
(catch Exception e
(println "Got an error here!"))))]
(future ((sample name)))))
list-names)
response (doall (map deref futures))]
1))
(defn foo
[]
(try
(tc-test)
(catch Exception e
(println "Handling error here as well"))))
Then after talking with a co worker he points out my flaw. And it all made sense! Anyways, just in case anyone was curious or runs into a similar issue.I never saw the exception in sample because there was no exception happening when returning an anonymous function. So to fix I had to return the try-catch and call throw-func. Then everything worked as I expected it
Thanks for the doc generation links and Martin Klepsch’s article on writing good docs. I had just finished documenting a couple of functions but was curious if it would be beneficial to put the breakdown of map properties into the meta of a function and write a tool to use it to build more detailed docs. Right now it feels like a big ’ol string.
So something like (println "hello" name "!")
automatically includes a space between operands. => hello chasote !
Seemed convenient at first but how do I get rid of the space if I don't want it?
(println (str "hello" name "!"))
simple enough! there will be a day when I'll be like, "why can't str
just put the darn space in for me!" haha
hehe, its pretty common in other languages, JavaScript’s console.log
, Pythons print(...)
and such do the same ^^
Hi All. If I have a vector of vectors (with strings as they type of each of the four elements of the individual vectors), what would be the best way to go about combing vectors that have the same first element string value?
So [["hey" "1" "2" "3"] ["you" "4" "5" "6"] ["hey" "7" "8" "9"]] would return [["hey" "1" "2" "3" "7" 8" "9"] ["you" "4" "5" "6"]]
I am guessing this would be a good case for a loop, any opinions?
you might play with group-by first
that's just a first step
@alexmiller Thank you! I think this puts me on the right path.
be careful, you get a map from that, so if its important to you that “hey” stays before “you”, the order of the entries in a map is not guaranteed
Thank you for the heads-up @lennart.buit.
Hi guys, I was wondering if there is something along the lines of didSet
in clojure?
The use case I'm thinking of is: an atom
is updated with a new value and then I want to fire some API request using the newValue
I found https://clojuredocs.org/clojure.core/add-watch, haven’t used it, but maybe it helps you
this is exactly what add-watch is for
I forget though, does the watch fire before or after possible retries?
answer: after retry
(ins)user=> (def a (atom 0))
#'user/a
(ins)user=> (def retries (atom 0))
#'user/retries
(cmd)user=> (add-watch a :foo (fn [_ _ _ _] (swap! retries inc)))
#object[clojure.lang.Atom 0x2f48b3d2 {:status :ready, :val 0}]
(ins)user=> (dotimes [_ 1000] (future (swap! a inc)))
nil
(ins)user=> @a
1000
(ins)user=> @retries
1000
retries should have been called tries
in retrospect, but since the numbers match it clearly only fires the watch after the retry if any
Thanks for confirming my googles, noisesmith! TIL
(cmd)user=> (def a (atom 0))
#'user/a
(cmd)user=> (def tries (atom 0))
#'user/tries
(ins)user=> (dotimes [_ 1000] (future (swap! a (fn [x] (swap! tries inc) (inc x)))))
nil
(cmd)user=> @a
1000
(ins)user=> @tries
1052
- for 1000 items, 52 retries