-
Notifications
You must be signed in to change notification settings - Fork 8.4k
doc: contribute: guidelines: Document KeepSorted and options #101197
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
Open
pdgendt
wants to merge
3
commits into
zephyrproject-rtos:main
Choose a base branch
from
pdgendt:keep-sorted-doc
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+96
−6
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -597,10 +597,10 @@ Running CI Tests Locally | |
| check_compliance.py | ||
| ------------------- | ||
|
|
||
| The ``check_compliance.py`` script serves as a valuable tool for assessing code | ||
| compliance with Zephyr's established guidelines and best practices. The script | ||
| acts as wrapper for a suite of tools that performs various checks, including | ||
| linters and formatters. | ||
| The :zephyr_file:`scripts/ci/check_compliance.py` script serves as a valuable | ||
| tool for assessing code compliance with Zephyr's established guidelines and | ||
| best practices. The script acts as wrapper for a suite of tools that performs | ||
| various checks, including linters and formatters. | ||
|
|
||
| Developers are encouraged to run the script locally to validate their changes | ||
| before opening a new Pull Request: | ||
|
|
@@ -616,6 +616,88 @@ before opening a new Pull Request: | |
| Set the default app to Strawberry Perl. By default the executable is | ||
| installed at ``C:\Strawberry\perl\bin\perl.exe``. | ||
|
|
||
| KeepSorted Check | ||
| ^^^^^^^^^^^^^^^^ | ||
|
|
||
| The KeepSorted check ensures that specified blocks of code, configuration, or | ||
| documentation remain in sorted order. | ||
|
|
||
| To use the KeepSorted check, wrap your sorted content between dedicated lines | ||
| containing start and stop markers, typically using comments: | ||
|
|
||
| .. code-block:: c | ||
|
|
||
| // zephyr-keep-sorted-start | ||
| option_a | ||
| option_b | ||
| option_c | ||
| // zephyr-keep-sorted-stop | ||
|
|
||
| KeepSorted Marker Options | ||
| """"""""""""""""""""""""" | ||
|
|
||
| The sorting behavior of each block can be customized in several ways. | ||
| To do this, one or more of the following parameters can be added on | ||
| the same line as the start marker itself: | ||
|
|
||
| **re(regex_pattern)** | ||
| Enables regex mode where only lines matching the specified regular expression | ||
| are checked for sorting. Other lines are ignored. | ||
|
|
||
| Example checking sorted properties in a yaml file: | ||
|
|
||
| .. code-block:: yaml | ||
|
|
||
| # zephyr-keep-sorted-start re(^\s+\- name:) | ||
| projects: | ||
| - name: application | ||
| revision: main | ||
| - name: library1 | ||
| revision: feature-branch | ||
| - name: library2 | ||
| revision: main | ||
| # zephyr-keep-sorted-stop | ||
|
|
||
| **strip(characters)** | ||
| Strips the specified characters from lines before performing the sort comparison. | ||
| This is useful when lines have optional prefixes or suffixes that should be | ||
| ignored during sorting. | ||
|
|
||
| Example stripping quotes from yaml dictionary keys: | ||
|
|
||
| .. code-block:: yaml | ||
|
|
||
| # zephyr-keep-sorted-start strip(":) | ||
| ACPI: | ||
| status: odd fixes | ||
| "West project: acpica": | ||
| status: odd fixes | ||
| # zephyr-keep-sorted-stop | ||
|
|
||
| **nofold** | ||
| Disables line folding. By default, indented lines following a main line are | ||
| concatenated (folded) together for sorting comparison. The ``nofold`` option | ||
| disables this behavior and ignores indented lines. | ||
|
|
||
| **ignorecase** | ||
| Enables case-insensitive sorting using Python's `str.casefold`_. This allows | ||
| mixing uppercase and lowercase items in sorted blocks without causing sort | ||
| order violations. Defaults to Python's string ordering if omitted. | ||
|
|
||
| .. _str.casefold: https://docs.python.org/3/library/stdtypes.html#str.casefold | ||
|
|
||
| Multiple options can be combined on the same marker line: | ||
|
|
||
| .. code-block:: rst | ||
|
|
||
| .. zephyr-keep-sorted-start re(^\* \w) ignorecase | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: the migration guide uses |
||
| * Shell | ||
| Some important message about the shell. | ||
|
|
||
| * STM32 | ||
| Updates for this vendor. | ||
| .. zephyr-keep-sorted-stop | ||
|
|
||
| twister | ||
| ------- | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.