From f92dce43e9c76bdba76359ec1f90e606cd609ee0 Mon Sep 17 00:00:00 2001 From: Nicolas Munnich <98408764+Nick-Munnich@users.noreply.github.com> Date: Thu, 25 Jul 2024 21:08:08 +0200 Subject: [PATCH] feat(docs): Add modules feature page (#2380) Co-authored-by: Cem Aksoylar --- docs/docs/config/index.md | 16 +- docs/docs/development/build-flash.mdx | 4 + docs/docs/development/new-shield.mdx | 7 + docs/docs/features/beta-testing.mdx | 100 ---------- docs/docs/features/modules.mdx | 194 +++++++++++++++++++ docs/sidebars.js | 260 ++++++++++++++------------ 6 files changed, 360 insertions(+), 221 deletions(-) delete mode 100644 docs/docs/features/beta-testing.mdx create mode 100644 docs/docs/features/modules.mdx diff --git a/docs/docs/config/index.md b/docs/docs/config/index.md index d542d435f1e..666cf4d9a68 100644 --- a/docs/docs/config/index.md +++ b/docs/docs/config/index.md @@ -28,12 +28,14 @@ When using a split keyboard, you can use a single file without the `_left` or `_ ### Board Folder -ZMK will search for config files in either of: +ZMK will search for config files in: - [`zmk/app/boards/arm/`](https://github.com/zmkfirmware/zmk/tree/main/app/boards/arm) -- `zmk-config/config/boards/arm/` +- `zmk-config/boards/arm/` +- `/boards/arm/` +- `zmk-config/config/boards/arm/` (For backwards compatibility only, do not use.) -...where `` is the name of the board. These files describe the hardware of the board. +...where `` is the name of the board and `` is the root directory of any [included module](../features/modules.mdx). These files describe the hardware of the board. ZMK will search the board folder for the following config files: @@ -48,12 +50,14 @@ For more documentation on creating and configuring a new board, see [Zephyr's bo ### Shield Folder -When building with a shield, ZMK will search for config files in either of: +When building with a shield, ZMK will search for config files in: - [`zmk/app/boards/shields/`](https://github.com/zmkfirmware/zmk/tree/main/app/boards/shields) -- `zmk-config/config/boards/shields/` +- `zmk-config/boards/shields/` +- `/boards/shields/` +- `zmk-config/config/boards/shields/` (For backwards compatibility only, do not use.) -...where `` is the name of the shield. These files describe the hardware of the shield that the board is plugged into. +...where `` is the name of the shield and `` is the root directory of any [included module](../features/modules.mdx). These files describe the hardware of the shield that the board is plugged into. ZMK will search the shield folder for the following config files: diff --git a/docs/docs/development/build-flash.mdx b/docs/docs/development/build-flash.mdx index 20e9e20a34c..cfcb39ee312 100644 --- a/docs/docs/development/build-flash.mdx +++ b/docs/docs/development/build-flash.mdx @@ -108,6 +108,10 @@ west build -b nice_nano -- -DSHIELD=kyria_left -DZMK_CONFIG="C:/Users/myUser/Doc The above command must still be invoked from the `zmk/app` directory as noted above, rather than the config directory. Otherwise, you will encounter errors such as `ERROR: source directory "." does not contain a CMakeLists.txt; is this really what you want to build?`. Alternatively you can add the `-s /path/to/zmk/app` flag to your `west` command. ::: +:::warning +If your config is also a [module](../features/modules.mdx), then you should also add the root (the folder in which the `zephyr` folder is found) of your `zmk-config` as an [external module to build with](#building-with-external-modules). +::: + In order to make your `zmk-config` folder available when building within the VSCode Remote Container, you need to create a docker volume named `zmk-config` by binding it to the full path of your config directory. If you have run the VSCode Remote Container before, it is likely that docker has created this volume automatically -- we need to delete the default volume before binding it to the correct path. Follow the following steps: diff --git a/docs/docs/development/new-shield.mdx b/docs/docs/development/new-shield.mdx index 60299abf92e..ae97f6afe75 100644 --- a/docs/docs/development/new-shield.mdx +++ b/docs/docs/development/new-shield.mdx @@ -51,6 +51,13 @@ Follow these steps to create your new repository: - Select Public or Private, depending on your preference. - Click the green "Create repository" button +The repository is a combination of the directories and files required of a ZMK config, and those required of a shield module. To create a shield module, the following components are needed: + +- The `boards/shields` directory, where the keyboard's files will go +- The `zephyr/module.yml` file, which identifies and describes the module. See the [Zephyr documentation](https://docs.zephyrproject.org/3.5.0/develop/modules.html#module-yaml-file-description) for details on customising this file. For the purposes of creating a shield module, the default found in the template can be left untouched. + +Neither of these should be moved out of their parent directory. The other files and directories such as `config` are not necessary for the purposes of a shield module, but rather intended to be used for user configuration and testing. + ## New Shield Directory :::note diff --git a/docs/docs/features/beta-testing.mdx b/docs/docs/features/beta-testing.mdx deleted file mode 100644 index 1a8d28633cb..00000000000 --- a/docs/docs/features/beta-testing.mdx +++ /dev/null @@ -1,100 +0,0 @@ ---- -title: Beta Testing -sidebar_label: Beta Testing ---- - -import Tabs from "@theme/Tabs"; -import TabItem from "@theme/TabItem"; - -You may find that ZMK does not support a feature or keyboard that you are interesting in using. You may find that someone -has already taken the time to submit the feature you need as a [Pull Request](https://github.com/zmkfirmware/zmk/pulls). If you find the feature you need as a pull request, -this page is for you! - -## Developer Repositories and Branches - -For a developer to submit a pull request to ZMK, they must first clone the original ZMK repository. After they have a copy -of the source code, they may create a feature branch to work within. When they have finished, they will publish the feature -branch and create the pull request. - -### Finding the Repository Page from the Pull Request - -![PR Repository](../assets/features/beta-testing/pr-repo-branch.png) - -### Finding the Repository URL - -![Repository URL](../assets/features/beta-testing/repo-url.png) - -### Finding the Repository Branch - -![Repository URL](../assets/features/beta-testing/repo-branch.png) - -## Testing Features - -Testing features will require you to modify the `west.yml` file. You will need to add a new remote for the pull request you -would like to test, and change the selected remote and revision (or branch) for the `zmk` project. - -### Examples - - - - -```yaml -manifest: - remotes: - - name: zmkfirmware - url-base: https://github.com/zmkfirmware - projects: - - name: zmk - remote: zmkfirmware - revision: main - import: app/west.yml - self: - path: config -``` - - - - -```yaml -manifest: - remotes: - - name: zmkfirmware - url-base: https://github.com/zmkfirmware - - name: okke-formsma - url-base: https://github.com/okke-formsma - projects: - - name: zmk - remote: okke-formsma - revision: macros - import: app/west.yml - self: - path: config -``` - - - - -```yaml -manifest: - remotes: - - name: zmkfirmware - url-base: https://github.com/zmkfirmware - - name: mcrosson - url-base: https://github.com/mcrosson - projects: - - name: zmk - remote: mcrosson - revision: feat-behavior-sleep - import: app/west.yml - self: - path: config -``` - - - diff --git a/docs/docs/features/modules.mdx b/docs/docs/features/modules.mdx new file mode 100644 index 00000000000..e25bc72aecc --- /dev/null +++ b/docs/docs/features/modules.mdx @@ -0,0 +1,194 @@ +--- +title: Modules +sidebar_label: Modules +--- + +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; + +ZMK makes use of [Zephyr modules](https://docs.zephyrproject.org/3.5.0/develop/modules.html) to include additional source code or configuration files into its build. You can think of them as similar to plugins or themes. The most common uses of this feature are: + +- Building firmware for a keyboard external to ZMK's tree +- Adding functionality to ZMK, such as a driver or a behavior + +A common ZMK setup thus consists of the following separate components, commonly housed in their respective Git repositories: + +- A single ZMK config maintained by the user, containing the `.conf` and `.keymap` files for one or multiple keyboards. This is also where files from ZMK or modules should be overridden/modified, if there is a need. +- Any number of ZMK modules, maintained by the module's owner. Some modules may contain multiple keyboards or functionalities. If all of your keyboards and functionalities are internal to ZMK's tree, then no modules are necessary. +- The ZMK firmware itself, maintained by its contributors. + +:::note +The shift to using modules for keyboards is a relatively recent one, and not all designs may be properly configured to be used as a module. If this is the case for your keyboard, then we would strongly suggest asking your vendor or designer to rectify this. +::: + +## Building With Modules + +### GitHub Actions + +When [using GitHub Actions to build ZMK](../user-setup.mdx), adding modules is as simple as modifying the `west.yml` found in your `zmk-config`'s `config` directory. The recommended way of doing so is: + +1. Find the URL base (the parent URL) for the module and add it as an entry to the [remotes](https://docs.zephyrproject.org/3.5.0/develop/west/manifest.html#remotes). +2. Add the module as an entry to the [projects](https://docs.zephyrproject.org/3.5.0/develop/west/manifest.html#projects). + Aside from the mandatory `name`, `remote`, and the commonly used `revision` properties, take note of the `import` property under `projects`. Some modules may have other modules as dependencies. This property allows the specifying of an additional west manifest file found in the tree of the module, which will automatically import all dependencies. + +For more information on `west.yml`, see [West Manifests](https://docs.zephyrproject.org/3.5.0/develop/west/manifest.html). + +#### Examples + + + + +```yaml +manifest: + remotes: + - name: zmkfirmware + url-base: https://github.com/zmkfirmware + projects: + - name: zmk + remote: zmkfirmware + revision: main + import: app/west.yml + self: + path: config +``` + + + + +```yaml +manifest: + remotes: + - name: zmkfirmware + url-base: https://github.com/zmkfirmware + - name: module_a_base + url-base: https://github.com/alice + projects: + - name: zmk + remote: zmkfirmware + revision: main + import: app/west.yml + - name: module_a + remote: module_a_base + revision: main + self: + path: config +``` + + + + +```yaml +manifest: + remotes: + - name: zmkfirmware + url-base: https://github.com/zmkfirmware + - name: module_a_base + url-base: https://github.com/alice + - name: module_b_base + url-base: https://github.com/bob + projects: + - name: zmk + remote: zmkfirmware + revision: main + import: app/west.yml + - name: module_a + remote: module_a_base + revision: main + - name: module_b + remote: module_b_base + revision: main + import: west.yml + self: + path: config +``` + + + + +### Building Locally + +To add a module to your build when building locally, you will need to clone/copy said module into your local file tree. You can then build using the module as described in [Building with External Modules](../development/build-flash.mdx#building-with-external-modules). + +## Beta Testing + +You may find that there are some features which you desire for which there is a [Pull Request](https://github.com/zmkfirmware/zmk/pulls), but no module. If this is the case, you can still make use of the feature. + +### Developer Repositories and Branches + +For a developer to submit a pull request to ZMK, they must first clone the original ZMK repository. After they have a copy +of the source code, they may create a feature branch to work within. When they have finished, they will publish the feature +branch and create the pull request. + +#### Finding the repository page from the Pull Request + +![PR Repository](../assets/features/beta-testing/pr-repo-branch.png) + +#### Finding the repository URL + +![Repository URL](../assets/features/beta-testing/repo-url.png) + +#### Finding the repository branch + +![Repository URL](../assets/features/beta-testing/repo-branch.png) + +## Testing Features + +### GitHub Actions + +When [using GitHub Actions to build ZMK](../user-setup.mdx), once you have obtained the correct URL, you'll need to modify the `west.yml` file similarly to [Building With Modules](#building-with-modules). Add the remote for the branch like in said section. The difference is that you will need to change the selected remote and revision (or branch) for the `zmk` project. + +#### Example + + + + +```yaml +manifest: + remotes: + - name: zmkfirmware + url-base: https://github.com/zmkfirmware + projects: + - name: zmk + remote: zmkfirmware + revision: main + import: app/west.yml + self: + path: config +``` + + + + +```yaml +manifest: + remotes: + - name: zmkfirmware + url-base: https://github.com/zmkfirmware + - name: forkedzmk + url-base: https://github.com/forkedzmk + projects: + - name: zmk + remote: forkedzmk + revision: specificpr + import: app/west.yml + self: + path: config +``` + + + + +### Building Locally + +When building from a pull request locally, you'll need to [perform the local user setup](../development/setup/index.md), but using the repository of the pull request rather than the official ZMK repository. You can then [build and flash](../development/build-flash.mdx) as usual. diff --git a/docs/sidebars.js b/docs/sidebars.js index e8c715c8c76..1233ccf1b42 100644 --- a/docs/sidebars.js +++ b/docs/sidebars.js @@ -1,120 +1,150 @@ module.exports = { - docs: { - "Getting Started": [ - "intro", - "hardware", - "faq", - "user-setup", - "customization", - { - type: "category", - label: "Troubleshooting", - link: { - type: "doc", - id: "troubleshooting/index", - }, - collapsed: true, - items: [ - "troubleshooting/building-issues", - "troubleshooting/flashing-issues", - "troubleshooting/connection-issues", - ], + docs: [ + { + type: "category", + label: "Getting Started", + link: { + type: "doc", + id: "intro", }, - ], - Features: [ - "features/keymaps", - "features/bluetooth", - "features/combos", - "features/conditional-layers", - "features/debouncing", - "features/displays", - "features/encoders", - "features/underglow", - "features/backlight", - "features/battery", - "features/soft-off", - "features/beta-testing", - ], - Behaviors: [ - "behaviors/index", - "behaviors/key-press", - "behaviors/layers", - "behaviors/misc", - "behaviors/hold-tap", - "behaviors/mod-tap", - "behaviors/mod-morph", - "behaviors/macros", - "behaviors/key-toggle", - "behaviors/sticky-key", - "behaviors/sticky-layer", - "behaviors/tap-dance", - "behaviors/caps-word", - "behaviors/key-repeat", - "behaviors/sensor-rotate", - "behaviors/mouse-emulation", - "behaviors/reset", - "behaviors/bluetooth", - "behaviors/outputs", - "behaviors/underglow", - "behaviors/backlight", - "behaviors/power", - "behaviors/soft-off", - ], - Codes: [ - "codes/index", - "codes/keyboard-keypad", - "codes/modifiers", - "codes/editing", - "codes/media", - "codes/applications", - "codes/input-assist", - "codes/power", - ], - Configuration: [ - "config/index", - "config/backlight", - "config/battery", - "config/behaviors", - "config/bluetooth", - "config/combos", - "config/displays", - "config/encoders", - "config/keymap", - "config/kscan", - "config/power", - "config/underglow", - "config/system", - ], - Development: [ - "development/clean-room", - "development/pre-commit", - "development/documentation", - { - type: "category", - label: "Setup", - collapsed: true, - items: [ - "development/setup/index", - "development/setup/docker", - "development/setup/native", - ], + collapsed: false, + items: [ + "hardware", + "faq", + "user-setup", + "customization", + { + type: "category", + label: "Troubleshooting", + link: { + type: "doc", + id: "troubleshooting/index", + }, + collapsed: true, + items: [ + "troubleshooting/building-issues", + "troubleshooting/flashing-issues", + "troubleshooting/connection-issues", + ], + }, + ], + }, + { + Features: [ + "features/keymaps", + "features/bluetooth", + "features/combos", + "features/conditional-layers", + "features/debouncing", + "features/displays", + "features/encoders", + "features/modules", + "features/underglow", + "features/backlight", + "features/battery", + "features/soft-off", + ], + }, + { + type: "category", + label: "Behaviors", + link: { + type: "doc", + id: "behaviors/index", }, - "development/build-flash", - "development/boards-shields-keymaps", - "development/posix-board", - "development/tests", - "development/usb-logging", - "development/ide-integration", - { - type: "category", - label: "Guides", - collapsed: false, - items: [ - "development/new-shield", - "development/hardware-metadata-files", - "development/new-behavior", - ], + collapsed: true, + items: [ + "behaviors/key-press", + "behaviors/layers", + "behaviors/misc", + "behaviors/hold-tap", + "behaviors/mod-tap", + "behaviors/mod-morph", + "behaviors/macros", + "behaviors/key-toggle", + "behaviors/sticky-key", + "behaviors/sticky-layer", + "behaviors/tap-dance", + "behaviors/caps-word", + "behaviors/key-repeat", + "behaviors/sensor-rotate", + "behaviors/mouse-emulation", + "behaviors/reset", + "behaviors/bluetooth", + "behaviors/outputs", + "behaviors/underglow", + "behaviors/backlight", + "behaviors/power", + "behaviors/soft-off", + ], + }, + { + Codes: [ + "codes/index", + "codes/keyboard-keypad", + "codes/modifiers", + "codes/editing", + "codes/media", + "codes/applications", + "codes/input-assist", + "codes/power", + ], + }, + { + type: "category", + label: "Configuration", + link: { + type: "doc", + id: "config/index", }, - ], - }, + collapsed: true, + items: [ + "config/backlight", + "config/battery", + "config/behaviors", + "config/bluetooth", + "config/combos", + "config/displays", + "config/encoders", + "config/keymap", + "config/kscan", + "config/power", + "config/underglow", + "config/system", + ], + }, + { + Development: [ + "development/clean-room", + "development/pre-commit", + "development/documentation", + { + type: "category", + label: "Setup", + collapsed: true, + items: [ + "development/setup/index", + "development/setup/docker", + "development/setup/native", + ], + }, + "development/build-flash", + "development/boards-shields-keymaps", + "development/posix-board", + "development/tests", + "development/usb-logging", + "development/ide-integration", + { + type: "category", + label: "Guides", + collapsed: false, + items: [ + "development/new-shield", + "development/hardware-metadata-files", + "development/new-behavior", + ], + }, + ], + }, + ], };