tiny babashka script that returns a random clojure doc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bb | |
(require '[clojure.repl]) | |
(def namespaces ; well, readily available ones | |
['clojure.core | |
'clojure.edn | |
'clojure.instant | |
'clojure.java.browse | |
'clojure.java.io | |
'clojure.java.shell | |
'clojure.main | |
'clojure.pprint | |
'clojure.repl | |
'clojure.string | |
'clojure.walk]) | |
(defmacro random-doc [] | |
(let [sym (->> namespaces | |
(mapcat ns-publics) | |
(filter (comp :doc meta resolve first)) | |
rand-nth | |
first)] | |
`(clojure.repl/doc ~sym))) | |
(random-doc) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
inspired by https://github.com/tomekw/cotd :)