Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(docs): Added a page on module creation #2456

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Nick-Munnich
Copy link
Contributor

@Nick-Munnich Nick-Munnich commented Sep 3, 2024

Added a page on module creation, much nicer this time.

This page makes use of another repository, zmk-module-template, which we should fork into the project if this approach is approved.

This page also makes reference to a second repository, zmk-modules. Work regarding zmk-modules is still in progress, but it is there to read and provide feedback on. If this is merged before zmk-modules is ready, then I suggest we comment out the parts on zmk-modules for the time being.

@Nick-Munnich Nick-Munnich requested a review from a team as a code owner September 3, 2024 11:38
@Nick-Munnich Nick-Munnich added the documentation Improvements or additions to documentation label Sep 3, 2024
@caksoylar caksoylar self-assigned this Sep 5, 2024
@Nick-Munnich Nick-Munnich requested a review from a team as a code owner September 8, 2024 12:08
@Nick-Munnich Nick-Munnich removed the request for review from a team September 9, 2024 12:20
Copy link
Contributor

@caksoylar caksoylar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is worth considering dropping the vfx category from the initial version, since it seems unclear to me how they'd be implemented right now (let me know if I am missing something).

Looks good to me as a document overall and I agree with the implementation guidelines in general. There are some of the more subjective statements which I didn't review, like the first sentence.

That being said, will this wait until some sort of ZMK versioning is in place?

docs/docs/development/module-creation.md Outdated Show resolved Hide resolved
docs/docs/development/module-creation.md Outdated Show resolved Hide resolved
docs/docs/development/module-creation.md Show resolved Hide resolved
docs/docs/development/module-creation.md Outdated Show resolved Hide resolved
docs/docs/development/module-creation.md Outdated Show resolved Hide resolved
docs/docs/development/module-creation.md Outdated Show resolved Hide resolved
docs/docs/development/module-creation.md Outdated Show resolved Hide resolved
docs/docs/development/module-creation.md Outdated Show resolved Hide resolved
docs/docs/development/module-creation.md Outdated Show resolved Hide resolved
docs/docs/development/module-creation.md Outdated Show resolved Hide resolved
Copy link
Contributor Author

@Nick-Munnich Nick-Munnich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some of the more subjective statements which I didn't review, like the first sentence.

Would be good to have a bit of discussion on those I think.

That being said, will this wait until some sort of ZMK versioning is in place?

The collection repo yes, but enough people seem to already be using the preview as a reference that I think it'd be worthwhile pushing through a trimmed down version of the page prior to versioning.

docs/docs/development/module-creation.md Outdated Show resolved Hide resolved
docs/docs/development/module-creation.md Outdated Show resolved Hide resolved
@urob
Copy link
Contributor

urob commented Nov 25, 2024

Something to ponder about: do you want to enforce a namespacing convention for headers? E.g., should modules be allowed to add new headers to /include/zmk, etc, or should everything be namespaced under /include/zmk-module-name? What about dts files?

For reference, zephyr does enforce namespacing of all headers:

Modules should expose all provided header files with an include pathname beginning with the module-name. (E.g., mcuboot should expose its bootutil/bootutil.h as “mcuboot/bootutil/bootutil.h”.)

@Nick-Munnich
Copy link
Contributor Author

Something to ponder about: do you want to enforce a namespacing convention for headers?

Good point, thanks for raising it. I'd be on the side of following the Zephyr convention, personally.

@Nick-Munnich Nick-Munnich force-pushed the module-creation branch 3 times, most recently from 68ea422 to aadf93c Compare February 3, 2025 19:48
Copy link
Contributor

@caksoylar caksoylar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is good overall, but I feel the reader will wonder how to write the contents of the files mentioned and what they do in general. To some degree it is normal, we can't explain how to develop any feature for ZMK here. Do you think there are any resources we can link to? e.g. we can cross-link between new shield and behavior guides, especially if we module-ify the latter like suggested in #2511. Maybe Zephyr has a nice page that I haven't ever found? 😆

It might also be good to drop a link to https://docs.zephyrproject.org/3.5.0/develop/modules.html near the beginning.

- Modules containing one or more keyboard-related definitions (boards, shields, interconnects, etc.)
- Modules containing behaviors & features
- Modules containing drivers
- Modules containing visual effects
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am still not a big fan of this classification, maybe we can say

Suggested change
- Modules containing visual effects
- Modules containing other features, such as visual effects


For each of these, you can use the singular or plural, i.e. `keyboard` and `keyboards` are both acceptable. Use your judgement to decide between the two.

`<description>` is your choice of name to describe the module. See the names of other modules of your chosen type in the `zmk-modules` repository for examples.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this repo will not be present if we merge this first, right?

name: <your module name>
```

#### Build Options
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#### Build Options
#### Build options

Re-cased according to our internal convention


- The `depends` child property is used to specify a list of modules which the module depends on. The dependencies are referred to by their [module name](#module-name).
- The `cmake` child property is used to identify a folder containing a `CMakeLists.txt` used to build the module.
- The `kconfig` child property is used to identify the `Kconfig` used to build the module.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- The `kconfig` child property is used to identify the `Kconfig` used to build the module.
- The `kconfig` child property is used to identify the `Kconfig` file that defines configuration settings used by the module.

Next, you need to define the options to build your module. These also go into `zephyr/module.yml`, as children of the `build` property. Commonly used options are:

- The `depends` child property is used to specify a list of modules which the module depends on. The dependencies are referred to by their [module name](#module-name).
- The `cmake` child property is used to identify a folder containing a `CMakeLists.txt` used to build the module.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- The `cmake` child property is used to identify a folder containing a `CMakeLists.txt` used to build the module.
- The `cmake` child property is used to identify a folder containing a `CMakeLists.txt` file that lists the CMake commands used to build source files.

- `settings` is a child property containing additional child properties, two of which are particularly relevant:
- `board_root` points to the parent directory of a `boards` directory, which contains additional board/shield definitions.
- `dts_root` points to the parent directory of a `dts` directory, which contains additional devicetree bindings.
- `snippet_root` points to the parent directory of a `snippets` directory, which contains [snippets](https://docs.zephyrproject.org/latest/build/snippets/index.html).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- `snippet_root` points to the parent directory of a `snippets` directory, which contains [snippets](https://docs.zephyrproject.org/latest/build/snippets/index.html).
- `snippet_root` points to the parent directory of a `snippets` directory, which contains [snippets](https://docs.zephyrproject.org/3.5.0/build/snippets/index.html).


### Informational Files

Make sure to include a `README.md` file and a `LICENSE` file in your repository. Only modules with MIT-compatible licenses can be added to `zmk-modules`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here also, do we want to remove this remark in the short term?


Note that the `include` and `src` folders are not mandated by the module system, and all of these can be positioned anywhere in your module's filetree if you adjust the `zephyr/module.yml` accordingly. The `west.yml` file is not commonly present in any of the types.

Modules should expose all provided header files with an include pathname beginning with the module-name.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Modules should expose all provided header files with an include pathname beginning with the module-name.
Modules should expose all provided header files with an include path name beginning with the module-name, for example at `include/zmk_<type>_<description>/<header>.h`.

Replaced hyphens with underscores to fit C conventions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants