Skip to content

Commit

Permalink
feat: convert namespace filters supplied as strings to regexes
Browse files Browse the repository at this point in the history
tools.deps users can't include a regex literal in deps.edn files. If we get a string as a namespace
filter, convert it to a regular expression.
  • Loading branch information
crimeminister committed Aug 14, 2024
1 parent 38f7e31 commit b4d2bfc
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions codox/src/codox/main.clj
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,15 @@
(symbol? pattern) (= pattern (symbol ns-name))))

(defn- filter-namespaces [namespaces ns-filters]
(if (and ns-filters (not= ns-filters :all))
(filter #(some (partial ns-matches? %) ns-filters) namespaces)
namespaces))
;; tools.deps users can't include a regex literal in deps.edn files. If we get a string as a
;; namespace filter, convert it to a regular expression.
(let [ns-filters (mapv (fn [ns-filter] (if (string? ns-filter)
(re-pattern ns-filter)
ns-filter))
ns-filters)]
(if (and ns-filters (not= ns-filters :all))
(filter #(some (partial ns-matches? %) ns-filters) namespaces)
namespaces)))

(defn- read-namespaces
[{:keys [language root-path source-paths namespaces metadata exclude-vars] :as opts}]
Expand Down

0 comments on commit b4d2bfc

Please sign in to comment.