Welcome! Please see the About page for a little more info on how this works.

0 votes
in tools.namespace by
retagged by

Problem

v1.4.0 of tools.namespace returns metadata from namespace declarations. Newer versions do not.

Reproduction

Given ./src/foo.clj:

(ns ^{:doc "foo" :no-doc true} foo)

And ./test.clj:

(require '[clojure.tools.namespace.find :as f]
         '[clojure.java.io :as io])

(binding [*print-meta* true]
  (pr (f/find-ns-decls-in-dir (io/file "src"))))

If I use v1.4.0, I get the foo ns :doc and :no-doc metadata:

❯ clj -Sdeps '{:deps {org.clojure/tools.namespace {:mvn/version "1.4.0"}}}' -M test.clj
((ns ^{:doc "foo", :no-doc true} foo))

But if I use v1.4.4, the ns metadata includes the new generated :dir and :file metadata from tools.namespace, but not the :doc and :no-doc metadata:

❯ clj -Sdeps '{:deps {org.clojure/tools.namespace {:mvn/version "1.4.4"}}}' -M test.clj
((ns ^{:dir "src", :file "foo.clj"} foo))

This has been true since v1.4.1 when the jar/dir and file metadata feature was introduced:

❯ clj -Sdeps '{:deps {org.clojure/tools.namespace {:mvn/version "1.4.1"}}}' -M test.clj
((ns ^{:dir "src", :file "foo.clj"} foo))

Additional Info

The same issue should exhibit for find-ns-decls-in-jarfile.

Usage Scenario

Cljdoc uses tools.namespace to learn about namespaces before attempting to load them. It skips namespaces that have :no-doc and/or :skip-wiki metadata.

1 Answer

0 votes
by
...