Skip to content

Conversation

@pdgendt
Copy link
Contributor

@pdgendt pdgendt commented Dec 17, 2025

Add a documentation about the KeepSorted compliance check and which options it provides.

Depends on #101188

Allow making the zephyr-keep-sorted check ignore cases, for example:

// zephyr-keep-sorted-start ignorecase
....
// zephyr-keep-sorted-stop

Signed-off-by: Pieter De Gendt <[email protected]>
Use the directive to create an actual link to the check_compliance.py file.

Signed-off-by: Pieter De Gendt <[email protected]>
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 with marker comments:
Copy link
Contributor

Choose a reason for hiding this comment

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

Could be a bit more explicit about zephyr-keep-sorted-{start,stop} being the magic marker, and the "comment" just being needed so that the file remains valid.

Something like:

Suggested change
To use the KeepSorted check, wrap your sorted content with marker comments:
To use the KeepSorted check, wrap your sorted content between a dedicated line containing
start marker ``zephyr-keep-sorted-start`` and a dedicated line containing end marker
``zephyr-keep-sorted-end`` (usually, these marker lines will be comments):

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can't put these inline as they would be picked up by the compliance script 😆

Copy link
Contributor

@mathieuchopstm mathieuchopstm Dec 17, 2025

Choose a reason for hiding this comment

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

oh right 😭 - but maybe we can keep something like this without the actual markers then?

`casefold https://docs.python.org/3/library/stdtypes.html#str.casefold`_. This allows
mixing uppercase and lowercase items in sorted blocks without causing sort
order violations.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd provide a simple example with only one option:

Options are provided on the same line as the start marker. For example, the following
<ensures only lines matching regexp will be sorted>:

    zephyr-keep-sorted-start re(........)
    xxxx
    yyyy
    zephyr-keep-sorted-end

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The regex option has an example already?

Copy link
Contributor

Choose a reason for hiding this comment

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

I took regexp as an example but it could be anything. As you said, there are examples already, so this is a bit silly... but the current wording feels a bit rough:

The KeepSorted start marker supports several optional parameters to
customize the sorting behavior:

See new review comment for alternative proposal.

@pdgendt pdgendt force-pushed the keep-sorted-doc branch 2 times, most recently from f68a8af to 139951d Compare December 17, 2025 13:04
Comment on lines 639 to 640
The KeepSorted start marker supports several optional parameters to
customize the sorting behavior:
Copy link
Contributor

Choose a reason for hiding this comment

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

cont. of #101197 (comment)

Suggested change
The KeepSorted start marker supports several optional parameters to
customize the sorting behavior:
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:

Add a documentation section about the KeepSorted compliance check and
which options it provides.

Signed-off-by: Pieter De Gendt <[email protected]>
@sonarqubecloud
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants