-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Macros that are not loaded should be included in cljs analysis #76
Comments
AfterthoughtsBut that (ns testing123.macros2
#?(:cljs (:require-macros [testing123.macros2])))
#?(:clj (defmacro clj-code-only [x]
`(println "foo" ~x))) So, a macro that is not explicitly exposed in this way for cljs easy-use, would have to be brought in by A thoughtful library author would probably not typically force the user of their library to use But...This syntax/technique did not always exist, it was introduced in 2015. Some very old or naive libraries would still expect their macros to be required the old way. (here's where core.async made the change to support the new syntax). So...I'm not so sure about this anymore. If a macro needs to be brought in by And how is a modern cljs developer to know that they need to use a special syntax to bring in the macro? |
Well, I guess we just can't know the author's intent for macros potentially reachable from cljs. If an author is surprised that their macros are included in the cljs API presented by cljdoc, we do offer a mechanism to exclude them via So... I think I'll take a stab at including reachable macros in the cljs API. If an author has requested only cljs analysis we'll not also include the macro under clj analysis. |
Another optionIf the macro is loaded during cljs analysis it is currently included in the cljs analysis. Perhaps if the macro is not loaded, it should appear under clj analysis only. This option implies, other than adding some tests, do nothing. But...But can I replicate this for static analysis? (an exploration currently in progress) |
Currently
While looking at cljdoc/cljdoc#543 I was reminded that
ClojureScript analysis only includes macros in
.clj
files if they happen to be loaded by other namespaces in a library.But...
Since all Clojure macros are available to ClojureScript, all macros should be included under ClojureScript analysis.
But tell me Lee...
What if a library author wanted to exclude a macro from their API?
Well, the macro or macro namespace could be marked with
^:no-doc
.But if a library author wants to include a macro for ClojureScript but not Clojure?
Well, I think one way would be to use reader conditionals in a .cljc file like so:
So...
Does this mean we have to always do Clojure analysis to pick up macros in
.clj
files, even if the user has requested ClojureScript-only analysis?Maybe. Not sure yet.
The text was updated successfully, but these errors were encountered: