cljdoc

https://cljdoc.org/ & https://github.com/cljdoc/cljdoc
Helins 2021-03-17T16:49:57.002200Z

I've written a CLJC lib which has a namespace with test.check generators. I don't want to force a dependency on test.check, this namespace is sort-of optional. Of course, Cljdoc cannot analyze this namespace since test.check is missing. Is there a solution, a way of declaring an optional dep for Cljdoc?

lread 2021-03-17T18:21:07.002800Z

@adam678, would @borkdude’s https://github.com/borkdude/dynaload help you here?

Helins 2021-03-17T18:33:56.005300Z

I might be mistaken but I don't think this solves the problem. Here, if I want to use that namespace, I just have to add test.check to my deps. If I don't want to use it, I simply don't require. The problem is that Cljdoc has no way of knowing that it needs test.check for analyzing that namespace and producing doc. It throws because test.check is not found.

localshred 2021-03-17T18:35:42.005800Z

can you put the test.check dep in an alias and use that alias when generating cljdocs?

Helins 2021-03-17T18:46:30.007100Z

@localshred Yes that would be ideal but is it possible to specify an alias for Cljdoc? I didn't find anything in the doc, maybe an oversight

localshred 2021-03-17T18:47:02.007500Z

ah, that I'm not aware of... sorry 😞

martinklepsch 2021-03-17T20:48:58.009Z

hey @adam678! if you specify a :scope "test" or :scope "provided" for the dependency it will be included during analysis but not considered a dependency by regular consumers

martinklepsch 2021-03-17T21:10:03.011400Z

It is a common pattern for Java pom.xml files to include optional dependencies this way

Helins 2021-03-17T21:12:09.011500Z

@martinklepsch Thanks Martin! I am not sure, does deps support adding a scope?! The generated pom file simply adds the dependency as a regular dep

Helins 2021-03-17T21:12:42.012100Z

I found that thread which mention this exact problem (in the context of Cljdoc) but no solution: https://ask.clojure.org/index.php/9110/scope-in-deps-edn-should-be-added-and-not-deleted-from-pom-xml