Lang registry: registration, resolution, and EDN loading. JVM/Babashka only.
A lang is a map of command functions: :run (fn [source opts] → result) — run a file :repl (fn [opts] → nil) — interactive loop :format (fn [source opts] → text) — format a file :to-clj (fn [source] → clj-text) — convert meme→clj :to-meme (fn [source] → meme-text) — convert clj→meme
Plus optional metadata: :extension ".ext" — file extension (string or vector) :extensions [".ext" ".e"] — file extensions (string or vector) Both forms are accepted and normalized to :extensions [...].
Every key is optional. A lang supports exactly the commands it has keys for.
Built-in langs are self-describing: each defines a lang-map in its own namespace. User langs can be registered via register! with EDN-style config maps.
Lang registry: registration, resolution, and EDN loading. JVM/Babashka only. A lang is a map of command functions: :run (fn [source opts] → result) — run a file :repl (fn [opts] → nil) — interactive loop :format (fn [source opts] → text) — format a file :to-clj (fn [source] → clj-text) — convert meme→clj :to-meme (fn [source] → meme-text) — convert clj→meme Plus optional metadata: :extension ".ext" — file extension (string or vector) :extensions [".ext" ".e"] — file extensions (string or vector) Both forms are accepted and normalized to :extensions [...]. Every key is optional. A lang supports exactly the commands it has keys for. Built-in langs are self-describing: each defines a lang-map in its own namespace. User langs can be registered via register! with EDN-style config maps.
(available-langs)Return a set of all available lang names (built-in + user-registered).
Return a set of all available lang names (built-in + user-registered).
(builtin-langs)Return a map of {lang-name lang-map} for all built-in langs.
Return a map of {lang-name lang-map} for all built-in langs.
(check-support lang lang-name command)Assert that the lang supports the given command. Throws if not.
Assert that the lang supports the given command. Throws if not.
(clear-user-langs!)Clear all registered user languages, preserving built-ins. For testing.
Clear all registered user languages, preserving built-ins. For testing.
The default lang used when none is specified.
The default lang used when none is specified.
(load-edn path)Load a lang from an EDN file. Returns a lang map with functions. H5 WARNING: this function executes code. Symbols in the EDN are resolved via requiring-resolve (loads namespaces from classpath). String values for :run are slurp'd and eval'd. Only use with trusted EDN files.
Load a lang from an EDN file. Returns a lang map with functions. H5 WARNING: this function executes code. Symbols in the EDN are resolved via requiring-resolve (loads namespaces from classpath). String values for :run are slurp'd and eval'd. Only use with trusted EDN files.
(register! lang-name config)Register a user lang at runtime. config is an EDN-style map — symbols are resolved via requiring-resolve, strings and keywords follow the same rules as load-edn. Pre-resolved functions are passed through. Rejects attempts to override built-in langs. Conflict checks are atomic — performed inside swap! to prevent TOCTOU races.
Register a user lang at runtime. config is an EDN-style map — symbols are resolved via requiring-resolve, strings and keywords follow the same rules as load-edn. Pre-resolved functions are passed through. Rejects attempts to override built-in langs. Conflict checks are atomic — performed inside swap! to prevent TOCTOU races.
(registered-extensions)Return a seq of [dot-extension run-fn] for all langs with :extensions and :run. Used by the generic loader to search the classpath for lang source files.
Return a seq of [dot-extension run-fn] for all langs with :extensions and :run. Used by the generic loader to search the classpath for lang source files.
(registered-langs)List all registered user language names (excludes built-ins).
List all registered user language names (excludes built-ins).
(resolve-by-extension path)Given a file path, find the lang whose :extensions match. Returns [lang-name lang-map] or nil.
Given a file path, find the lang whose :extensions match. Returns [lang-name lang-map] or nil.
(resolve-lang lang-name)Resolve a lang by keyword name. Returns the lang map. Deprecated name (:classic) is accepted but emits a warning. Throws on unknown name.
Resolve a lang by keyword name. Returns the lang map. Deprecated name (:classic) is accepted but emits a warning. Throws on unknown name.
(supports? lang command)Does the lang support the given command?
Does the lang support the given command?
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 |