Liking cljdoc? Tell your friends :D

spdx.regexes

Regex related functionality. This functionality is bespoke (it does not use any logic from Spdx-Java-Library).

Regex related functionality.  This functionality is bespoke (it does not use
any logic from `Spdx-Java-Library`).
raw docstring

addition-ref-reclj

(addition-ref-re)

Returns a regex (Pattern) that can find or match any SPDX AdditionRef.

Specifics of the regex are as for build-re.

Notes:

  • Caches the generated Pattern object and returns it on subsequent calls, so is efficient when called many times
Returns a regex (`Pattern`) that can find or match any SPDX AdditionRef.

Specifics of the regex are as for [[build-re]].

Notes:

* Caches the generated `Pattern` object and returns it on subsequent calls, so
  is efficient when called many times
sourceraw docstring

build-reclj

(build-re ids)
(build-re ids
          {:keys [include-license-refs? include-addition-refs?]
           :or {include-license-refs? false include-addition-refs? false}})

Returns a regex (Pattern) that can find or match any one of the given SPDX ids (a sequence of Strings) in a source text. Returns nil if ids is nil or empty.

The regex includes these named capturing groups:

  • Identifier (always present) - captures the entire identifier, LicenseRef or AdditionRef
  • DocumentRef (optional) - captures the DocumentRef variable text of a LicenseRef, if that's what's matched and it contains one
  • LicenseRef (optional) - captures the LicenseRef variable text of a LicenseRef, if that's what's matched
  • AdditionDocumentRef (optional) - captures the DocumentRef variable text of an AdditionRef, if that's what's matched and it contains one
  • AdditionRef (optional) - captures the AdditionRef variable text of an AdditionRef, if that's what's matched

Groups should not be accessed by index, as the groups in the returned regexes are not part of the public contract of this API, and are liable to change over time. You may choose to use something like rencg (a library that clj-spdx has a dependency upon, so is already available to your code) to ensure your code is future proof in this regard.

ids will appear in the regex sorted from longest to shortest, so that more specific values are preferentially found or matched first - this avoids mismatches when one id is a subset of another id (e.g. GPL-2.0-or-later and GPL-2.0).

opts are:

  • include-license-refs? (boolean, default false) - controls whether LicenseRef support is also included in the regex
  • include-addition-refs? (boolean, default false) - controls whether AdditionRef support is also included in the regex
Returns a regex (`Pattern`) that can find or match any one of the given SPDX
`ids` (a sequence of `String`s) in a source text. Returns `nil` if `ids` is
`nil` or empty.

The regex includes these named capturing groups:

* `Identifier` (always present) - captures the entire identifier, LicenseRef
  or AdditionRef
* `DocumentRef` (optional) - captures the `DocumentRef` variable text of a
  LicenseRef, if that's what's matched and it contains one
* LicenseRef (optional) - captures the LicenseRef variable text of a
  LicenseRef, if that's what's matched
* `AdditionDocumentRef` (optional) - captures the `DocumentRef` variable text
  of an AdditionRef, if that's what's matched and it contains one
* AdditionRef (optional) - captures the AdditionRef variable text of an
  AdditionRef, if that's what's matched

Groups should _not_ be accessed by index, as the groups in the returned
regexes are not part of the public contract of this API, and are liable to
change over time.  You may choose to use something like
[rencg](https://github.com/pmonks/rencg) (a library that clj-spdx has a
dependency upon, so is already available to your code) to ensure your code is
future proof in this regard.

`ids` will appear in the regex sorted from longest to shortest, so that more
specific values are preferentially found or matched first - this avoids
mismatches when one id is a subset of another id (e.g. `GPL-2.0-or-later` and
`GPL-2.0`).

`opts` are:

* `include-license-refs?` (`boolean`, default `false`) - controls whether
  LicenseRef support is also included in the regex
* `include-addition-refs?` (`boolean`, default `false`) - controls whether
  AdditionRef support is also included in the regex
sourceraw docstring

exception-ids-reclj

(exception-ids-re)

Returns a regex (Pattern) that can find or match any SPDX license exception identifier, or AdditionRef in a source text.

Specifics of the regex are as for build-re.

Notes:

  • Caches the generated Pattern object and returns it on subsequent calls, so is efficient when called many times
Returns a regex (`Pattern`) that can find or match any SPDX license exception
identifier, or AdditionRef in a source text.

Specifics of the regex are as for [[build-re]].

Notes:

* Caches the generated `Pattern` object and returns it on subsequent calls, so
  is efficient when called many times
sourceraw docstring

id-seqclj

(id-seq text)
(id-seq re text)

Returns a lazy sequence of the canonicalised forms of all identifiers found in text, in the order in which they were found, or nil if no matches were found. re must be a regex returned by one of the fns in this namespace, and defaults to ids-re if not provided.

If you need more information about where in the text the identifiers were found, or the original text that matched an identifier, use id-seq-matches instead.

Returns a lazy sequence of the canonicalised forms of all identifiers found
in `text`, in the order in which they were found, or `nil` if no matches were
found. `re` must be a regex returned by one of the fns in this namespace, and
defaults to [[ids-re]] if not provided.

If you need more information about where in the text the identifiers were
found, or the original text that matched an identifier, use [[id-seq-matches]]
instead.
sourceraw docstring

id-seq-matchesclj

(id-seq-matches text)
(id-seq-matches re text)

Returns a lazy sequence of maps representing each of the identifier matches found in text, in the order in which they were found, or nil if no matches were found. re must be a regex returned by one of the fns in this namespace, and defaults to ids-re if not provided.

Each map in the result may contain these keys:

  • :identifier (always present) - the canonical represention of the listed identifier, LicenseRef or AdditionRef that matched
  • :type (always present) - identifier type, as per spdx.identifiers/id-type
  • :license-ref (optional) - the LicenseRef's tag value, if it's a LicenseRef
  • :document-ref (optional) - the LicenseRef's DocumentRef tag value, if it's a LicenseRef and it has a DocumentRef
  • :addition-ref (optional) - the AdditionRef's tag value, if it's an AdditionRef
  • :addition-document-ref (optional) - the AdditionRef's DocumentRef tag value, if it's an AdditionRef and it has a DocumentRef
Returns a lazy sequence of maps representing each of the identifier matches
found in `text`, in the order in which they were found, or `nil` if no matches
were found. `re` must be a regex returned by one of the fns in this namespace,
and defaults to [[ids-re]] if not provided.

Each map in the result may contain these keys:

* `:identifier` (always present) - the canonical represention of the listed
  identifier, LicenseRef or AdditionRef that matched
* `:type` (always present) - identifier type, as per [[spdx.identifiers/id-type]]
* `:license-ref` (optional) - the LicenseRef's tag value, if it's a LicenseRef
* `:document-ref` (optional) - the LicenseRef's DocumentRef tag value, if it's
  a LicenseRef and it has a DocumentRef
* `:addition-ref` (optional) - the AdditionRef's tag value, if it's an
  AdditionRef
* `:addition-document-ref` (optional) - the AdditionRef's DocumentRef tag
  value, if it's an AdditionRef and it has a DocumentRef
sourceraw docstring

ids-reclj

(ids-re)

Returns a regex (Pattern) that can find or match any SPDX license identifier, SPDX exception identifier, LicenseRef, or AdditionRef in a source text.

Specifics of the regex are as for build-re.

Notes:

  • Caches the generated Pattern object and returns it on subsequent calls, so is efficient when called many times
Returns a regex (`Pattern`) that can find or match any SPDX license
identifier, SPDX exception identifier, LicenseRef, or AdditionRef in
a source text.

Specifics of the regex are as for [[build-re]].

Notes:

* Caches the generated `Pattern` object and returns it on subsequent calls, so
  is efficient when called many times
sourceraw docstring

init!clj

(init!)

Initialises this namespace upon first call (and does nothing on subsequent calls), returning nil. Consumers of this namespace are not required to call this fn, as initialisation will occur implicitly anyway; it is provided to allow explicit control of the cost of initialisation to callers who need it.

Note: this function may have a substantial performance cost.

Initialises this namespace upon first call (and does nothing on subsequent
calls), returning `nil`. Consumers of this namespace are not required to call
this fn, as initialisation will occur implicitly anyway; it is provided to
allow explicit control of the cost of initialisation to callers who need it.

Note: this function may have a substantial performance cost.
sourceraw docstring

license-ids-reclj

(license-ids-re)

Returns a regex (Pattern) that can find or match any SPDX license identifier, or LicenseRef in a source text.

Specifics of the regex are as for build-re.

Notes:

  • Caches the generated Pattern object and returns it on subsequent calls, so is efficient when called many times
Returns a regex (`Pattern`) that can find or match any SPDX license
identifier, or LicenseRef in a source text.

Specifics of the regex are as for [[build-re]].

Notes:

* Caches the generated `Pattern` object and returns it on subsequent calls, so
  is efficient when called many times
sourceraw docstring

license-ref-reclj

(license-ref-re)

Returns a regex (Pattern) that can find or match any SPDX LicenseRef.

Specifics of the regex are as for build-re.

Notes:

  • Caches the generated Pattern object and returns it on subsequent calls, so is efficient when called many times
Returns a regex (`Pattern`) that can find or match any SPDX LicenseRef.

Specifics of the regex are as for [[build-re]].

Notes:

* Caches the generated `Pattern` object and returns it on subsequent calls, so
  is efficient when called many times
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