Fork me on GitHub
#cljdoc
<
2019-06-06
>
martinklepsch07:06:05

@lee sounds great! Were you asking because it wasn't quite obvious what I had in mind?

borkdude09:06:56

@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 😉

borkdude09:06:30

@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}}

borkdude09:06:03

using the last two values, you could e.g. use https://github.com/lambdaisland/deep-diff to find differences

borkdude09:06:37

please note that the cache namespace in clj-kondo is an implementation detail and might break in a future version 😉

martinklepsch09:06:53

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

martinklepsch09:06:06

We should really get this API thing worked out 🙂

lread14:06:38

Did you start work on this yet? I think you were leaning toward a new separate repo to extract publics? Need a hand?

martinklepsch15:06:07

I didn't start working on an API yet. Not sure what you mean with the separate repo and how that would be related?

lread15:06:28

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

lread15:06:23

actually it looks like a stand-alone project is my assumption, you did not explicitly mention doing that.

lread16:06:31

but it seems like a good idea. A single purpose project that could be reused by maybe even codox master.

martinklepsch16:06:07

yes I was thinking of doing that

martinklepsch16:06:19

hands welcome for sure, I simply didn't get to it so far

martinklepsch16:06:56

I also thought that I had a branch with some modifications in that direction but I can't find that right now

lread16:06:56

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.

lread16:06:22

I’ll come back when I’m finished some other work and check if I can still be of help

martinklepsch16:06:02

whoops, I thought I already merged that PR, sorry for taking so long on this!

lread17:06:18

I thought you wanted to wait… I was ok with that.

lread17:06:30

whatever makes sense is fine with me.

borkdude09:06:33

adding to cljdoc directly would make sense?

martinklepsch09:06:52

oh yeah, that's what I'd love to see

borkdude09:06:53

but then it would maybe not work for libraries that are forks and renamed versions of others

borkdude09:06:09

unless you would make a “compare to” thingy

martinklepsch09:06:26

like a "mechanical changelog" where you can compare two versions of the same lib and you see the (obvious) API differences (changed arities etc)

borkdude09:06:03

yeah, but in lread’s case he’s doing a reworked version of some other library he’s trying to remain compatible with

borkdude09:06:15

so it’s not the same lib, different clojars coordinates

borkdude09:06:49

for accepting PRs this would also be useful

martinklepsch10:06:42

ah right, that's a bit of a different thing

borkdude10:06:32

but the automatic changelog is good to start with probably

borkdude10:06:43

and later a “compare to” option can be added maybe

martinklepsch10:06:18

yeah, or an API so people can do whatever 🙂

borkdude10:06:11

that’s even better. the automatic changelog could then use that API

lread12:06:49

That’s interesting @borkdude! Thanks for sharing the details!

borkdude12:06:18

@lee yeah, for one-off things it’s pretty easy to make a script out of it for your use case

lread12:06:20

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.

martinklepsch12:06:51

It always comes back to import-vars 😄

borkdude12:06:01

now that you mention it, clj-kondo should probably support that too 😉

borkdude12:06:57

does that also work in cljs?

borkdude12:06:07

probably not 😉

lread12:06:02

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.

borkdude12:06:34

@lee I wonder if that survives Closure advanced optimizations?

borkdude12:06:39

In Haskell this thing is built-in I think, re-exposing imported things

lread12:06:29

@borkdude, I didn’t occur to me that it might not, I am using cljs analyzer to do the import-vars magic.

borkdude12:06:57

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)

borkdude12:06:03

(some CLJC libraries I have are tested in 3 ways on CI: clojure, advanced CLJS, self-hosted CLJS)

borkdude12:06:17

you’ll be surprised how often it doesn’t work directly 😉

borkdude12:06:46

but in most cases things are fixable

lread12:06:51

Thanks for the tips. I doubt that it works under self hosted cljs.

borkdude12:06:17

well, the analyzer also works in self-hosted I think, so it might

lread12:06:22

But I really don’t understand self hosted cljs yet.

lread12:06:33

Another todo for me, thanks.

lread12:06:47

very helpful, thanks!