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 include-or-later)

Extract all SPDX ids (as a set of strings) from the given parse result, optionally including the 'or later' indicator ('+') after license ids that have that designation in the parse tree (defaults to false).

Note: license 'families' that provide 'or-later' suffixed variants (i.e. *GPL licenses) will always end up with either the 'or-later' or the 'only' suffix version of an id, regardless of the value of the include-or-later flag. This is because the 'naked' variants of these license ids (e.g. 'GPL-2.0') are deprecated in the SPDX license list, and their use is discouraged. See https://github.com/spdx/license-list-XML/blob/main/DOCS/faq.md#what-does-it-mean-when-a-license-id-is-deprecated for more details.

Extract all SPDX ids (as a set of strings) from the given parse result,
optionally including the 'or later' indicator ('+') after license ids that
have that designation in the parse tree (defaults to false).

Note: license 'families' that provide 'or-later' suffixed variants (i.e.
*GPL licenses) will always end up with either the 'or-later' or the 'only'
suffix version of an id, regardless of the value of the include-or-later
flag.  This is because the 'naked' variants of these license ids (e.g.
'GPL-2.0') are deprecated in the SPDX license list, and their use is
discouraged. See https://github.com/spdx/license-list-XML/blob/main/DOCS/faq.md#what-does-it-mean-when-a-license-id-is-deprecated
for more details.
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)

'Normalises' an SPDX expression, by running it through parse then unparse.

'Normalises' an SPDX expression, by running it through parse then unparse.
sourceraw docstring

parseclj

(parse s)

Attempt to parse the given string as an SPDX license expression, returning a data structure representing the parse tree or nil if the string cannot be parsed.

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

Notes:

  • The parser normalises SPDX ids to their canonical case e.g. aPAcHe-2.0 -> Apache-2.0

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

  • When a license is modified with the "or later" modifier ('+'), the two are grouped

  • When a license is modified WITH a license exception, the two are grouped

Examples:

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

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

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

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

Attempt to parse the given string as an SPDX license expression, returning a
data structure representing the parse tree or nil if the string cannot be
parsed.

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

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

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

* When a license is modified with the "or later" modifier ('+'), the two
  are grouped

* When a license is modified WITH a license exception, the two are grouped

Examples:

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

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

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

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

parse-with-infoclj

(parse-with-info s)

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

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

As for parse, but returns 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 (successful) parse result back into a (normalised) SPDX expression string. Results are undefined for invalid parse trees.

Turns a (successful) parse result back into a (normalised) SPDX expression
string. Results are undefined for invalid parse trees.
sourceraw docstring

valid?clj

(valid? s)

Is the given string a valid SPDX license expression?

Note: if you intend to parse the given string if it's valid, it's more efficient to call parse directly and check for a nil result.

Is the given string a valid SPDX license expression?

Note: if you intend to parse the given string if it's valid, it's more
efficient to call parse directly and check for a nil result.
sourceraw docstring

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

× close