rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Patrick Miller <paddymills@proton.me>
To: a.hindborg@samsung.com, alex.gaynor@gmail.com,
	aliceryhl@google.com, apw@canonical.com, benno.lossin@proton.me,
	bjorn3_gh@protonmail.com, boqun.feng@gmail.com,
	dwaipayanray1@gmail.com, gary@garyguo.net, joe@perches.com,
	linux-kernel@vger.kernel.org, lukas.bulwahn@gmail.com,
	ojeda@kernel.org, rust-for-linux@vger.kernel.org,
	tmgross@umich.edu, wedsonaf@gmail.com
Cc: Patrick Miller <paddymills@proton.me>
Subject: [PATCH v3 2/2] checkpatch: warn on known non-plural rust doc headers
Date: Thu, 12 Sep 2024 19:56:57 +0000	[thread overview]
Message-ID: <20240912195649.227878-1-paddymills@proton.me> (raw)

[-- Attachment #1: Type: text/plain, Size: 1819 bytes --]

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

The rust maintainers prefer document headers to be plural. This is to enforce
consistency among the documentation as well as to protect against errors when
additions are made. For example, if the header said "Example" because there was
only 1 example, if a second example was added, making the header plural could
easily be missed and the maintainers prefer to not have to remind people to fix
their documentation.

Link: https://github.com/Rust-for-Linux/linux/issues/1110

v1: https://lore.kernel.org/rust-for-linux/2024090628-bankable-refusal-5f20@gregkh/T/#t
v2: https://lore.kernel.org/rust-for-linux/92be0b48-cde9-4241-8ef9-7fe4d7c42466@proton.me/T/#t
  - fixed whitespace that was formatted due to editor settings 
v3:
  - move && to previous line and remove whitespace in WARN per Joe Perches
  - reformat following C coding style
---
 scripts/checkpatch.pl | 7 ++++
+++
 1 file changed, 7 insertions(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 39032224d504..5b18246ad511 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 section 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 #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 249 bytes --]

             reply	other threads:[~2024-09-12 19:57 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-12 19:56 Patrick Miller [this message]
2024-09-13  7:33 ` [PATCH v3 2/2] checkpatch: warn on known non-plural rust doc headers Alice Ryhl
2024-09-13 19:21   ` Joe Perches
2024-09-13 19:34     ` Benno Lossin
2024-09-13 11:30 ` Benno Lossin
2024-09-14 18:16 ` [PATCH v4 " Patrick Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240912195649.227878-1-paddymills@proton.me \
    --to=paddymills@proton.me \
    --cc=a.hindborg@samsung.com \
    --cc=alex.gaynor@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=apw@canonical.com \
    --cc=benno.lossin@proton.me \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=dwaipayanray1@gmail.com \
    --cc=gary@garyguo.net \
    --cc=joe@perches.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lukas.bulwahn@gmail.com \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=tmgross@umich.edu \
    --cc=wedsonaf@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).