Fork me on GitHub
#cursive
<
2024-02-07
>
Drew Verlee00:02:01

How do i setup javadocs using intelliji and cursive?

cfleming00:02:46

What do you want to set up? Hopefully, they should just work.

Drew Verlee00:02:34

maybe i just dont know how to view them. So in the code below how would i get java docs for Base64/getDecoder:

(ns point-codec
  (:require
   [ :as io]
   [clojure.string :as str])
  (:import
   ( DataInputStream)
   (java.util Base64 UUID)
   (java.util.zip GZIPInputStream)))

(defn unzip
  [encoded-points]
  (->> encoded-points
       (.decode (Base64/getDecoder))
       io/input-stream
       GZIPInputStream.
       DataInputStream.))

cfleming00:02:00

If you put the caret on e.g. Base64 and use View | Quick Documentation do you see it?

cfleming00:02:27

On a Mac it’s also bound to ^J, I can’t remember the key code for other platforms. The doc will show them to you for your platform: https://cursive-ide.com/userguide/documentation.html

Drew Verlee00:02:09

this is what i get:

cfleming00:02:02

I get the full thing:

Drew Verlee00:02:05

in my other pure java project, i had to tell gradle to download the java docs. And in emacs with cider i had to enable something in the cider configuration, so i assume there is the same there here.

Drew Verlee00:02:47

like, maybe the issue is that i'm using deps and not lein? (lein being more batteries included)

cfleming00:02:11

No, it’s how your Java SDK is set up in IntelliJ I think. One sec…

cfleming00:02:26

If you go to File | Project Structure… and then select Project on the left, you should see an SDK on the right.

cfleming00:02:59

Then, if you select SDKs on the left, and select the SDK you’re using on the right, what does that look like? If you click on Sourcepath, is there anything there?

Drew Verlee00:02:20

i added the documentation path the editor recommended (first picture) and then i get some docs (second picture)

Drew Verlee00:02:29

reading what you said now...

Drew Verlee00:02:25

nothing in my sourcepath:

cfleming00:02:26

Ok, so I think that’s the problem, that your JDK doesn’t have sources downloaded. Probably the easiest fix is just to get IntelliJ to download another JDK, which will set it all up correctly. If you click +, then download JDK… then follow the process, then select the new JDK for your project by selecting Project on the left again, then I think it should work for you.

👍 1
cfleming00:02:16

Or you might have other JDKs lying around which IntelliJ has autodetected, they’ll be in the list when you click +. You could check them and see if they work better. But if you don’t mind the download getting a new one is probably the most likely to just let you get on with your day.

Drew Verlee00:02:23

thanks. Yep, i got the docs adding the documentation path. Ok, now i dont have to guess on how to get the docs for stuff, which was quickly becoming much harder then it was in pure clojure land.

cfleming00:02:58

That will work for platform classes, if you want the same for library classes it’s a little more involved. Deps doesn’t have a good way of downloading sources by default, but Cursive does have some support for this: https://cursive-ide.com/userguide/deps.html#downloading-and-attaching-source-artefacts