-
Notifications
You must be signed in to change notification settings - Fork 2
doc: Add API conventions and clarify breaking change criteria #310
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
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: kartben <[email protected]>
Co-authored-by: kartben <[email protected]>
Co-authored-by: kartben <[email protected]>
kartben
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should not be any formatting-only change in the pull request, it should only actually change stuff
There should be descriptions of changes considered breaking / non breaking, e.g renaming a Kconfig symbol, deleting a public function in a header, making a DeviceTree property required without a default, etc. it should be as exhaustive as possible
…examples Co-authored-by: kartben <[email protected]>
Done in commit 7feebed: Formatting-only changes removed:
Comprehensive breaking/non-breaking change examples added to C APIs:
Kconfig:
Devicetree:
Lifecycle impact: Private (no docs), Internal (must document), Public (must follow lifecycle) |
kartben
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make the description of breaking/non breaking changes more concise
Consider also a better way to present them
Co-authored-by: kartben <[email protected]>
Done in commit 5d78d68: More concise: Reduced from 235 to 187 lines (48 lines shorter, 20% reduction) Better presentation: Changed to RST table format with side-by-side comparison:
Removed questionable item: Inline/non-inline change (line 123) removed as it's not universally API-breaking |
kartben
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot maybe add a note that ABI compatibility is out of scope at the moment as it is assumed people recompile their code base
Co-authored-by: kartben <[email protected]>
Added in commit 9994c10. The note clarifies that the breaking/non-breaking changes section focuses on API source compatibility, and that ABI compatibility is out of scope since applications are expected to recompile when updating Zephyr versions. |
doc/develop/api/api_conventions.rst
Outdated
| | | ||
| | **Data types:** | ||
| | • Remove or rename struct/union/enum | ||
| | • Modify struct fields (remove, rename, reorder, change type) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot are all of these really api issues ? Some feel like abi
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! Removed "reorder" in commit 7557242. Reordering struct fields is an ABI concern (affects memory layout) but not an API issue - source code that accesses fields by name still compiles. The remaining items (remove, rename, change type) are true API breaking changes that prevent source compilation.
…API) Co-authored-by: kartben <[email protected]>
Plan: Add API Conventions Documentation ✅ COMPLETE
doc/develop/api/api_conventions.rstwith API classification contentdoc/develop/api/index.rstto include api_conventions.rstdoc/develop/api/design_guidelines.rst(only essential changes, no formatting)doc/glossary.rstwith "software component" definitionSummary of Changes
New API Conventions Documentation (
api_conventions.rst)192 lines (concise and well-organized)
API Classification:
Breaking and Non-Breaking Changes:
Changes from feedback:
Design Guidelines Updates (
design_guidelines.rst):c:struct:→:c:type:)Glossary Update (
glossary.rst)The documentation focuses exclusively on API source compatibility issues. ABI-only concerns (like struct field reordering or inline/non-inline changes) have been removed, consistent with the documented scope.
Original prompt
diff --git a/doc/develop/api/api_conventions.rst b/doc/develop/api/api_conventions.rst
new file mode 100644
index 0000000000000..a2cf4603b767a
--- /dev/null
+++ b/doc/develop/api/api_conventions.rst
@@ -0,0 +1,102 @@
+.. _api_conventions.rst:
+
+API Conventions
+###############
+
+Zephyr provides a few programming interfaces that users can use for creating their applications.
+Zephyr's API space includes the following areas:
+
+- C programming interface (function prototypes, structures, and macros), provided in C header files
+- Configuration system (Kconfig)
+- Hardware description system (Devicetree)
+
+Other areas, such as the build system (CMake), may also be seen as Zephyr's API. However, any area
+that is not explicitly listed herein is not considered Zephyr's API as of today.
+
+API classification
+******************
+The files that define the Zephyr APIs may contain symbols intended for different usage. The intended
+API usage is designated by the API class. Zephyr APIs are classified as:
+
+Private
software component. Private APIsapi_lifecycle. Therefore, they can be changed or+Internal
arch_are intended for use by the Zephyr kernel to invokeapi_lifecycle. Therefore, can be changed or removed at any time. However, changes to the+Public
software component. Public APIs may be used in-treeapi_lifecycle. Therefore, changes to an+Note, that only APIs defined in the main Zephyr tree are subject to :ref:
api_lifecycle. External projects+used as :ref:
modulesmay define their own rules for API lifecycle.+
+Zephyr is a constantly evolving project and API classification may change over time. A Private or
+Internal API may be promoted to Internal or Public API, respectively. Zephyr users are encouraged to
+follow :ref:
rfcsprocess to recommend changes in API classification.+
+The following sections provide guidelines on how to identify the class of an API depending on its
+type.
+
+Header files contents
+=====================
+Private
include/zephyr/private/. In addition, private symbols are prefixed withz_.z_are public.+Internal
include/zephyr/internal. In addition, Internal@internaldoxygen command.+Public
include/zephyr/.+In addition, the following prefixes are reserved by Zephyr kernel for use in Zephyr Public APIs:
+
+.. list-table:: Prefixes and Descriptions
atomic_device_irq_k_sys_+Kconfig symbols
+===============
+All Kconfig symbols are Public. The :ref:
api_lifecycleof a Kconfig symbol is defined by the+:ref:
api_lifecycleof a :term:software componentto which the binding belongs. For example,+Kconfig symbols defined for regulators follow the lifecycle of the :ref:
regulator_api.+
+Devicetree bindings
+===================
+Device tree bindings and their content are Public. The :ref:
api_lifecycleof a binding is defined+by the :ref:
api_lifecycleof a :term:software componentto which the binding belongs. For+example, bindings defined for regulators follow the lifecycle of the :ref:
regulator_api.diff --git a/doc/develop/api/design...
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.