cider
                                
                                 cider copied to clipboard
                                
                                    cider copied to clipboard
                            
                            
                            
                        cider-clojuredocs and cider-clojuredocs-web with clojurescript
Hi,
When I try to use cider-clojuredocs from clojurescript codes it says : ‘cider-clojuredocs’ doesn’t support ClojureScript
But when I try to use cider-clojuredocs-web from clojurescript it does open a browser window but with a wrong url, for example if I lookup "case", it goes to https://clojuredocs.org/cljs.core/case which is obviously wrong.
Because there is no equivalent of clojuredocs for clojurescript, I think the correct behaviour should be that it opens the corresponding clojuredocs documentation (even if clojurescript).
After checking a bit the code of cider-clojuredocs.el I have found that the lines
(when (derived-mode-p 'clojurescript-mode)
    (user-error "`cider-clojuredocs' doesn't support ClojureScript"))
Are present in (defun cider-clojuredocs [..] but not in (defun cider-clojuredocs-web [..] so
Either we have to have a similare behaviour for both which is generating a "user-error" ..
Or we remove this check and try to translate "cljs.core" to "clojure.core" (for example) in the urls and let it work for clojurescript ?
I would be motivated to work on this but I'd like to know what you guys think the correct behaviour should be.
Environment & Version information
CIDER version information
CIDER 0.25.0snapshot nREPL 0.7.0
Emacs version
27.0.91
Operating system
OS X 10.14.6 "Mojave"
But when I try to use cider-clojuredocs-web from clojurescript it does open a browser window but with a wrong url, for example if I lookup "case", it goes to https://clojuredocs.org/cljs.core/case which is obviously wrong.
I guess that's a remnant of our days of using conj.io, which actually had docs for ClojureScript as well. That was part of the reason why I preferred it over ClojureDocs initially (plus it had some actual API that we could use).
Or we remove this check and try to translate "cljs.core" to "clojure.core" (for example) in the urls and let it work for clojurescript ?
We can certainly do it, but I guess that'd be a bit misleading in some cases. Can you remind me if we cljs.core was the only namespace with a different name compared to Clojure?
We can certainly do it, but I guess that'd be a bit misleading in some cases. Can you remind me if we cljs.core was the only namespace with a different name compared to Clojure?
From what I can see on https://cljs.github.io/api/ it's not a simple translation from cljs -> clojure
Here is the list from https://cljs.github.io/api/ :
- cljs.core
- cljs.js
- cljs.nodejs
- cljs.pprint
- cljs.reader
- cljs.repl
- cljs.spec.alpha
- cljs.spec.gen.alpha
- cljs.spec.test.alpha
- cljs.test
- clojure.core.reducers
- clojure.data
- clojure.reflect
- clojure.set
- clojure.string
- clojure.walk
- clojure.zip
So we can see that for the last ones they kept "clojure.xxx" ..
Regarding the "misleading" nature of it, we could have a config flag or something to toggle between "we don't support" to "we redirect to clojuredoc's clojure version" ?
Yeah, that's true. I'm thinking that we probably won't lose much by translating any namespace starting with cljs to clojure, at least for the time being. I hope that down the road ClojureDocs is going to add some ClojureScript coverage.
Ok Great, I'll try to submit a PR with a proposal for it. Shall I just send to clojuredocs for clojurescript ALWAYS or shall I have some config to activate it ? (Not sure how I would do the config part but I will dig a bit ..) I'm really NOT an expert in elisp .. Actually I'm a newbie to emacs and elisp .. But I'm learning ...
Shall I just send to clojuredocs for clojurescript ALWAYS or shall I have some config to activate it ? (Not sure how I would do the config part but I will dig a bit ..)
No need for config.
I've checked the code this morning and I see that's going to be trickier than I thought, because the command that displays the docs in a buffer is Clojure-specific (it does symbol name resolution in Clojure context). I guess that's why it currently throws this error, as it won't work with a ClojureScript buffer anyways. For the translation to work the whole approach needs to be changed - doing symbol resolution in one step and fetching data for a fully resolved name in a second step. That way one can update the name between the steps.
Well the weird thing is that it worked from cljs code for cider-clojuredocs-web (event thou the url was wrong :https://clojuredocs.org/cljs.core/case) but it is blocked for cider-clojuredocs 🤔
So it did resolve the cljs symbol
You didn't understand me - I meant to say that when we call the web version we resolve to symbol and use this symbol to generate the URL that we end up opening, but for the other version there's no separate resolve step - we just pass the symbol at point to the middleware and it's resolved there in the same context in which it fetches the data from the ClojureDocs EDN export. That's why this was disabled in the first place - it simply won't work for a ClojureScript symbol the way it's written today. It's not some complex change, but it's definitely a bit more involved than I expected it to be.
@bbatsov yes I get it now ... Thanks