Liking cljdoc? Tell your friends :D

mranderson.util

Filesystem, class-file and jarjar helpers shared across the pipeline.

Two concerns live here: locating and normalizing Clojure source dirs and files, and the Java side of inlining - finding bundled .class files and relocating their packages via jarjar under a name+version prefix (distinct from the namespace :project-prefix).

Filesystem, class-file and jarjar helpers shared across the pipeline.

Two concerns live here: locating and normalizing Clojure source dirs and
files, and the Java side of inlining - finding bundled `.class` files and
relocating their packages via jarjar under a name+version prefix (distinct from
the namespace `:project-prefix`).
raw docstring

apply-jarjar!clj

(apply-jarjar! pname pversion srcdeps jar-file)

Repackages the bundled Java .class files in jar-file in place. Relocates every package root found under srcdeps (see java-class-dirs) beneath the name+version prefix derived from pname/pversion, via jarjar.

Repackages the bundled Java `.class` files in `jar-file` in place. Relocates
every package root found under `srcdeps` (see `java-class-dirs`) beneath the
name+version prefix derived from `pname`/`pversion`, via jarjar.
sourceraw docstring

assert-no-duplicate-filesclj

(assert-no-duplicate-files files)

Throw internal error if there are any duplicates in files.

Throw internal error if there are any duplicates in `files`.
sourceraw docstring

class-file->fully-qualified-nameclj

(class-file->fully-qualified-name srcdeps file)

Returns the fully-qualified (dotted) class name for a .class file, derived from its path relative to srcdeps with the extension dropped.

Returns the fully-qualified (dotted) class name for a `.class` `file`, derived
from its path relative to `srcdeps` with the extension dropped.
sourceraw docstring

class-filesclj

(class-files srcdeps)

Returns a vector of all .class files found under the subdirectories of srcdeps (files directly in the root are ignored).

Returns a vector of all `.class` files found under the subdirectories of
`srcdeps` (files directly in the root are ignored).
sourceraw docstring

clean-name-versionclj

(clean-name-version pname pversion)

Builds an identifier-safe prefix out of pname and pversion.

Strips every non-alphanumeric character so that names or versions containing characters like / (e.g. a version of "n/a") don't leak into the generated package/namespace prefix and break imports.

Builds an identifier-safe prefix out of `pname` and `pversion`.

Strips every non-alphanumeric character so that names or versions
containing characters like `/` (e.g. a version of "n/a") don't leak
into the generated package/namespace prefix and break imports.
sourceraw docstring

clj-files->dirsclj

(clj-files->dirs prefix clj-files)

Returns the set of distinct directories holding clj-files, each prefixed with prefix (as prefix/dir).

Returns the set of distinct directories holding `clj-files`, each prefixed with
`prefix` (as `prefix/dir`).
sourceraw docstring

clojure-source-filesclj

(clojure-source-files dirs)

Like clojure-source-files-relative, but returns each file canonicalized.

Like `clojure-source-files-relative`, but returns each file canonicalized.
sourceraw docstring

clojure-source-files-relativeclj

(clojure-source-files-relative dirs)
(clojure-source-files-relative dirs excl-dir)

Returns all .clj/.cljc/.cljs files under dirs as a vector of File, left as-is (not canonicalized). When excl-dir is given, any file under <dir>/<excl-dir> for each of dirs is excluded.

Returns all .clj/.cljc/.cljs files under `dirs` as a vector of File, left
as-is (not canonicalized). When `excl-dir` is given, any file under
`<dir>/<excl-dir>` for each of `dirs` is excluded.
sourceraw docstring

determine-source-dirsclj

(determine-source-dirs {:keys [source-paths]
                        {:keys [included-source-paths]} :mranderson})

Returns the project source dirs to inline, per the [:mranderson :included-source-paths] option: nil/:first means just the first source path, :source-paths means all of them, or an explicit vector of paths is used as-is.

Returns the project source dirs to inline, per the
`[:mranderson :included-source-paths]` option: `nil`/`:first` means just the
first source path, `:source-paths` means all of them, or an explicit vector of
paths is used as-is.
sourceraw docstring

duplicated-filesclj

(duplicated-files files)

Returns map of duplicates in files, key is fully qualified file as string, value is num occurrences. If no duplicates, empty map is returned.

Returns map of duplicates in `files`, key is fully qualified file as string, value is num occurrences.
If no duplicates, empty map is returned.
sourceraw docstring

extension->platformclj

(extension->platform extension-of-moved)

Returns the platform keyword for a single-platform extension: :clj for ".clj", :cljs for ".cljs". Returns nil for .cljc or anything else.

Returns the platform keyword for a single-platform extension: `:clj` for
".clj", `:cljs` for ".cljs". Returns nil for `.cljc` or anything else.
sourceraw docstring

file->extensionclj

(file->extension file)

Returns the Clojure source extension of file (".clj", ".cljc" or ".cljs"), or nil if it has none. Doubles as an is-this-a-source-file? predicate.

Returns the Clojure source extension of `file` (".clj", ".cljc" or
".cljs"), or nil if it has none. Doubles as an is-this-a-source-file?
predicate.
sourceraw docstring

first-src-pathclj

(first-src-path root source-paths)

Returns the first of source-paths relative to project root (the leading root prefix and its trailing separator are stripped).

Returns the first of `source-paths` relative to project `root` (the leading
`root` prefix and its trailing separator are stripped).
sourceraw docstring

java-class-dirsclj

(java-class-dirs srcdeps)

Returns the set of top-level package roots (the first path segment under srcdeps) that contain bundled .class files. These are the roots jarjar relocates under the name+version prefix.

Returns the set of top-level package roots (the first path segment under
`srcdeps`) that contain bundled `.class` files. These are the roots jarjar
relocates under the name+version prefix.
sourceraw docstring

normalize-dirsclj

(normalize-dirs dirs)

Returns dirs (as strings) normalized, deduped and without subdirs

Returns `dirs` (as strings) normalized, deduped and without subdirs
sourceraw docstring

platform-compclj

(platform-comp platform)

Returns the complementary platform keyword (:clj <-> :cljs), or nil when platform is nil.

Returns the complementary platform keyword (`:clj` <-> `:cljs`), or nil when
`platform` is nil.
sourceraw docstring

source-dep?clj

(source-dep? dependency)

True if dependency is marked for inlining, i.e. its metadata carries :source-dep or :inline-dep.

True if `dependency` is marked for inlining, i.e. its metadata carries
`:source-dep` or `:inline-dep`.
sourceraw docstring

srcdeps-relativeclj

(srcdeps-relative srcdeps file)

Returns the path of file relative to the srcdeps root, using forward slashes. file is expected to live under srcdeps, as everything produced by walking the srcdeps tree does.

Returns the path of `file` relative to the `srcdeps` root, using forward
slashes. `file` is expected to live under `srcdeps`, as everything produced by
walking the srcdeps tree does.
sourceraw docstring

sym->file-nameclj

(sym->file-name sym)

Converts a namespace symbol to its relative file path (no extension), munging dashes to underscores and dots to the platform file separator.

Converts a namespace symbol to its relative file path (no extension), munging
dashes to underscores and dots to the platform file separator.
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