stathissideris / spec-provider

Infer Clojure specs from sample data. Inspired by F#'s type providers.
519 stars 22 forks source link

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

Open jpmonettas opened 7 years ago

jpmonettas commented 7 years ago

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

stathissideris commented 7 years ago

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.

jpmonettas commented 7 years ago

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)
stathissideris commented 6 years ago

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!

marco-m commented 6 years ago

@stathissideris any news ?

stathissideris commented 6 years ago

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!