[PATCH 2/2] checkpatch: warn on known non-plural rust doc headers

From: Patrick Miller
Date: Fri Sep 06 2024 - 12:46:06 EST


Adds a check for documentation in rust file. Warns if certain known
documentation headers are not plural.

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 | 8 ++++++++
1 file changed, 8 insertions(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 39032224d504..0e99d11eeb04 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3900,6 +3900,14 @@ 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 section headers are plural in rust files
+ if ( $realfile =~ /\.rs$/
+ && $rawline =~ /^\+\s*\/\/\/\s+#+\s+(Example|Invariant)\s*$/ )
+ {
+ WARN( "RUST_DOC_HEADER",
+ "Rust doc he
aders 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

Attachment: publickey - paddymills@proton.me - 0xDCA74891.asc
Description: application/pgp-keys

Attachment: signature.asc
Description: OpenPGP digital signature