Liking cljdoc? Tell your friends :D

dunnage.sitoa.schema-namespaces

Emit an XSD-derived malli registry as Clojure source instead of one EDN file.

Every registry type becomes a .cljc namespace holding plain data defs, and a single entry namespace requires them all, assembles the registry and the top type, and exposes make-schema. Registry values are pure data, so per-type files need no :require at all and a cyclic XSD type graph can never produce cyclic namespace requires: every cross-type edge stays a keyword that malli's registry resolves at m/schema time.

The EDN path (serialize-registry / serialize-schema) is untouched; this namespace is purely additive.

Emit an XSD-derived malli registry as Clojure source instead of one EDN file.

Every registry type becomes a .cljc namespace holding plain data defs, and a
single entry namespace requires them all, assembles the registry and the top
type, and exposes make-schema. Registry values are pure data, so per-type
files need no :require at all and a cyclic XSD type graph can never produce
cyclic namespace requires: every cross-type edge stays a keyword that malli's
registry resolves at m/schema time.

The EDN path (serialize-registry / serialize-schema) is untouched; this
namespace is purely additive.
raw docstring

canonicalize-formclj

(canonicalize-form form)

Put a form in the shape the generator emits: attribute rows sorted, empty property maps dropped. Attributes are sorted first, while :map forms still carry their properties at index 1.

Put a form in the shape the generator emits: attribute rows sorted, empty
property maps dropped. Attributes are sorted first, while :map forms still
carry their properties at index 1.
sourceraw docstring

canonicalize-registryclj

(canonicalize-registry registry)

canonicalize-form over every registry value.

canonicalize-form over every registry value.
sourceraw docstring

emit-namespaces!clj

(emit-namespaces! {:keys [out-dir entry-ns top-types]} registry top-type)

Write one .cljc file per registry type plus an entry namespace under out-dir.

registry and top-type are the raw data structures produced by xsd->registry / xsd->top-type; the generator never re-walks XSOM.

Options: :out-dir directory the source tree is written under (required) :entry-ns symbol naming the aggregator namespace (required) :top-types optional collection of registry keys used as reachability seeds, mirroring furl's trim-registry-for-top-types call. Only the reachable closure of own entries is required and registered by the entry namespace (the builtin xmlschema-registry is always merged whole; its unreachable entries are inert); unreachable types still get their own file. With seeds the entry's registry may not cover every top-type arm, so callers pick a start type with the 1-arity make-schema.

Files are overwritten but never deleted, so a type dropped from the XSD leaves its previous file behind; regenerate into a clean directory.

Returns {:files [...] :entry-ns sym :entry-file path :included #{kws}}.

Write one .cljc file per registry type plus an entry namespace under out-dir.

`registry` and `top-type` are the raw data structures produced by
xsd->registry / xsd->top-type; the generator never re-walks XSOM.

Options:
  :out-dir   directory the source tree is written under (required)
  :entry-ns  symbol naming the aggregator namespace (required)
  :top-types optional collection of registry keys used as reachability seeds,
             mirroring furl's trim-registry-for-top-types call. Only the
             reachable closure of own entries is required and registered by
             the entry namespace (the builtin xmlschema-registry is always
             merged whole; its unreachable entries are inert); unreachable
             types still get their own file. With seeds the entry's registry
             may not cover every top-type arm, so callers pick a start type
             with the 1-arity make-schema.

Files are overwritten but never deleted, so a type dropped from the XSD
leaves its previous file behind; regenerate into a clean directory.

Returns {:files [...] :entry-ns sym :entry-file path :included #{kws}}.
sourceraw docstring

ensure-on-classpath!clj

(ensure-on-classpath! dir)

Add dir to the classpath so require can find files just written there.

The URL is registered both on the outermost DynamicClassLoader of the current load (so a require in the same form sees it) and on the thread context class loader (so later forms do too).

Add `dir` to the classpath so require can find files just written there.

The URL is registered both on the outermost DynamicClassLoader of the current
load (so a require in the same form sees it) and on the thread context class
loader (so later forms do too).
sourceraw docstring

form-refsclj

(form-refs registry-keys form)

Sorted set of registry keywords referenced anywhere in form.

The pipeline emits references in two shapes: [:ref :ns/Foo] from -seq-ref via wrap-ref-np, and bare namespaced keywords from base-type chains and from XSD builtin references that wrap-ref-np deliberately leaves unwrapped. Both count.

Sorted set of registry keywords referenced anywhere in `form`.

The pipeline emits references in two shapes: [:ref :ns/Foo] from -seq-ref via
wrap-ref-np, and bare namespaced keywords from base-type chains and from XSD
builtin references that wrap-ref-np deliberately leaves unwrapped. Both count.
sourceraw docstring

kw->ns-symclj

(kw->ns-sym k)

Namespace symbol for a registry keyword. A dot inside the local name would create a bogus extra namespace segment, so it is munged to an underscore; dashes stay, following Clojure convention.

Namespace symbol for a registry keyword. A dot inside the local name would
create a bogus extra namespace segment, so it is munged to an underscore;
dashes stay, following Clojure convention.
sourceraw docstring

ns-sym->pathclj

(ns-sym->path ns-sym)

Clojure's own source path rule: dashes to underscores, dots to separators.

Clojure's own source path rule: dashes to underscores, dots to separators.
sourceraw docstring

reachable-keysclj

(reachable-keys registry seeds)

Transitive closure of registry keys reachable from seeds, computed on the raw registry data. Mirrors trim-registry-for-top-types, which walks compiled schemas for the same edges.

Transitive closure of registry keys reachable from `seeds`, computed on the
raw registry data. Mirrors trim-registry-for-top-types, which walks compiled
schemas for the same edges.
sourceraw docstring

xsd->namespaces!clj

(xsd->namespaces! {:keys [default-ns] :as opts} f)

parse-xsd + xsd->registry + xsd->top-type + emit-namespaces!.

Options are emit-namespaces! options plus :default-ns, the namespace applied to declarations without a targetNamespace.

parse-xsd + xsd->registry + xsd->top-type + emit-namespaces!.

Options are emit-namespaces! options plus :default-ns, the namespace applied
to declarations without a targetNamespace.
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