Fork me on GitHub
#clojure-spec
<
2021-07-14
>
mathias_dw11:07:23

Hi, I'm sure it's been asked before, but googling didn't turn anything up: is there an easy way to associate comments to specs? My usecase is working together with some non-clojure (actually, non-programmer) people on a data definition. I'm used to spec and all the related tooling, but I can't expect the others to really understand everything from code.

mpenet12:07:00

it's not supported out of the box. you need to build your own metadata api for specs right now if you need that.

mpenet12:07:14

it's quite easy to do tho, basically an atom and a few functions that will work against it. We have something like that internally, we can do (-> (s/def ::foo string?) (x/vary-meta! assoc :doc "some docstring"))

mpenet12:07:49

s/def returns the spec key, you can take advantage of this. and from there writing x/with-doc is just a small fn

👍 2
Alex Miller (Clojure team)14:07:14

this is the most requested feature for spec and I expect it will be added in spec 2

👍 8
2