@lee sounds great! Were you asking because it wasn't quite obvious what I had in mind?
@lee you can use clj-kondo for this, I could explain how. but since this is not part of a public contract, I haven’t documented this anywhere 😉
@lee quick REPL session:
$ clj
Clojure 1.10.0
user=> (require '[clj-kondo.impl.cache :as cache])
nil
user=> (require '[clj-kondo.core :as clj-kondo])
user=> (clj-kondo/run! {:lint ["/tmp/rewrite-clj/src"] :cache "/tmp/rewrite-clj"})
...
user=> (clj-kondo/run! {:lint ["/tmp/rewrite-cljs-playground/src"] :cache "/tmp/playground"})
...
user=> (cache/from-cache "/tmp/rewrite-clj/2019.06.02-alpha-SNAPSHOT" :clj ['rewrite-clj.parser.core])
{rewrite-clj.parser.core {dispatch {:fixed-arities #{1}, :private? true, :ns rewrite-clj.parser.core, :name dispatch, :base-lang :clj, :lang :clj, :col 1, :row 17}, parse-next {:fixed-arities #{1}, :ns rewrite-clj.parser.core, :name parse-next, :base-lang :clj, :lang :clj, :col 1, :row 33}, parse-delim {:fixed-arities #{2}, :private? true, :ns rewrite-clj.parser.core, :name parse-delim, :base-lang :clj, :lang :clj, :col 1, :row 39}, parse-printables {:private? true, :ns rewrite-clj.parser.core, :name parse-printables, :base-lang :clj, :var-args-min-arity 3, :lang :clj, :col 1, :row 46}, :source :disk}}
user=> (cache/from-cache "/tmp/playground/2019.06.02-alpha-SNAPSHOT" :cljc ['rewrite-clj.parser.core])
{rewrite-clj.parser.core {:clj {dispatch {:fixed-arities #{1}, :private? true, :ns rewrite-clj.parser.core, :name dispatch, :base-lang :cljc, :lang :clj, :col 1, :row 16}, parse-next {:fixed-arities #{0}, :ns rewrite-clj.parser.core, :name parse-next, :base-lang :cljc, :lang :clj, :col 1, :row 32}, parse-delim {:fixed-arities #{1}, :private? true, :ns rewrite-clj.parser.core, :name parse-delim, :base-lang :cljc, :lang :clj, :col 1, :row 38}, parse-printables {:private? true, :ns rewrite-clj.parser.core, :name parse-printables, :base-lang :cljc, :var-args-min-arity 2, :lang :clj, :col 1, :row 45}}, :cljs {dispatch {:fixed-arities #{1}, :private? true, :ns rewrite-clj.parser.core, :name dispatch, :base-lang :cljc, :lang :cljs, :col 1, :row 16}, parse-next {:fixed-arities #{1}, :ns rewrite-clj.parser.core, :name parse-next, :base-lang :cljc, :lang :cljs, :col 1, :row 32}, parse-delim {:fixed-arities #{2}, :private? true, :ns rewrite-clj.parser.core, :name parse-delim, :base-lang :cljc, :lang :cljs, :col 1, :row 38}, parse-printables {:private? true, :ns rewrite-clj.parser.core, :name parse-printables, :base-lang :cljc, :var-args-min-arity 3, :lang :cljs, :col 1, :row 45}}, :source :disk}}
using the last two values, you could e.g. use https://github.com/lambdaisland/deep-diff to find differences
please note that the cache namespace in clj-kondo is an implementation detail and might break in a future version 😉
A similar approach could be taken with the data in cljdoc but that's still a bit hard to get to unless you're willing to add this to cljdoc directly
We should really get this API thing worked out 🙂
adding to cljdoc directly would make sense?
oh yeah, that's what I'd love to see
but then it would maybe not work for libraries that are forks and renamed versions of others
unless you would make a “compare to” thingy
like a "mechanical changelog" where you can compare two versions of the same lib and you see the (obvious) API differences (changed arities etc)
yeah, but in lread’s case he’s doing a reworked version of some other library he’s trying to remain compatible with
so it’s not the same lib, different clojars coordinates
for accepting PRs this would also be useful
ah right, that's a bit of a different thing
but the automatic changelog is good to start with probably
and later a “compare to” option can be added maybe
yeah, or an API so people can do whatever 🙂
that’s even better. the automatic changelog could then use that API
That’s interesting @borkdude! Thanks for sharing the details!
@lee yeah, for one-off things it’s pretty easy to make a script out of it for your use case
my original thought was, as @martinklepsch was suggesting, to look at publics via analyzers like cljdocs version of codox does. I thought this might work better because rewrite-clj makes use of a version of potemkin (hotly debated) import-vars.
It always comes back to import-vars
😄
now that you mention it, clj-kondo should probably support that too 😉
does that also work in cljs?
probably not 😉
I have created a version of import-vars for cljs within my rewrite-clj/rewrite-clj merge effort. I did it as a learning effort but since the concept is so contentious I questioned myslef often. 😬 It also led me here to cljdoc because the cljdoc codox fork needed to be updated to support cljs import-vars.
@lee I wonder if that survives Closure advanced optimizations?
In Haskell this thing is built-in I think, re-exposing imported things
@borkdude, I didn’t occur to me that it might not, I am using cljs analyzer to do the import-vars magic.
it could work, just something to be aware of. also I’d test if it works under self-hosted CLJS (e.g. Planck or Lumo)
(some CLJC libraries I have are tested in 3 ways on CI: clojure, advanced CLJS, self-hosted CLJS)
you’ll be surprised how often it doesn’t work directly 😉
but in most cases things are fixable
Thanks for the tips. I doubt that it works under self hosted cljs.
well, the analyzer also works in self-hosted I think, so it might
But I really don’t understand self hosted cljs yet.
Another todo for me, thanks.
example project: https://github.com/borkdude/respeced/blob/master/script/test
very helpful, thanks!
Did you start work on this yet? I think you were leaning toward a new separate repo to extract publics? Need a hand?
I didn't start working on an API yet. Not sure what you mean with the separate repo and how that would be related?
Oops, we might be talking about different things. I’m referring to the cljdoc fork of codox. My memory is fuzzy but I thought you were considering moving away from the codox fork and creating a stand-alone project https://github.com/cljdoc/codox/pull/1#issuecomment-490548935
actually it looks like a stand-alone project is my assumption, you did not explicitly mention doing that.
but it seems like a good idea. A single purpose project that could be reused by maybe even codox master.
yes I was thinking of doing that
hands welcome for sure, I simply didn't get to it so far
I also thought that I had a branch with some modifications in that direction but I can't find that right now
I think you expressed some goals in our discussion https://github.com/cljdoc/codox/pull/1 I suppose extracting these to an adr might make sense.
I’ll come back when I’m finished some other work and check if I can still be of help
whoops, I thought I already merged that PR, sorry for taking so long on this!
I thought you wanted to wait… I was ok with that.
whatever makes sense is fine with me.