r/Clojure • • Oct 30 '25

Cljue: Reference ClojureDocs Offline

I've been trying to get into Clojure and one pain point was finding a function to do this or that. ClojureDocs has been really helpful, so I wrote this little Babashka script (source) to pull down the ClojureDocs export.json and search over it with fzf and bat.

I'm sure my code is far from idiomatic and I would love suggestions on how this script could be better.

(Also not very familiar with reddit, the image was intended to be a gif (source))

EDIT: Cljue source link above is a permalink to a specific commit (should always work). Here is a link for latest cljue (source)

96 Upvotes

16 comments sorted by

View all comments

Show parent comment

1

u/NonlinearFruit Nov 01 '25

Two questions:
- Any ideas on how to get the scripts absolute path? That would be great. I tried something like this ([stackoverflow](https://stackoverflow.com/a/13276993)) but ran into issues with `(class *ns*)` throwing a casting exception
- What does putting documentation on `clj-docs` mean? What is `clj-docs`?

I've been able to incorporate the rest of the feedback (shelling out, path/file conversions, when-not, clojure.core//). Thank you!

1

u/amalloy Nov 01 '25

You have a function named clj-docs. It could use a comment, or a docstring, explaining the JSON format.

You're already looking at *file* and (System/getProperty "babashka.file"). According to the Babashka documentation, *file* is just a String containing the running program's full path.

1

u/NonlinearFruit Nov 01 '25

Aaaah, I see, it was in front of my face the whole time. Thank you! I've documented the structure and cljue no longer assumes it is on the PATH.