cljdoc

https://cljdoc.org/ & https://github.com/cljdoc/cljdoc
martinklepsch 2019-06-06T07:45:05.011400Z

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

borkdude 2019-06-06T09:07:56.011900Z

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

borkdude 2019-06-06T09:45:30.013200Z

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

borkdude 2019-06-06T09:46:03.013600Z

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

borkdude 2019-06-06T09:46:37.014400Z

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

martinklepsch 2019-06-06T09:53:53.015600Z

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

martinklepsch 2019-06-06T09:54:06.016Z

We should really get this API thing worked out 🙂

borkdude 2019-06-06T09:54:33.016300Z

adding to cljdoc directly would make sense?

martinklepsch 2019-06-06T09:54:52.017Z

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

borkdude 2019-06-06T09:54:53.017100Z

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

borkdude 2019-06-06T09:55:09.017700Z

unless you would make a “compare to” thingy

martinklepsch 2019-06-06T09:55:26.018200Z

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

borkdude 2019-06-06T09:57:03.018800Z

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

borkdude 2019-06-06T09:57:15.019Z

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

borkdude 2019-06-06T09:57:49.019400Z

for accepting PRs this would also be useful

martinklepsch 2019-06-06T10:05:42.019800Z

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

borkdude 2019-06-06T10:10:32.020200Z

but the automatic changelog is good to start with probably

borkdude 2019-06-06T10:10:43.020600Z

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

martinklepsch 2019-06-06T10:11:18.021Z

yeah, or an API so people can do whatever 🙂

borkdude 2019-06-06T10:34:11.021400Z

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

lread 2019-06-06T12:09:49.022900Z

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

borkdude 2019-06-06T12:10:18.023300Z

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

lread 2019-06-06T12:19:20.029700Z

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.

martinklepsch 2019-06-06T12:19:51.030100Z

It always comes back to import-vars 😄

borkdude 2019-06-06T12:22:01.030500Z

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

borkdude 2019-06-06T12:22:57.030700Z

does that also work in cljs?

borkdude 2019-06-06T12:24:07.030900Z

probably not 😉

lread 2019-06-06T12:45:02.038500Z

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.

borkdude 2019-06-06T12:46:34.039100Z

@lee I wonder if that survives Closure advanced optimizations?

borkdude 2019-06-06T12:47:39.039800Z

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

lread 2019-06-06T12:49:29.041800Z

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

borkdude 2019-06-06T12:49:57.042300Z

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)

borkdude 2019-06-06T12:51:03.043400Z

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

borkdude 2019-06-06T12:51:17.043900Z

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

borkdude 2019-06-06T12:51:46.044600Z

but in most cases things are fixable

lread 2019-06-06T12:51:51.044800Z

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

borkdude 2019-06-06T12:52:17.045900Z

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

lread 2019-06-06T12:52:22.046100Z

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

lread 2019-06-06T12:53:33.046800Z

Another todo for me, thanks.

borkdude 2019-06-06T12:53:48.047Z

example project: https://github.com/borkdude/respeced/blob/master/script/test

lread 2019-06-06T12:54:47.047600Z

very helpful, thanks!

lread 2019-06-06T14:09:38.050300Z

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

martinklepsch 2019-06-06T15:30:07.050500Z

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

lread 2019-06-06T15:58:28.050700Z

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

lread 2019-06-06T15:59:23.051Z

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

lread 2019-06-06T16:00:31.051200Z

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

martinklepsch 2019-06-06T16:06:07.051400Z

yes I was thinking of doing that

martinklepsch 2019-06-06T16:07:19.051600Z

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

martinklepsch 2019-06-06T16:07:56.051800Z

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

lread 2019-06-06T16:16:56.052Z

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.

lread 2019-06-06T16:18:22.052300Z

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

martinklepsch 2019-06-06T16:19:02.052500Z

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

lread 2019-06-06T17:39:18.052700Z

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

lread 2019-06-06T17:39:30.052900Z

whatever makes sense is fine with me.