From da166d4d8b1eb5cf984a08effdf20faaca2b3234 Mon Sep 17 00:00:00 2001 From: Pascal Getreuer <50221757+getreuer@users.noreply.github.com> Date: Mon, 31 Mar 2025 22:06:42 -0700 Subject: [PATCH] Add "license" field to Community Module JSON schema. (#25085) Add "license" field to community module schema. --- data/schemas/community_module.jsonschema | 1 + docs/features/community_modules.md | 5 +++++ lib/python/qmk/json_encoders.py | 8 +++++--- modules/qmk/hello_world/qmk_module.json | 1 + modules/qmk/super_alt_tab/qmk_module.json | 1 + 5 files changed, 13 insertions(+), 3 deletions(-) diff --git a/data/schemas/community_module.jsonschema b/data/schemas/community_module.jsonschema index a3474476dff..a237e210ce6 100644 --- a/data/schemas/community_module.jsonschema +++ b/data/schemas/community_module.jsonschema @@ -7,6 +7,7 @@ "properties": { "module_name": {"$ref": "qmk.definitions.v1#/text_identifier"}, "maintainer": {"$ref": "qmk.definitions.v1#/text_identifier"}, + "license": {"type": "string"}, "url": { "type": "string", "format": "uri" diff --git a/docs/features/community_modules.md b/docs/features/community_modules.md index a28c5afaeb1..52526c9fe82 100644 --- a/docs/features/community_modules.md +++ b/docs/features/community_modules.md @@ -72,6 +72,7 @@ A Community Module is denoted by a `qmk_module.json` file such as the following: { "module_name": "Hello World", "maintainer": "QMK Maintainers", + "license": "GPL-2.0-or-later", "features": { "deferred_exec": true }, @@ -86,6 +87,10 @@ A Community Module is denoted by a `qmk_module.json` file such as the following: At minimum, the module must provide the `module_name` and `maintainer` fields. +The `license` field is encouraged to indicate the terms for using and sharing the module. It is recommended to use a [SPDX license identifier](https://spdx.org/licenses/) like "`Apache-2.0`" or "`GPL-2.0-or-later`" if possible. + +The `url` field may specify a URL to more information about the module. + The use of `features` matches the definition normally provided within `keyboard.json` and `info.json`, allowing a module to signal to the build system that it has its own dependencies. In the example above, it enables the _deferred executor_ feature whenever the above module is used in a build. The `keycodes` array allows a module to provide new keycodes (as well as corresponding aliases) to a keymap. diff --git a/lib/python/qmk/json_encoders.py b/lib/python/qmk/json_encoders.py index e83a381d520..e8bcf48996e 100755 --- a/lib/python/qmk/json_encoders.py +++ b/lib/python/qmk/json_encoders.py @@ -250,12 +250,14 @@ class CommunityModuleJSONEncoder(QMKJSONEncoder): return '00module_name' if key == 'maintainer': return '01maintainer' + if key == 'license': + return '02license' if key == 'url': - return '02url' + return '03url' if key == 'features': - return '03features' + return '04features' if key == 'keycodes': - return '04keycodes' + return '05keycodes' elif self.indentation_level == 3: # keycodes if key == 'key': return '00key' diff --git a/modules/qmk/hello_world/qmk_module.json b/modules/qmk/hello_world/qmk_module.json index fd855a6e237..bbd00f3fcc3 100644 --- a/modules/qmk/hello_world/qmk_module.json +++ b/modules/qmk/hello_world/qmk_module.json @@ -1,6 +1,7 @@ { "module_name": "Hello World", "maintainer": "QMK Maintainers", + "license": "GPL-2.0-or-later", "features": { "console": true, "deferred_exec": true diff --git a/modules/qmk/super_alt_tab/qmk_module.json b/modules/qmk/super_alt_tab/qmk_module.json index 002f7fb69e3..142613a23e1 100644 --- a/modules/qmk/super_alt_tab/qmk_module.json +++ b/modules/qmk/super_alt_tab/qmk_module.json @@ -1,6 +1,7 @@ { "module_name": "Super Alt Tab", "maintainer": "QMK Maintainers", + "license": "GPL-2.0-or-later", "keycodes": [ { "key": "COMMUNITY_MODULE_SUPER_ALT_TAB",