diff --git a/README.md b/README.md index 3654a389..c039bd38 100644 --- a/README.md +++ b/README.md @@ -949,12 +949,14 @@ Original by [@souenzzo](https://gist.github.com/souenzzo/a959a4c5b8c0c90df76fe33 ### Print random docstring +See [examples/random_doc.clj](https://github.com/borkdude/babashka/blob/master/examples/random_doc.clj) + ``` shell -$ bb "(defmacro random-doc [] (let [sym (-> (ns-publics 'clojure.core) keys rand-nth)] \`(clojure.repl/doc ~sym))) (random-doc)" +$ examples/random_doc.clj ------------------------- -clojure.core/keyword? +clojure.core/ffirst ([x]) - Return true if x is a Keyword + Same as (first (first x)) ``` ## Thanks diff --git a/examples/random_doc.clj b/examples/random_doc.clj new file mode 100755 index 00000000..c30c4214 --- /dev/null +++ b/examples/random_doc.clj @@ -0,0 +1,11 @@ +#!/usr/bin/env bb + +(require '[clojure.repl]) + +(defmacro random-doc [] + (let [sym (-> (ns-publics 'clojure.core) keys rand-nth)] + (if (:doc (meta (resolve sym))) + `(clojure.repl/doc ~sym) + `(random-doc)))) + +(random-doc)