All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
To: Randy Dunlap <rdunlap@infradead.org>
Cc: Linux Doc Mailing List <linux-doc@vger.kernel.org>,
	Jonathan Corbet <corbet@lwn.net>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] kernel-doc: add support for handling global variables
Date: Wed, 10 Sep 2025 06:23:23 +0200	[thread overview]
Message-ID: <20250910062323.059bb078@foz.lan> (raw)
In-Reply-To: <c195c68f-e815-4428-9134-8746198a4611@infradead.org>

Em Tue, 9 Sep 2025 17:02:00 -0700
Randy Dunlap <rdunlap@infradead.org> escreveu:

> On 9/9/25 4:50 PM, Randy Dunlap wrote:
> > 
> > 
> > On 9/9/25 4:49 PM, Randy Dunlap wrote:  
> >>
> >>
> >> On 9/9/25 4:09 PM, Mauro Carvalho Chehab wrote:  
> >>> Em Tue, 9 Sep 2025 14:06:43 -0700
> >>> Randy Dunlap <rdunlap@infradead.org> escreveu:
> >>>  
> >>>> On 9/9/25 12:58 PM, Mauro Carvalho Chehab wrote:  
> >>>>> Em Tue, 9 Sep 2025 00:27:20 -0700
> >>>>> Randy Dunlap <rdunlap@infradead.org> escreveu:  
> >>>  
> >>>>>> +.. kernel-doc:: init/kdoc-globals-test.c
> >>>>>> +   :identifiers:
> >>>>>>
> >>>>>> The html output says
> >>>>>> "Kernel Globals"
> >>>>>> but nothing else.    
> >>>>>
> >>>>> I usually don't add :identifiers: on kernel-doc entries. If you use
> >>>>> identifiers, you need to explicitly tell what symbols you want.    
> >>>>
> >>>> Well, it worked/works without using having any identifiers listed, and
> >>>> the docs in Documentation/doc-guide/kernel-doc.rst says that they are
> >>>> optional:
> >>>>
> >>>> identifiers: *[ function/type ...]*
> >>>>   Include documentation for each *function* and *type* in *source*.
> >>>>   If no *function* is specified, the documentation for all functions
> >>>>   and types in the *source* will be included.
> >>>>   *type* can be a struct, union, enum, or typedef identifier.  
> >>>
> >>> Hmm.. looking the entire logic:
> >>>
> >>>         elif 'identifiers' in self.options:
> >>>             identifiers = self.options.get('identifiers').split()
> >>>             if identifiers:
> >>>                 for i in identifiers:
> >>>                     i = i.rstrip("\\").strip()
> >>>                     if not i:
> >>>                         continue
> >>>
> >>>                     cmd += ['-function', i]
> >>>                     self.msg_args["symbol"].append(i)
> >>>             else:
> >>>                 cmd += ['-no-doc-sections']
> >>>                 self.msg_args["no_doc_sections"] = True
> >>>
> >>> I suspect that an empty identifier could be raising an exception.  
> 
> and it's being caught and ignored (not printed)?

there is a try/except block to capture exceptions. It is supposed to
print something, though:

        try:
            if kfiles:
                return self.run_kdoc(cmd, kfiles)
            else:
                return self.run_cmd(cmd)

        except Exception as e:  # pylint: disable=W0703
            logger.warning("kernel-doc '%s' processing failed with: %s" %
                           (cmd_str(cmd), pformat(e)))
            return [nodes.error(None, nodes.paragraph(text = "kernel-doc missing"))]

> >>> The right logic should be, instead:
> >>>
> >>> -        elif 'identifiers' in self.options:
> >>> -            identifiers = self.options.get('identifiers').split()
> >>> -            if identifiers:
> >>> -                for i in identifiers:
> >>> +        elif 'identifiers' in self.options:
> >>> +            identifiers = self.options.get('identifiers')
> >>> +            if identifiers:
> >>> +                for i in identifiers.split():
> >>>
> >>> (tests needed)  
> >>
> >> Sheesh, I can't find that code so that I can patch it.
> >> (in today's linux-next 20250909)  
> > 
> > oops, I was looking in scripts/ and not in Documentation/.
> > got it.
> >   
> >> Anyway, does this take away something that currently works?  
> 
> The output looks the same with this patch AFAICT.

run it in verbose mode to see what command line was passed to
the file:

	$ make SPHINXDIRS=your_test_dir V=1 htmldocs

This should be printing how the kernel-doc.py command line would be(*):

	scripts/kernel-doc.py -rst -enable-lineno ./include/linux/peci.h
	./include/linux/peci.h:20 Scanning doc for struct peci_controller_ops
	./include/linux/peci.h:32 Scanning doc for struct peci_controller
	./include/linux/peci.h:58 Scanning doc for struct peci_device
	./include/linux/peci.h:88 Scanning doc for struct peci_request

(*) the kerneldoc.py extension doesn't call kernel-doc.py, but instead
    run directly the Python classes from the library. Yet, to help one
    to debug it, the command line is displayed.

for instance, on a more complex kernel-doc tags case:

	$ make SPHINXDIRS=driver-api/cxl/ V=1 htmldocs 2>&1 |grep scripts/kernel-doc.py
	scripts/kernel-doc.py -rst -enable-lineno -function 'cxl pci' ./drivers/cxl/pci.c
	scripts/kernel-doc.py -rst -enable-lineno -internal ./drivers/cxl/pci.c
	scripts/kernel-doc.py -rst -enable-lineno -function 'cxl mem' ./drivers/cxl/mem.c
	scripts/kernel-doc.py -rst -enable-lineno -internal ./drivers/cxl/cxlmem.h
	scripts/kernel-doc.py -rst -enable-lineno -no-doc-sections ./drivers/cxl/core/memdev.c
	scripts/kernel-doc.py -rst -enable-lineno -function 'cxl port' ./drivers/cxl/port.c
	scripts/kernel-doc.py -rst -enable-lineno -function 'cxl objects' ./drivers/cxl/cxl.h
	scripts/kernel-doc.py -rst -enable-lineno -internal ./drivers/cxl/cxl.h
	scripts/kernel-doc.py -rst -enable-lineno -function add_cxl_resources ./drivers/cxl/acpi.c
	scripts/kernel-doc.py -rst -enable-lineno -function 'cxl core hdm' ./drivers/cxl/core/hdm.c
	scripts/kernel-doc.py -rst -enable-lineno -no-doc-sections ./drivers/cxl/core/hdm.c
	scripts/kernel-doc.py -rst -enable-lineno -no-doc-sections ./drivers/cxl/core/cdat.c
	scripts/kernel-doc.py -rst -enable-lineno -function 'cxl core' ./drivers/cxl/core/port.c
	scripts/kernel-doc.py -rst -enable-lineno -no-doc-sections ./drivers/cxl/core/port.c
	scripts/kernel-doc.py -rst -enable-lineno -function 'cxl core pci' ./drivers/cxl/core/pci.c
	scripts/kernel-doc.py -rst -enable-lineno -no-doc-sections ./drivers/cxl/core/pci.c
	scripts/kernel-doc.py -rst -enable-lineno -function 'cxl pmem' ./drivers/cxl/core/pmem.c
	scripts/kernel-doc.py -rst -enable-lineno -no-doc-sections ./drivers/cxl/core/pmem.c
	scripts/kernel-doc.py -rst -enable-lineno -function 'cxl registers' ./drivers/cxl/core/regs.c
	scripts/kernel-doc.py -rst -enable-lineno -no-doc-sections ./drivers/cxl/core/regs.c
	scripts/kernel-doc.py -rst -enable-lineno -function 'cxl mbox' ./drivers/cxl/core/mbox.c
	scripts/kernel-doc.py -rst -enable-lineno -no-doc-sections ./drivers/cxl/core/mbox.c
	scripts/kernel-doc.py -rst -enable-lineno -function 'cxl features' ./drivers/cxl/core/features.c
	scripts/kernel-doc.py -rst -enable-lineno -function 'cxl core region' ./drivers/cxl/core/region.c
	scripts/kernel-doc.py -rst -enable-lineno -no-doc-sections ./drivers/cxl/core/region.c
	scripts/kernel-doc.py -rst -enable-lineno -function UAPI ./include/uapi/linux/cxl_mem.h
	scripts/kernel-doc.py -rst -enable-lineno -internal ./include/uapi/linux/cxl_mem.h


Thanks,
Mauro

  reply	other threads:[~2025-09-10  4:23 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-07 16:22 [PATCH] kernel-doc: add support for handling global variables Mauro Carvalho Chehab
2025-09-07 21:34 ` Mauro Carvalho Chehab
2025-09-09  6:22   ` Randy Dunlap
2025-09-09 20:12     ` Mauro Carvalho Chehab
2025-09-09  7:27 ` Randy Dunlap
2025-09-09 15:57   ` Randy Dunlap
2025-09-09 16:18     ` Mauro Carvalho Chehab
2025-09-09 18:20       ` Randy Dunlap
2025-09-09 20:37         ` Mauro Carvalho Chehab
2025-09-09 19:58   ` Mauro Carvalho Chehab
2025-09-09 20:09     ` Mauro Carvalho Chehab
2025-09-09 21:06     ` Randy Dunlap
2025-09-09 23:09       ` Mauro Carvalho Chehab
2025-09-09 23:49         ` Randy Dunlap
2025-09-09 23:50           ` Randy Dunlap
2025-09-10  0:02             ` Randy Dunlap
2025-09-10  4:23               ` Mauro Carvalho Chehab [this message]
2025-09-10  5:59                 ` Randy Dunlap
2025-09-10  6:13                   ` Randy Dunlap
2025-09-10  8:54                     ` Mauro Carvalho Chehab
2025-11-15  0:50                       ` Randy Dunlap
2025-11-16 10:28                         ` Mauro Carvalho Chehab
2025-11-16 19:46                           ` Randy Dunlap
2025-11-17  9:45   ` Mauro Carvalho Chehab
2025-11-17 17:45     ` Randy Dunlap
2025-09-10  9:24 ` Jani Nikula
2025-09-10 12:13   ` 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=20250910062323.059bb078@foz.lan \
    --to=mchehab+huawei@kernel.org \
    --cc=corbet@lwn.net \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rdunlap@infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.