Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: convert namespace filters supplied as strings to regexes #224

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion codox/src/codox/main.clj
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,16 @@

(defn- filter-namespaces [namespaces ns-filters]
(if (and ns-filters (not= ns-filters :all))
(filter #(some (partial ns-matches? %) ns-filters) namespaces)
;; tools.deps users can't include a regex literal in deps.edn files. Plain strings used as
;; namespace filters are matched against using = already, so we need to distinguish strings
;; meant to be regex patterns somehow. If a filter string begins with #re: convert it to a
;; regular expression.
(let [ns-filters (mapv (fn [ns-filter] (if (and (string? ns-filter)
(str/starts-with? ns-filter "#re:"))
(re-pattern (subs ns-filter 3))
ns-filter))
ns-filters)]
(filter #(some (partial ns-matches? %) ns-filters) namespaces))
namespaces))

(defn- read-namespaces
Expand Down