linux-doc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
To: Hans Verkuil <hverkuil+cisco@kernel.org>
Cc: Jonathan Corbet <corbet@lwn.net>,
	Linux Doc Mailing List <linux-doc@vger.kernel.org>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	linux-kernel@vger.kernel.org, linux-media@vger.kernel.org
Subject: Re: [PATCH 02/23] tools: docs: parse_data_structs.py: output a line number
Date: Mon, 20 Oct 2025 08:56:43 -0300	[thread overview]
Message-ID: <20251020085643.14007a29@sal.lan> (raw)
In-Reply-To: <1507fe55-d756-46bb-abf1-0d1fb7f9bee0@kernel.org>

Em Mon, 20 Oct 2025 12:46:50 +0200
Hans Verkuil <hverkuil+cisco@kernel.org> escreveu:

> On 01/10/2025 16:49, Mauro Carvalho Chehab wrote:
> 
> Missing commit message!

Weird, I'm almost sure I filled some description.

> 
> I'm less concerned about the missing message (it's clear what is happening here),
> than I am about the fact that checkpatch wasn't run.

My mailbomb script does run checkpatch for each patch, but I probably
missed the warnings(*).

(*) By the time I sent this series, I was playing with a new version
    written in Python. It had several issues, however, mostly because I
    was unable to find a way for Python to read an e-mail formatted with
    git format-patch without mangling with content encoding. I got problems
    on translations, with binary file patches and even with \n at the code.

    On my original script, written in 2015, it was easy to lose checkpatch 
    messages in the crowd on big series. I did several improvements on
    it, like running checkpatch in parallel and re-ordering warnings to
    avoid losing them, but it was done only after sending this series.

In any case, checkpatch currently doesn't have any logic for Python
or ReST files. It only reports patch descriptions issues like this.
IMO what it is needed for checkpatch to be more useful for tools is:

1. to define a coding style for Python;
2. to add some code at checkpatch to handle Python as well.

> 
> Regards,
> 
> 	Hans
> 
> > Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
> > ---
> >  tools/docs/lib/parse_data_structs.py | 29 ++++++++++++++--------------
> >  1 file changed, 15 insertions(+), 14 deletions(-)
> > 
> > diff --git a/tools/docs/lib/parse_data_structs.py b/tools/docs/lib/parse_data_structs.py
> > index 6c868f84f029..d28471a045f1 100755
> > --- a/tools/docs/lib/parse_data_structs.py
> > +++ b/tools/docs/lib/parse_data_structs.py
> > @@ -143,7 +143,7 @@ class ParseDataStructs:
> >          for symbol_type in self.DEF_SYMBOL_TYPES:
> >              self.symbols[symbol_type] = {}
> >  
> > -    def store_type(self, symbol_type: str, symbol: str,
> > +    def store_type(self, ln, symbol_type: str, symbol: str,
> >                     ref_name: str = None, replace_underscores: bool = True):
> >          """
> >          Stores a new symbol at self.symbols under symbol_type.
> > @@ -172,7 +172,7 @@ class ParseDataStructs:
> >          else:
> >              ref_link = symbol
> >  
> > -        self.symbols[symbol_type][symbol] = f"{prefix}{ref_link}{suffix}"
> > +        self.symbols[symbol_type][symbol] = (f"{prefix}{ref_link}{suffix}", ln)
> >  
> >      def store_line(self, line):
> >          """Stores a line at self.data, properly indented"""
> > @@ -240,20 +240,20 @@ class ParseDataStructs:
> >                  if is_enum:
> >                      match = re.match(r"^\s*([_\w][\w\d_]+)\s*[\,=]?", line)
> >                      if match:
> > -                        self.store_type("symbol", match.group(1))
> > +                        self.store_type(line_no, "symbol", match.group(1))
> >                      if "}" in line:
> >                          is_enum = False
> >                      continue
> >  
> >                  match = re.match(r"^\s*#\s*define\s+([\w_]+)\s+_IO", line)
> >                  if match:
> > -                    self.store_type("ioctl", match.group(1),
> > +                    self.store_type(line_no, "ioctl", match.group(1),
> >                                      replace_underscores=False)
> >                      continue
> >  
> >                  match = re.match(r"^\s*#\s*define\s+([\w_]+)(\s+|$)", line)
> >                  if match:
> > -                    self.store_type("define", match.group(1))
> > +                    self.store_type(line_no, "define", match.group(1))
> >                      continue
> >  
> >                  match = re.match(r"^\s*typedef\s+([_\w][\w\d_]+)\s+(.*)\s+([_\w][\w\d_]+);",
> > @@ -261,20 +261,20 @@ class ParseDataStructs:
> >                  if match:
> >                      name = match.group(2).strip()
> >                      symbol = match.group(3)
> > -                    self.store_type("typedef", symbol, ref_name=name)
> > +                    self.store_type(line_no, "typedef", symbol, ref_name=name)
> >                      continue
> >  
> >                  for re_enum in self.RE_ENUMS:
> >                      match = re_enum.match(line)
> >                      if match:
> > -                        self.store_type("enum", match.group(1))
> > +                        self.store_type(line_no, "enum", match.group(1))
> >                          is_enum = True
> >                          break
> >  
> >                  for re_struct in self.RE_STRUCTS:
> >                      match = re_struct.match(line)
> >                      if match:
> > -                        self.store_type("struct", match.group(1))
> > +                        self.store_type(line_no, "struct", match.group(1))
> >                          break
> >  
> >      def process_exceptions(self, fname: str):
> > @@ -342,7 +342,8 @@ class ParseDataStructs:
> >  
> >                  # Change self.symbols to use the replacement rule
> >                  if old in self.symbols[c_type]:
> > -                    self.symbols[c_type][old] = new_ref
> > +                    (_, ln) = self.symbols[c_type][old]
> > +                    self.symbols[c_type][old] = (new_ref, ln)
> >                  else:
> >                      print(f"{name}:{ln}: Warning: can't find {old} {c_type}")
> >  
> > @@ -360,8 +361,8 @@ class ParseDataStructs:
> >  
> >              print(f"{c_type}:")
> >  
> > -            for symbol, ref in sorted(refs.items()):
> > -                print(f"  {symbol} -> {ref}")
> > +            for symbol, (ref, ln) in sorted(refs.items()):
> > +                print(f"  #{ln:<5d} {symbol} -> {ref}")
> >  
> >              print()
> >  
> > @@ -384,7 +385,7 @@ class ParseDataStructs:
> >  
> >          # Process all reference types
> >          for ref_dict in self.symbols.values():
> > -            for symbol, replacement in ref_dict.items():
> > +            for symbol, (replacement, _) in ref_dict.items():
> >                  symbol = re.escape(re.sub(r"([\_\`\*\<\>\&\\\\:\/])", r"\\\1", symbol))
> >                  text = re.sub(fr'{start_delim}{symbol}{end_delim}',
> >                                fr'\1{replacement}\2', text)
> > @@ -420,8 +421,8 @@ class ParseDataStructs:
> >              text.append("")
> >  
> >              # Sort symbols alphabetically
> > -            for symbol, ref in sorted(refs.items()):
> > -                text.append(f"* :{ref}:")
> > +            for symbol, (ref, ln) in sorted(refs.items()):
> > +                text.append(f"* {ref}: line #{ln}")
> >  
> >              text.append("")  # Add empty line between categories
> >    
> 

  reply	other threads:[~2025-10-20 11:56 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-01 14:49 [PATCH 00/23] Fix media uAPI cross references Mauro Carvalho Chehab
2025-10-01 14:49 ` [PATCH 01/23] tools: docs: parse_data_structs.py: drop contents header Mauro Carvalho Chehab
2025-10-01 14:49 ` [PATCH 02/23] tools: docs: parse_data_structs.py: output a line number Mauro Carvalho Chehab
2025-10-20 10:46   ` Hans Verkuil
2025-10-20 11:56     ` Mauro Carvalho Chehab [this message]
2025-10-01 14:49 ` [PATCH 03/23] docs: kernel_include.py: fix line numbers for TOC Mauro Carvalho Chehab
2025-10-01 14:49 ` [PATCH 04/23] docs: kernel_include.py: propose alternatives Mauro Carvalho Chehab
2025-10-01 14:49 ` [PATCH 05/23] tools: docs: parse_data_structs: make process_exceptions two stages Mauro Carvalho Chehab
2025-10-01 14:49 ` [PATCH 06/23] tools: docs: parse_data_structs.py: get rid of process_exceptions() Mauro Carvalho Chehab
2025-10-01 14:49 ` [PATCH 07/23] tools: docs: parse_data_structs.py: add namespace support Mauro Carvalho Chehab
2025-10-01 14:49 ` [PATCH 08/23] tools: docs: parse_data_structs.py: accept more reftypes Mauro Carvalho Chehab
2025-10-01 14:49 ` [PATCH 09/23] docs: media: dvb: use TOC instead of file contents at headers Mauro Carvalho Chehab
2025-10-01 14:49 ` [PATCH 10/23] docs: media: dvb: enable warnings for most headers Mauro Carvalho Chehab
2025-10-01 14:49 ` [PATCH 11/23] docs: media: rc: use TOC instead of file contents for LIRC header Mauro Carvalho Chehab
2025-10-01 14:49 ` [PATCH 12/23] docs: media: mediactl: use TOC instead of file contents Mauro Carvalho Chehab
2025-10-01 14:49 ` [PATCH 13/23] docs: kernel_include.py: use get_close_matches() to propose alternatives Mauro Carvalho Chehab
2025-10-01 14:49 ` [PATCH 14/23] docs: media: add missing c namespace to V4L headers Mauro Carvalho Chehab
2025-10-01 14:49 ` [PATCH 15/23] docs: media: videodev2.h.rst.exceptions: fix namespace on refs Mauro Carvalho Chehab
2025-10-01 14:49 ` [PATCH 16/23] media: docs: add a missing reference for VIDIOC_QUERY_CTRL Mauro Carvalho Chehab
2025-10-01 14:49 ` [PATCH 17/23] media: docs: videodev2.h.rst.exceptions: ignore struct __kernel_v4l2_timeval Mauro Carvalho Chehab
2025-10-01 14:49 ` [PATCH 18/23] media: docs: add some C domain missing references Mauro Carvalho Chehab
2025-10-01 14:49 ` [PATCH 19/23] docs: cec: cec.h.rst.exceptions: fix broken references from cec.h Mauro Carvalho Chehab
2025-10-01 14:49 ` [PATCH 20/23] docs: cec: show broken xrefs and show TOC instead of cec.h content Mauro Carvalho Chehab
2025-10-01 14:49 ` [PATCH 21/23] docs: media: dmx_types: place kerneldoc at the right namespace Mauro Carvalho Chehab
2025-10-01 14:49 ` [PATCH 22/23] docs: media: dvb: headers: warn about broken cross references Mauro Carvalho Chehab
2025-10-01 14:49 ` [PATCH 23/23] docs: media: dvb: fix dmx.h.rst.exceptions Mauro Carvalho Chehab
2025-10-17 20:08 ` [PATCH 00/23] Fix media uAPI cross references Jonathan Corbet
2025-10-18 10:53   ` Mauro Carvalho Chehab
2025-10-20 10:51 ` Hans Verkuil

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=20251020085643.14007a29@sal.lan \
    --to=mchehab+huawei@kernel.org \
    --cc=corbet@lwn.net \
    --cc=hverkuil+cisco@kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    /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).