Linux Documentation
 help / color / mirror / Atom feed
From: "Knop, Ryszard" <ryszard.knop@intel.com>
To: "mchehab+huawei@kernel.org" <mchehab+huawei@kernel.org>
Cc: "intel-xe@lists.freedesktop.org" <intel-xe@lists.freedesktop.org>,
	"Lin, Shuicheng" <shuicheng.lin@intel.com>,
	"linux-doc@vger.kernel.org" <linux-doc@vger.kernel.org>,
	"rdunlap@infradead.org" <rdunlap@infradead.org>,
	"jani.nikula@linux.intel.com" <jani.nikula@linux.intel.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] scripts/kernel-doc: Suggest possible names for excess descriptions
Date: Wed, 15 Jul 2026 13:21:27 +0000	[thread overview]
Message-ID: <80ccd6405e31b1200a391b2755780b7676597c74.camel@intel.com> (raw)
In-Reply-To: <20260715144243.60686000@localhost>

On Wed, 2026-07-15 at 14:42 +0200, Mauro Carvalho Chehab wrote:
> On Wed, 15 Jul 2026 13:17:26 +0200
> Ryszard Knop <ryszard.knop@intel.com> wrote:
> 
> > Since check_sections() now warns if a documentation tag member name is
> > the same as defined in the struct, we can suggest names the checker
> > knows, so that it's more obvious how to deal with the warning.
> > 
> > v2 (rdunlap):
> > - Strip whitespace from warnings, nicer when the hint is empty
> > 
> > Signed-off-by: Ryszard Knop <ryszard.knop@intel.com>
> > ---
> >  tools/lib/python/kdoc/kdoc_parser.py | 13 +++++++++++--
> >  1 file changed, 11 insertions(+), 2 deletions(-)
> > 
> > diff --git a/tools/lib/python/kdoc/kdoc_parser.py b/tools/lib/python/kdoc/kdoc_parser.py
> > index 2dedda215c22..a22c3e3182f0 100644
> > --- a/tools/lib/python/kdoc/kdoc_parser.py
> > +++ b/tools/lib/python/kdoc/kdoc_parser.py
> > @@ -558,6 +558,13 @@ class KernelDoc:
> >                          self.push_parameter(ln, decl_type, param, dtype,
> >                                              arg, declaration_name)
> >  
> > +    def get_suggestions_hint(self, decl_name, possible_names):
> > +        suggestions = set(name for name in possible_names if decl_name in name)
> > +        if not suggestions:
> > +            return ""
> > +
> > +        return f"(did you mean one of: '{"', '".join(suggestions)}')"
> > +
> 
> There is a better way to propose suggestions. See:
> 	Documentation/sphinx/kernel_include.py
> 
> E.g. use something like:
> 
> 	from difflib import get_close_matches
> 
> 	matches = get_close_matches(decl_name, possible_names)
> 
> See: https://docs.python.org/3/library/difflib.html#difflib.get_close_matches
> 
> If the problem is due to a typo, this will likely return the
> right name.

The checks here specifically were added to deal with situations like
[1] which boils down to:

struct {
    /** @flags: good description */
    int flags;

    /** @substruct: also good */
    struct {
        /** @mode: bad, wrong, no good */
        int mode;
    } substruct;
} big_block_o_data;

The docs should say "@substruct.mode" instead of just "@mode", so this
is distant enough from the actual input that difflib would not suggest
it. I could merge suggestions from both difflib and the plain substring
comparison if you'd like me to?

[1] https://patchwork.freedesktop.org/patch/734307/?series=168905&rev=1

> 
> Regards,
> Mauro

Thanks, Ryszard

  reply	other threads:[~2026-07-15 13:21 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-14 11:12 [PATCH] scripts/kernel-doc: Suggest possible names for excess descriptions Ryszard Knop
2026-07-14 21:44 ` Randy Dunlap
2026-07-15 11:18   ` Knop, Ryszard
2026-07-15 11:17 ` [PATCH v2] " Ryszard Knop
2026-07-15 12:42   ` Mauro Carvalho Chehab
2026-07-15 13:21     ` Knop, Ryszard [this message]
2026-07-15 13:52       ` Mauro Carvalho Chehab

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=80ccd6405e31b1200a391b2755780b7676597c74.camel@intel.com \
    --to=ryszard.knop@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=jani.nikula@linux.intel.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mchehab+huawei@kernel.org \
    --cc=rdunlap@infradead.org \
    --cc=shuicheng.lin@intel.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