Skip to content

Macros that are not loaded should be included in cljs analysis #76

@lread

Description

@lread

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:

(ns testing123.macros)

(defmacro cljs-doc-only #?(:clj {:no-doc true}) [x]
  `(println "ho" ~x))

(defmacro clj-doc-only #?(:cljs {:no-doc true}) [x]
  `(println "hey" ~x))

#?(:clj (defmacro clj-code-only [x]
          `(println "foo" ~x))
   :cljs (defmacro cljs-code-only [x]
           `(println "bar" ~x)))

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions