spec-provider icon indicating copy to clipboard operation
spec-provider copied to clipboard

Consider using pretty-spec/pprint instead of clojure.pprint/pprint to pprint specs

Open jpmonettas opened this issue 7 years ago • 5 comments

Maybe https://github.com/jpmonettas/pretty-spec can help pprinting specs more similar to what you would write by hand.

jpmonettas avatar Aug 10 '17 14:08 jpmonettas

Does pretty-spec support shortening namespaces so that clojure.spec.alpha/fspec becomes s/fspec in the printout? This is useful if you want to paste the output back into your code.

stathissideris avatar Aug 10 '17 14:08 stathissideris

Added that to version 0.1.3

user> (pspec/pprint (s/form 'clojure.core/let)
                    {:ns-aliases {"clojure.spec.alpha" "s"
                                  "clojure.core.specs.alpha" "score"
                                  "clojure.core" nil}})

; (s/fspec
;  :args (s/cat :bindings :score/bindings :body (s/* any?))
;  :ret any?
;  :fn nil)
                                                 

jpmonettas avatar Aug 12 '17 13:08 jpmonettas

I've started using this in the latest master for function specs and it works pretty well, my own code still as to convert :foo/bar to ::bar when appropriate. I'll try it for "data" specs as well. Thanks!

stathissideris avatar Oct 14 '17 23:10 stathissideris

@stathissideris any news ?

marco-m avatar Feb 15 '18 11:02 marco-m

I've started testing pretty-spec in trace.clj (the undocumented part of spec-provider that attempts to deal with inferring specs of functions - not ready yet). I thought that I would release both features together, but function specs are taking a little longer than I expected, so maybe it would be worth to go for pretty-spec independently. Thanks for reminding me!

stathissideris avatar Feb 15 '18 11:02 stathissideris