Liking cljdoc? Tell your friends :D

spdx.expressions

SPDX license expression functionality. This functionality is bespoke (it is not provided by Spdx-Java-Library).

SPDX license expression functionality. This functionality is bespoke (it is
not provided by Spdx-Java-Library).
raw docstring

extract-idsclj

(extract-ids parse-result)
(extract-ids parse-result
             {:keys [include-or-later?] :or {include-or-later? false} :as opts})

Extract all SPDX ids (as a set of strings) from the given parse-result.

The optional opts map has these keys:

  • include-or-later? (boolean, default false) - controls whether the output includes the 'or later' indicator ('+') after license ids that have that designation in the parse tree.
Extract all SPDX ids (as a set of strings) from the given `parse-result`.

The optional `opts` map has these keys:
* include-or-later? (boolean, default false) - controls whether the output
  includes the 'or later' indicator ('+') after license ids that have that
  designation in the parse tree.
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.

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

normaliseclj

(normalise s)
(normalise s opts)

Normalises an SPDX expression, by running it through parse then unparse. Returns nil if s is nil or is not a valid SPDX expression.

opts are as for parse

Normalises an SPDX expression, by running it through parse then unparse.
Returns nil if `s` is nil or is not a valid SPDX expression.

`opts` are as for parse
sourceraw docstring

parseclj

(parse s)
(parse s opts)

Attempt to parse s (a String) as an SPDX license expression, returning a data structure representing the parse tree, or nil if it cannot be parsed.

The optional opts map has these keys:

  • normalise-gpl-ids? (boolean, default true) - controls whether deprecated 'historical oddity' GPL family ids in the expression are normalised to their non-deprecated replacements as part of the parsing process.

Notes:

Examples (assuming default options):

"Apache-2.0" -> {:license-id "Apache-2.0"}

"Apache-2.0+" -> {:license-id "Apache-2.0" :or-later? true}

"GPL-2.0+" -> {:license-id "GPL-2.0-or-later"}

"GPL-2.0 WITH Classpath-exception-2.0" -> {:license-id "GPL-2.0-only" :license-exception-id "Classpath-exception-2.0"}

"CDDL-1.1 OR (GPL-2.0+ WITH Classpath-exception-2.0)" -> [:or {:license-id "CDDL-1.1"} {:license-id "GPL-2.0-or-later" :license-exception-id "Classpath-exception-2.0"}]

See SPDX Specification Annex D for more details on SPDX license expressions: https://spdx.github.io/spdx-spec/v2.3/SPDX-license-expressions/

Attempt to parse `s` (a String) as an SPDX license expression, returning a
data structure representing the parse tree, or nil if it cannot be parsed.

The optional `opts` map has these keys:
* `normalise-gpl-ids?` (boolean, default true) - controls whether
  deprecated 'historical oddity' GPL family ids in the expression are
  normalised to their non-deprecated replacements as part of the parsing
  process.

Notes:
* The parser always normalises SPDX ids to their canonical case
  e.g. aPAcHe-2.0 -> Apache-2.0

* The parser always removes redundant grouping
  e.g. (((((Apache-2.0)))))) -> Apache-2.0

* The parser synthesises grouping when needed to make SPDX license
  expressions' precedence rules explicit (see
  https://spdx.github.io/spdx-spec/v2.3/SPDX-license-expressions/#d45-order-of-precedence-and-parentheses)

Examples (assuming default options):

"Apache-2.0"
-> {:license-id "Apache-2.0"}

"Apache-2.0+"
-> {:license-id "Apache-2.0" :or-later? true}

"GPL-2.0+"
-> {:license-id "GPL-2.0-or-later"}

"GPL-2.0 WITH Classpath-exception-2.0"
-> {:license-id "GPL-2.0-only"
    :license-exception-id "Classpath-exception-2.0"}

"CDDL-1.1 OR (GPL-2.0+ WITH Classpath-exception-2.0)"
-> [:or
    {:license-id "CDDL-1.1"}
    {:license-id "GPL-2.0-or-later"
     :license-exception-id "Classpath-exception-2.0"}]

See SPDX Specification Annex D for more details on SPDX license expressions:
https://spdx.github.io/spdx-spec/v2.3/SPDX-license-expressions/
sourceraw docstring

parse-with-infoclj

(parse-with-info s)
(parse-with-info s {:keys [normalise-gpl-ids?] :or {normalise-gpl-ids? true}})

As for parse, but returns an instaparse parse error info if parsing fails, instead of nil.

See also https://github.com/Engelberg/instaparse#parse-errors

As for parse, but returns an instaparse parse error info if parsing fails,
instead of nil.

See also https://github.com/Engelberg/instaparse#parse-errors
sourceraw docstring

unparseclj

(unparse parse-result)

Turns a valid parse-result back into an SPDX expression string. Results are undefined for invalid parse trees. Returns nil if parse-result is nil.

Turns a valid `parse-result` back into an SPDX expression string.  Results
are undefined for invalid parse trees.  Returns nil if `parse-result` is nil.
sourceraw docstring

valid?clj

(valid? s)

Is s (a String) a valid SPDX license expression?

Note: if you intend to parse s if it's valid, it's more efficient to call parse directly and check for a nil result instead of calling this method first (it avoids double parsing).

Is `s` (a String) a valid SPDX license expression?

Note: if you intend to parse `s` if it's valid, it's more efficient to call
parse directly and check for a nil result instead of calling this method
first (it avoids double parsing).
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close