jupyter-book / mystmd

Command line tools for working with MyST Markdown.
https://mystmd.org/guide
MIT License
219 stars 65 forks source link

🪪 Allow custom licenses outside SPDX #1563

Closed fwkoch closed 1 month ago

fwkoch commented 1 month ago

Currently license values in MyST frontmatter are strict. They must be from the SPDX license list, referenced by ID, with no extra, custom information. This is probably how licenses should be used - just pick a good, existing one and stick with that, don't try to embellish it or make up your own. However, in reality, this is not the case. Publishers, authors, etc often have their own license notes, urls for their license policies, or entirely new licenses.

This PR updates license validation in MyST to enable more flexibility when defining license.

First, you may define a license as an SPDX ID, as before. The behavior for this is unchanged: it will be automatically expanded to contain all the relevant license metadata, including name, url, OSI status, etc:

license: CC-BY-4.0

And, as before, you may still separate content and code licenses - again, no changes to this.

license:
  content: CC-BY-4.0
  code: MIT

However, you may now add your own note - in this case, other metadata will still be populated as before, alongside your note:

license:
  id: CC-BY-4.0
  note: When attributing this content, please indicate the Source was MyST Documentation.

You may also override metadata fields - in this case, the new url will be used, but other metadata will be populated as before:

license:
  id: CC-BY-4.0
  url: https://example.com/licenses/how-our-journal-uses-cc-by

Finally, you may define your own totally new license:

license:
  id: im-not-a-lawyer
  name: I'm Not A Lawyer License
  url: https://example.com/licenses/these-wont-stand-up-in-court

Note, in cases all where you (1) do not use an SPDX license or (2) override default SPDX fields, MyST will raise a warning.

changeset-bot[bot] commented 1 month ago

🦋 Changeset detected

Latest commit: a5b68710c378c322a41d2556c21560b0f57255d6

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 7 packages | Name | Type | | ---------------- | ----- | | myst-to-md | Patch | | myst-cli | Patch | | myst-frontmatter | Patch | | myst-common | Patch | | myst-config | Patch | | myst-spec-ext | Patch | | mystmd | Patch |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

rowanc1 commented 1 month ago

Went through this with Franklin! Looking good, and opens up a lot more possibilities to support real-world use cases for capturing license information.