nedap / speced.def

spec-backed forms of defn/defprotocol/..., aided by metadata
Eclipse Public License 2.0
67 stars 3 forks source link

Make def-with-doc play well with clojure.repl/doc #53

Closed vemv closed 5 years ago

vemv commented 5 years ago

The docstring in the top half should be included in the bottom one:

image

Acceptance criteria

vemv commented 5 years ago

cc/ @lennartbuit , I almost forgot to create an issue ;p

This is the doc macro:

(defmacro doc
  "Prints documentation for a var or special form given its name,
   or for a spec if given a keyword"
  {:added "1.0"}
  [name]
  (if-let [special-name ('{& fn catch try finally try} name)]
    `(#'print-doc (#'special-doc '~special-name))
    (cond
      (special-doc-map name) `(#'print-doc (#'special-doc '~name))
      (keyword? name) `(#'print-doc {:spec '~name :doc '~(spec/describe name)})
      (find-ns name) `(#'print-doc (#'namespace-doc (find-ns '~name)))
      (resolve name) `(#'print-doc (meta (var ~name))))))

It cannot be monkeypatched b/c https://github.com/clojure/clojure/blob/076e88449f2bf738c01803c3661d06f12d3cbaea/build.xml includes clojure.repl and <property name="directlinking" value="true"/>.

Maybe we can just copy defmacro doc and tweak as needed. Sounds good? Would you use it?