From 778e6a9c97ce54378d73824b1669c3ed5a772e96 Mon Sep 17 00:00:00 2001 From: Mikhail Kuzmin Date: Tue, 2 Jul 2024 21:40:27 +0400 Subject: [PATCH] add docstring for the ns-publics fn --- src/darkleaf/di/core.clj | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/darkleaf/di/core.clj b/src/darkleaf/di/core.clj index 9cfc0b6..6ef6ac5 100644 --- a/src/darkleaf/di/core.clj +++ b/src/darkleaf/di/core.clj @@ -694,7 +694,22 @@ (and (bound? var) (some? @var))) -(defn ns-publics [] +(defn ns-publics + "A registry middleware that interprets a whole namespace as a component. + A component will be a map of var names to corresponding components. + + The key of a component is a keyword with the namespace `:ns-publics` + and a name containing the name of a target ns. + For example `:ns-publics/io.gihub.my.ns`. + + This is useful for testing to access for all public components. + + See the test darkleaf.di.tutorial.x-ns-publics-test. + + ```clojure + (di/start :ns-publics/io.gihub.my.ns (di/ns-publics)) + ```" + [] (fn [registry] (fn [key] (if (and (qualified-keyword? key)