clj-kondo types for the functions of a source tree, read from the source without loading it:
(emit! {:src-dirs ["src"] :out ".clj-kondo/imports/defn-typed/types/config.edn"}), or from a shell
clojure -M -m defn-typed.kondo --src-dir src --out .clj-kondo/imports/defn-typed/types/config.edn.
Reading the source covers .cljs files, whose schemas exist only at run time in a browser, and
needs no loaded namespaces, so an after-edit hook can call emit! in any warm JVM.
clj-kondo types for the functions of a source tree, read from the source without loading it:
`(emit! {:src-dirs ["src"] :out ".clj-kondo/imports/defn-typed/types/config.edn"})`, or from a shell
`clojure -M -m defn-typed.kondo --src-dir src --out .clj-kondo/imports/defn-typed/types/config.edn`.
Reading the source covers .cljs files, whose schemas exist only at run time in a browser, and
needs no loaded namespaces, so an after-edit hook can call emit! in any warm JVM.(-main & args)CLI: emit! with the dirs and the out path of the args (cli-options); one line on stderr, stdout
stays empty. Exit 0 after OK <n> fns → <path>, 2 on bad args (with the --help text).
CLI: emit! with the dirs and the out path of the args (cli-options); one line on stderr, stdout stays empty. Exit 0 after `OK <n> fns → <path>`, 2 on bad args (with the --help text).
(cli-options args){:src-dirs [...] :out path} from the CLI's args, {:help true} for --help, {:error message}
for an unknown flag, a flag without its value, or no --src-dir / --out.
{:src-dirs [...] :out path} from the CLI's args, `{:help true}` for --help, `{:error message}`
for an unknown flag, a flag without its value, or no --src-dir / --out.(config-text entries)The clj-kondo config for entries ({:ns :name :schema} each, a later entry of the same ns and name replacing an earlier one), as fipp prints it at width 120, every map sorted by key-order: the same sources print the same text whatever order the maps were built in.
The clj-kondo config for entries ({:ns :name :schema} each, a later entry of the same ns and
name replacing an earlier one), as fipp prints it at width 120, every map sorted by key-order:
the same sources print the same text whatever order the maps were built in.The metadata edamame puts on every form it reads (:all true): never a table's own props.
The metadata edamame puts on every form it reads (`:all true`): never a table's own props.
(emit! {:keys [src-dirs out]})Writes the clj-kondo type config of every typed function under src-dirs to out:
each defn-typed / defnt form (its signature as the macro reads it, defn-typed.core/form-parts,
defaulted rows optional) and each plain defn / defn- carrying :malli/schema, read from the
source (function-entries) — a .cljs file through its :cljs reader branches, a .clj / .cljc file
through its :clj ones. In a schema, a symbol naming a top-level def of the same ns (or of the ns
it is :referred from) stands for that def's value, and [:fn …] for :any
(resolved-schema); metadata on a defn-typed input map becomes the map's props
(typed-form-schema). malli.clj-kondo turns the signatures into config; every map prints sorted
by key (config-text), so the same sources give the same text, and out is written only when
that text differs from the file's. malli's global function-schema registry is never touched,
so a REPL's own registrations stay as they are. Returns {:written? :fns :out}, :fns the number of
distinct functions typed. Writes a file, so no in/out cases.
Writes the clj-kondo type config of every typed function under src-dirs to out:
each defn-typed / defnt form (its signature as the macro reads it, defn-typed.core/form-parts,
defaulted rows optional) and each plain defn / defn- carrying `:malli/schema`, read from the
source (function-entries) — a .cljs file through its :cljs reader branches, a .clj / .cljc file
through its :clj ones. In a schema, a symbol naming a top-level def of the same ns (or of the ns
it is `:refer`red from) stands for that def's value, and `[:fn …]` for `:any`
(resolved-schema); metadata on a defn-typed input map becomes the map's props
(typed-form-schema). malli.clj-kondo turns the signatures into config; every map prints sorted
by key (config-text), so the same sources give the same text, and out is written only when
that text differs from the file's. malli's global function-schema registry is never touched,
so a REPL's own registrations stay as they are. Returns {:written? :fns :out}, :fns the number of
distinct functions typed. Writes a file, so no in/out cases.(function-entries src-dirs){:ns :name :schema :file} of every typed function under src-dirs, in file-seq order: each
.clj/.cljs/.cljc file mentioning :malli/schema or defn-typed, each top-level defn-typed /
defnt form (typed-form-schema) and each defn / defn- with a :malli/schema (plain-defn-schema),
its schema resolved (resolved-schema); a defn-typed input then marked by defaults-optional
again, which reaches the defaults a resolved symbol brought in, as the macro's
optional-if-defaulted does for a row typed by a symbol when it loads.
{:ns :name :schema :file} of every typed function under src-dirs, in file-seq order: each
.clj/.cljs/.cljc file mentioning `:malli/schema` or `defn-typed`, each top-level defn-typed /
defnt form (typed-form-schema) and each defn / defn- with a `:malli/schema` (plain-defn-schema),
its schema resolved (resolved-schema); a defn-typed input then marked by defaults-optional
again, which reaches the defaults a resolved symbol brought in, as the macro's
optional-if-defaulted does for a row typed by a symbol when it loads.(key-order a b)The order every map of the config prints in: numbers by value, then keywords, then symbols, then anything else, each kind by its printed text.
The order every map of the config prints in: numbers by value, then keywords, then symbols, then anything else, each kind by its printed text.
(plain-defn-schema form)The :malli/schema of a plain defn form's attr-map (any map before its arg vector), else nil.
The `:malli/schema` of a plain defn form's attr-map (any map before its arg vector), else nil.
(plain-defn? form)Whether form is a (defn …) / (defn- …) definition.
Whether form is a `(defn …)` / `(defn- …)` definition.
(read-source source)[ns-sym forms] of a source file: every top-level form, read as the compiler of its language
reads it — a .cljs file its :cljs reader-conditional branches, a .clj / .cljc file its :clj
ones; ::k resolves against the file's own ns, tagged literals read as their plain value.
[ns-sym forms] of a source file: every top-level form, read as the compiler of its language reads it — a .cljs file its `:cljs` reader-conditional branches, a .clj / .cljc file its `:clj` ones; `::k` resolves against the file's own ns, tagged literals read as their plain value.
(referred-namespaces parsed){ns-sym {sym home-ns}}: every symbol a ns form :refers by name ([home :refer [sym …]]).
`{ns-sym {sym home-ns}}`: every symbol a ns form `:refer`s by name (`[home :refer [sym …]]`).
(resolved-schema {:keys [defs refers ns-sym schema]})schema of ns-sym with every symbol naming a def of its own ns, else a def of the ns it is
:referred from, replaced by that def's value (resolved the same way, at any depth), and every
[:fn …] replaced by :any: a cljs predicate cannot run on the JVM, and clj-kondo types :fn
as :any anyway. Any other symbol stays (malli's predicate names: string?, pos-int? …).
schema of ns-sym with every symbol naming a def of its own ns, else a def of the ns it is `:refer`red from, replaced by that def's value (resolved the same way, at any depth), and every `[:fn …]` replaced by `:any`: a cljs predicate cannot run on the JVM, and clj-kondo types `:fn` as `:any` anyway. Any other symbol stays (malli's predicate names: `string?`, `pos-int?` …).
(schema-defs parsed){ns-sym {def-sym value}}: every top-level (def name … value) of the parsed files, a ns's
files (.clj and .cljs of one ns) merged.
`{ns-sym {def-sym value}}`: every top-level `(def name … value)` of the parsed files, a ns's
files (.clj and .cljs of one ns) merged.(typed-form-schema path form)The [:=> [:cat <input>] <output>] a defn-typed form gives its function, through the macro's
own reading of the form (defn-typed.core/form-parts). Metadata on the input map (^{:as row},
^{:closed true}, accepted by 0.3.1, a compile error since) does not stop it: the map is read
without it, and its keys become the [:map …]'s props, as 0.3.1 expanded them. Throws an
ex-info naming file and function when the form is not a defn-typed form.
The `[:=> [:cat <input>] <output>]` a defn-typed form gives its function, through the macro's
own reading of the form (defn-typed.core/form-parts). Metadata on the input map (`^{:as row}`,
`^{:closed true}`, accepted by 0.3.1, a compile error since) does not stop it: the map is read
without it, and its keys become the `[:map …]`'s props, as 0.3.1 expanded them. Throws an
ex-info naming file and function when the form is not a defn-typed form.(typed-form? form)Whether form is a (defn-typed …) / (defnt …) definition, referred or qualified.
Whether form is a `(defn-typed …)` / `(defnt …)` definition, referred or qualified.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |