rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/2] checkpatch: warn on known non-plural rust doc headers
@ 2024-09-06 18:05 Patrick Miller
  2024-09-07 10:53 ` Joe Perches
  2024-09-09 16:31 ` Benno Lossin
  0 siblings, 2 replies; 12+ messages in thread
From: Patrick Miller @ 2024-09-06 18:05 UTC (permalink / raw)
  To: a.hindborg, alex.gaynor, aliceryhl, apw, benno.lossin, bjorn3_gh,
	boqun.feng, dwaipayanray1, gary, joe, linux-kernel, lukas.bulwahn,
	ojeda, rust-for-linux, tmgross, wedsonaf
  Cc: Patrick Miller


[-- Attachment #1.1: Type: text/plain, Size: 1363 bytes --]

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.

Signed-off-by: Patrick Miller <paddymills@proton.me>
Suggested-by: Miguel Ojeda <ojeda@kernel.org>
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


[-- Attachment #1.2: publickey - paddymills@proton.me - 0xDCA74891.asc --]
[-- Type: application/pgp-keys, Size: 705 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 249 bytes --]

^ permalink raw reply related	[flat|nested] 12+ messages in thread
* [PATCH 2/2] checkpatch: warn on known non-plural rust doc headers
@ 2024-09-06 16:45 Patrick Miller
  2024-09-06 17:00 ` Greg KH
  0 siblings, 1 reply; 12+ messages in thread
From: Patrick Miller @ 2024-09-06 16:45 UTC (permalink / raw)
  To: a.hindborg, alex.gaynor, aliceryhl, apw, benno.lossin, bjorn3_gh,
	boqun.feng, dwaipayanray1, gary, joe, linux-kernel, lukas.bulwahn,
	ojeda, rust-for-linux, tmgross, wedsonaf
  Cc: Patrick Miller


[-- Attachment #1.1: Type: text/plain, Size: 1173 bytes --]

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

Signed-off-by: Patrick Miller <paddymills@proton.me>
Suggested-by: Miguel Ojeda <ojeda@kernel.org>
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 #1.2: publickey - paddymills@proton.me - 0xDCA74891.asc --]
[-- Type: application/pgp-keys, Size: 705 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 249 bytes --]

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2024-09-09 16:38 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-06 18:05 [PATCH 2/2] checkpatch: warn on known non-plural rust doc headers Patrick Miller
2024-09-07 10:53 ` Joe Perches
2024-09-07 11:57   ` Patrick Miller
2024-09-07 14:22     ` Patrick Miller
2024-09-07 15:33       ` Joe Perches
2024-09-09 16:24   ` Benno Lossin
2024-09-09 16:31 ` Benno Lossin
2024-09-09 16:38   ` Benno Lossin
  -- strict thread matches above, loose matches on Subject: below --
2024-09-06 16:45 Patrick Miller
2024-09-06 17:00 ` Greg KH
2024-09-06 17:29   ` Patrick Miller
2024-09-06 17:56     ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).