Liking cljdoc? Tell your friends :D

meme.registry

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.
raw docstring

available-langsclj

(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).
sourceraw docstring

builtin-langsclj

(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.
sourceraw docstring

check-supportclj

(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.
sourceraw docstring

clear-user-langs!clj

(clear-user-langs!)

Clear all registered user languages, preserving built-ins. For testing.

Clear all registered user languages, preserving built-ins. For testing.
sourceraw docstring

default-langclj

The default lang used when none is specified.

The default lang used when none is specified.
sourceraw docstring

load-ednclj

(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.
sourceraw docstring

register!clj

(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.
sourceraw docstring

registered-extensionsclj

(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.
sourceraw docstring

registered-langsclj

(registered-langs)

List all registered user language names (excludes built-ins).

List all registered user language names (excludes built-ins).
sourceraw docstring

resolve-by-extensionclj

(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.
sourceraw docstring

resolve-langclj

(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.
sourceraw docstring

supports?clj

(supports? lang command)

Does the lang support the given command?

Does the lang support the given command?
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close