File tree Expand file tree Collapse file tree 3 files changed +31
-0
lines changed Expand file tree Collapse file tree 3 files changed +31
-0
lines changed Original file line number Diff line number Diff line change 266
266
(doseq [[tag parents] hierarchy, parent parents]
267
267
(derive tag parent)))))))
268
268
269
+ #?(:clj
270
+ (defn load-annotations
271
+ " Search the base classpath for all resources that share the same path
272
+ (by default `integrant/annotations.edn`), and use their contents to
273
+ add annotations to namespaced keywords via [[annotate]]. This allows
274
+ annotations to be specified without needing to load every namespace.
275
+
276
+ The annoation resources should be edn files that map namespaced keywords
277
+ to maps of annotation metadata. For example:
278
+
279
+ {:example/keyword {:doc \" An example keyword.\" }}
280
+
281
+ This is equivalent to:
282
+
283
+ (annotate :example/keyword {:doc \" An example keyword.\" })"
284
+ ([] (load-annotations " integrant/annotations.edn" ))
285
+ ([path]
286
+ (doseq [url (resources path)]
287
+ (let [annotations (edn/read-string (slurp url))]
288
+ (doseq [[kw metadata] annotations]
289
+ (annotate kw metadata)))))))
290
+
269
291
(defn- missing-refs-exception [config refs]
270
292
(ex-info (str " Missing definitions for refs: " (str/join " , " refs))
271
293
{:reason ::missing-refs
Original file line number Diff line number Diff line change
1
+ {:integrant.core-test/a {:doc " A test keyword." }}
Original file line number Diff line number Diff line change 129
129
(underive :example/child :example/father )
130
130
(underive :example/child :example/mother )))))
131
131
132
+ #?(:clj
133
+ (deftest load-annotations-test
134
+ (try
135
+ (ig/load-annotations )
136
+ (is (= {:doc " A test keyword." } (ig/describe ::a )))
137
+ (finally
138
+ (ig/annotate ::a {})))))
139
+
132
140
#?(:clj
133
141
(deftest load-namespaces-test
134
142
(testing " all namespaces"
You can’t perform that action at this time.
0 commit comments