reducecombine / fridge

Ideas for awesomer Clojure development
0 stars 0 forks source link

Universal repl-friendly doc helper #10

Open vemv opened 4 years ago

vemv commented 4 years ago

clojure.repl/doc is quite limited.

I'm thinking of a replacement that does the following:

The idea is to have a 'megamorphic' macro that tries to gather all possible relevant info and print it at once. 0 to N 'providers' (:doc metadata, speced.def, clojuredocs) may match.

The result would be an IDE-agnostic tool, that would bring a lot of smartness / interactivity to the table - particularly for folks stuck into a not particularly Clojurey workflow.

vemv commented 4 years ago

Here's a silly emacs snippet that I'm using atm:

(-> Integer/parseInt quote ((fn [x]

                              (cond
                                (not (symbol? x)) ;; ::some-spec
                                (eval \`(nedap.speced.def/doc ~(eval x)))

                                (try ;; Integer/parseInt
                                  (eval x)
                                  false
                                  (catch Exception _
                                    true))
                                (eval \`(clojure.java.javadoc/javadoc ~(-> x str (clojure.string/split #"/") first symbol)))

                                (try ;; Integer
                                  (-> x eval class?)
                                  (catch Exception _
                                    false))
                                (eval \`(clojure.java.javadoc/javadoc ~(-> x eval)))

                                true ;; +, clojure.core/+
                                (eval \`(nedap.speced.def/doc ~(-> x))))

                              )))