Re: [PATCH 2/2] checkpatch: warn on known non-plural rust doc headers
From: Benno Lossin
Date: Mon Sep 09 2024 - 12:39:05 EST
On 09.09.24 18:31, Benno Lossin wrote:
> Hi,
>
> Thanks for the patch!
>
> On 06.09.24 20:05, Patrick Miller wrote:
>> Adds a check for documentation in rust file. Warns if certain known
>> documentation headers are not plural. Even though some sections may
>> be singular (i.e. only one example), the header should still be plural
>> so that more examples can be added later without needing to change the
>> header.
>>
>> Fixed the whitespace issue on my previous patch.
>
> This line shouldn't be part of the commit message, as it only makes
> sense if you know there existed a previous version. You can put a
> changelog underneath the `---` line, that part won't be put into the
> final commit message.
Also one more thing that I forgot, when sending a new version of a
patch, please mark it in the patch title with `[PATCH v2 2/2]` (you can
do it with `git format-patch -v2`).
Also don't immediately resend it, but wait for other people to also
provide feedback.
---
Cheers,
Benno
> I am not familiar with perl, but the regex looks good to me.
>
> ---
> Cheers,
> Benno
>
>> Signed-off-by: Patrick Miller <paddymills@xxxxxxxxx>
>> Suggested-by: Miguel Ojeda <ojeda@xxxxxxxxxx>
>> Link: https://github.com/Rust-for-Linux/linux/issues/1110
>>
>> ---
>> scripts/checkpatch.pl | 7 +++++++
>> 1 file changed, 7 insertions(+)
>>
>> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
>> index 39032224d504..cb5ecdb6df9b 100755
>> --- a/scripts/checkpatch.pl
>> +++ b/scripts/checkpatch.pl
>> @@ -3900,6 +3900,13 @@ sub process {
>> "Avoid using '.L' prefixed local symbol names for denoting a range of code via 'SYM_*_START/END' annotations; see Documentation/core-api/asm-annotations.rst\n" . $herecurr);
>> }
>>
>> +# check that document sec
>> tion headers are plural in rust files
>> + if ($realfile =~ /\.rs$/
>> + && $rawline =~ /^\+\s*\/\/\/\s+#+\s+(Example|Invariant|Guarantee|Panic)\s*$/) {
>> + WARN( "RUST_DOC_HEADER",
>> + "Rust doc headers should be plural\n" . $herecurr );
>> + }
>> +
>> # check we are in a valid source file C or perl if not then ignore this hunk
>> next if ($realfile !~ /\.(h|c|pl|dtsi|dts)$/);
>>
>> --
>> 2.46.0
>>
>
>