Linux Documentation
 help / color / mirror / Atom feed
* make mandocs: subdirectories scanned
@ 2025-11-08 22:50 Randy Dunlap
  2025-11-08 23:08 ` Mauro Carvalho Chehab
  0 siblings, 1 reply; 4+ messages in thread
From: Randy Dunlap @ 2025-11-08 22:50 UTC (permalink / raw)
  To: Linux Documentation, Mauro Carvalho Chehab, Jonathan Corbet

Hi,

I just hit a problem that I haven't encountered in the past.

I always use O=subdir to build test kernels, where subdir is
at the top level of the kernel source tree.
(I just found this maybe because I haven't been doing a lot of
kernel builds lately.)

This causes 'make mandocs' to recurse continuously because
subdir/source is a symbolic link to ".." (top level of kernel
tree) and kernel-doc finds all of the (same) source files again
there.

I first discovered this with a subdir named ARM, for arch/arm/
builds. I tried renaming it .ARM but same result. Then I tried
a subdir name of "snap" because it is in the .gitignore file.

All of these have the same result. Here is an example of the
output:

Warning: ../snap/source/snap/source/snap/source/drivers/net/ethernet/freescale/gianfar.h:1105 struct member 'rstat' not described in 'gfar_priv_grp'
Warning: ../snap/source/snap/source/snap/source/drivers/net/ethernet/freescale/gianfar.h:1105 struct member 'num_tx_queues' not described in 'gfar_priv_grp'
Warning: ../snap/source/snap/source/snap/source/drivers/net/ethernet/freescale/gianfar.h:1105 struct member 'tx_bit_map' not described in 'gfar_priv_grp'
Warning: ../snap/source/snap/source/snap/source/drivers/net/ethernet/freescale/gianfar.h:1105 struct member 'num_rx_queues' not described in 'gfar_priv_grp'
Warning: ../snap/source/snap/source/snap/source/drivers/net/ethernet/freescale/gianfar.h:1105 struct member 'rx_bit_map' not described in 'gfar_priv_grp'
Warning: ../snap/source/snap/source/snap/source/drivers/net/ethernet/freescale/fec_mpc52xx.c:698 function parameter 'may_sleep' not described in 'mpc52xx_fec_stop'

Would it be reasonable to have kernel-doc not follow symbolic links?

Any other suggestions (other than not using local [in the kernel source tree]
build subdirectories)?

thanks.
-- 
~Randy


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

* Re: make mandocs: subdirectories scanned
  2025-11-08 22:50 make mandocs: subdirectories scanned Randy Dunlap
@ 2025-11-08 23:08 ` Mauro Carvalho Chehab
  2025-11-08 23:11   ` Randy Dunlap
  2025-11-09  5:00   ` Randy Dunlap
  0 siblings, 2 replies; 4+ messages in thread
From: Mauro Carvalho Chehab @ 2025-11-08 23:08 UTC (permalink / raw)
  To: Randy Dunlap; +Cc: Linux Documentation, Mauro Carvalho Chehab, Jonathan Corbet

Em Sat, 8 Nov 2025 14:50:35 -0800
Randy Dunlap <rdunlap@infradead.org> escreveu:

> Hi,
> 
> I just hit a problem that I haven't encountered in the past.
> 
> I always use O=subdir to build test kernels, where subdir is
> at the top level of the kernel source tree.
> (I just found this maybe because I haven't been doing a lot of
> kernel builds lately.)
> 
> This causes 'make mandocs' to recurse continuously because
> subdir/source is a symbolic link to ".." (top level of kernel
> tree) and kernel-doc finds all of the (same) source files again
> there.
> 
> I first discovered this with a subdir named ARM, for arch/arm/
> builds. I tried renaming it .ARM but same result. Then I tried
> a subdir name of "snap" because it is in the .gitignore file.
> 
> All of these have the same result. Here is an example of the
> output:
> 
> Warning: ../snap/source/snap/source/snap/source/drivers/net/ethernet/freescale/gianfar.h:1105 struct member 'rstat' not described in 'gfar_priv_grp'
> Warning: ../snap/source/snap/source/snap/source/drivers/net/ethernet/freescale/gianfar.h:1105 struct member 'num_tx_queues' not described in 'gfar_priv_grp'
> Warning: ../snap/source/snap/source/snap/source/drivers/net/ethernet/freescale/gianfar.h:1105 struct member 'tx_bit_map' not described in 'gfar_priv_grp'
> Warning: ../snap/source/snap/source/snap/source/drivers/net/ethernet/freescale/gianfar.h:1105 struct member 'num_rx_queues' not described in 'gfar_priv_grp'
> Warning: ../snap/source/snap/source/snap/source/drivers/net/ethernet/freescale/gianfar.h:1105 struct member 'rx_bit_map' not described in 'gfar_priv_grp'
> Warning: ../snap/source/snap/source/snap/source/drivers/net/ethernet/freescale/fec_mpc52xx.c:698 function parameter 'may_sleep' not described in 'mpc52xx_fec_stop'
> 
> Would it be reasonable to have kernel-doc not follow symbolic links?
> 
> Any other suggestions (other than not using local [in the kernel source tree]
> build subdirectories)?
> 
> thanks.

The logic which parses the directory structure is at
scripts/lib/kdoc/kdoc_files.py:

    def _parse_dir(self, dirname):
        """Internal function to parse files recursively"""

        with os.scandir(dirname) as obj:
            for entry in obj:
                name = os.path.join(dirname, entry.name)

                if entry.is_dir():
                    yield from self._parse_dir(name)

                if not entry.is_file():
                    continue

                basename = os.path.basename(name)

                if not basename.endswith(self.extensions):
                    continue

                yield name

The recursive logic is at:

                if entry.is_dir():
                    yield from self._parse_dir(name)

It should be easy to change the above to check for symlinks with either:

+	if entry.is_symlink():
+	    continue
+
        if entry.is_dir():
            yield from self._parse_dir(name)

(this would ignore symlinks on files - not sure if this is the best
strategy)

or:

                if entry.is_dir():
+		    if entry.is_symlink():
+		        continue
+
                    yield from self._parse_dir(name)

Alternatively, you can, instead, do:

-               if entry.is_dir():
+               if entry.is_dir(follow_symlinks=False):
                    yield from self._parse_dir(name)

which should prevent it to follow symlinks.

I would try the last one first.

It is likely easier if you write such patch, as you have already a setup
where you can test it.


Thanks,
Mauro

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

* Re: make mandocs: subdirectories scanned
  2025-11-08 23:08 ` Mauro Carvalho Chehab
@ 2025-11-08 23:11   ` Randy Dunlap
  2025-11-09  5:00   ` Randy Dunlap
  1 sibling, 0 replies; 4+ messages in thread
From: Randy Dunlap @ 2025-11-08 23:11 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: Linux Documentation, Mauro Carvalho Chehab, Jonathan Corbet



On 11/8/25 3:08 PM, Mauro Carvalho Chehab wrote:
> Em Sat, 8 Nov 2025 14:50:35 -0800
> Randy Dunlap <rdunlap@infradead.org> escreveu:
> 
>> Hi,
>>
>> I just hit a problem that I haven't encountered in the past.
>>
>> I always use O=subdir to build test kernels, where subdir is
>> at the top level of the kernel source tree.
>> (I just found this maybe because I haven't been doing a lot of
>> kernel builds lately.)
>>
>> This causes 'make mandocs' to recurse continuously because
>> subdir/source is a symbolic link to ".." (top level of kernel
>> tree) and kernel-doc finds all of the (same) source files again
>> there.
>>
>> I first discovered this with a subdir named ARM, for arch/arm/
>> builds. I tried renaming it .ARM but same result. Then I tried
>> a subdir name of "snap" because it is in the .gitignore file.
>>
>> All of these have the same result. Here is an example of the
>> output:
>>
>> Warning: ../snap/source/snap/source/snap/source/drivers/net/ethernet/freescale/gianfar.h:1105 struct member 'rstat' not described in 'gfar_priv_grp'
>> Warning: ../snap/source/snap/source/snap/source/drivers/net/ethernet/freescale/gianfar.h:1105 struct member 'num_tx_queues' not described in 'gfar_priv_grp'
>> Warning: ../snap/source/snap/source/snap/source/drivers/net/ethernet/freescale/gianfar.h:1105 struct member 'tx_bit_map' not described in 'gfar_priv_grp'
>> Warning: ../snap/source/snap/source/snap/source/drivers/net/ethernet/freescale/gianfar.h:1105 struct member 'num_rx_queues' not described in 'gfar_priv_grp'
>> Warning: ../snap/source/snap/source/snap/source/drivers/net/ethernet/freescale/gianfar.h:1105 struct member 'rx_bit_map' not described in 'gfar_priv_grp'
>> Warning: ../snap/source/snap/source/snap/source/drivers/net/ethernet/freescale/fec_mpc52xx.c:698 function parameter 'may_sleep' not described in 'mpc52xx_fec_stop'
>>
>> Would it be reasonable to have kernel-doc not follow symbolic links?
>>
>> Any other suggestions (other than not using local [in the kernel source tree]
>> build subdirectories)?
>>
>> thanks.
> 
> The logic which parses the directory structure is at
> scripts/lib/kdoc/kdoc_files.py:
> 
>     def _parse_dir(self, dirname):
>         """Internal function to parse files recursively"""
> 
>         with os.scandir(dirname) as obj:
>             for entry in obj:
>                 name = os.path.join(dirname, entry.name)
> 
>                 if entry.is_dir():
>                     yield from self._parse_dir(name)
> 
>                 if not entry.is_file():
>                     continue
> 
>                 basename = os.path.basename(name)
> 
>                 if not basename.endswith(self.extensions):
>                     continue
> 
>                 yield name
> 
> The recursive logic is at:
> 
>                 if entry.is_dir():
>                     yield from self._parse_dir(name)
> 
> It should be easy to change the above to check for symlinks with either:
> 
> +	if entry.is_symlink():
> +	    continue
> +
>         if entry.is_dir():
>             yield from self._parse_dir(name)
> 
> (this would ignore symlinks on files - not sure if this is the best
> strategy)
> 
> or:
> 
>                 if entry.is_dir():
> +		    if entry.is_symlink():
> +		        continue
> +
>                     yield from self._parse_dir(name)
> 
> Alternatively, you can, instead, do:
> 
> -               if entry.is_dir():
> +               if entry.is_dir(follow_symlinks=False):
>                     yield from self._parse_dir(name)
> 
> which should prevent it to follow symlinks.
> 
> I would try the last one first.
> 
> It is likely easier if you write such patch, as you have already a setup
> where you can test it.

Sure, I'll test that today (Saturday) or Sunday.

Thanks.

-- 
~Randy


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

* Re: make mandocs: subdirectories scanned
  2025-11-08 23:08 ` Mauro Carvalho Chehab
  2025-11-08 23:11   ` Randy Dunlap
@ 2025-11-09  5:00   ` Randy Dunlap
  1 sibling, 0 replies; 4+ messages in thread
From: Randy Dunlap @ 2025-11-09  5:00 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: Linux Documentation, Mauro Carvalho Chehab, Jonathan Corbet

Mauro,

On 11/8/25 3:08 PM, Mauro Carvalho Chehab wrote:
> Em Sat, 8 Nov 2025 14:50:35 -0800
> Randy Dunlap <rdunlap@infradead.org> escreveu:
> 
>> Hi,
>>
>> I just hit a problem that I haven't encountered in the past.
>>
>> I always use O=subdir to build test kernels, where subdir is
>> at the top level of the kernel source tree.
>> (I just found this maybe because I haven't been doing a lot of
>> kernel builds lately.)
>>
>> This causes 'make mandocs' to recurse continuously because
>> subdir/source is a symbolic link to ".." (top level of kernel
>> tree) and kernel-doc finds all of the (same) source files again
>> there.
>>
>> I first discovered this with a subdir named ARM, for arch/arm/
>> builds. I tried renaming it .ARM but same result. Then I tried
>> a subdir name of "snap" because it is in the .gitignore file.
>>
>> All of these have the same result. Here is an example of the
>> output:
>>
>> Warning: ../snap/source/snap/source/snap/source/drivers/net/ethernet/freescale/gianfar.h:1105 struct member 'rstat' not described in 'gfar_priv_grp'
>> Warning: ../snap/source/snap/source/snap/source/drivers/net/ethernet/freescale/gianfar.h:1105 struct member 'num_tx_queues' not described in 'gfar_priv_grp'
>> Warning: ../snap/source/snap/source/snap/source/drivers/net/ethernet/freescale/gianfar.h:1105 struct member 'tx_bit_map' not described in 'gfar_priv_grp'
>> Warning: ../snap/source/snap/source/snap/source/drivers/net/ethernet/freescale/gianfar.h:1105 struct member 'num_rx_queues' not described in 'gfar_priv_grp'
>> Warning: ../snap/source/snap/source/snap/source/drivers/net/ethernet/freescale/gianfar.h:1105 struct member 'rx_bit_map' not described in 'gfar_priv_grp'
>> Warning: ../snap/source/snap/source/snap/source/drivers/net/ethernet/freescale/fec_mpc52xx.c:698 function parameter 'may_sleep' not described in 'mpc52xx_fec_stop'
>>
>> Would it be reasonable to have kernel-doc not follow symbolic links?
>>
>> Any other suggestions (other than not using local [in the kernel source tree]
>> build subdirectories)?
>>
>> thanks.
> 
> The logic which parses the directory structure is at
> scripts/lib/kdoc/kdoc_files.py:
> 
>     def _parse_dir(self, dirname):
>         """Internal function to parse files recursively"""
> 
>         with os.scandir(dirname) as obj:
>             for entry in obj:
>                 name = os.path.join(dirname, entry.name)
> 
>                 if entry.is_dir():
>                     yield from self._parse_dir(name)
> 
>                 if not entry.is_file():
>                     continue
> 
>                 basename = os.path.basename(name)
> 
>                 if not basename.endswith(self.extensions):
>                     continue
> 
>                 yield name
> 
> The recursive logic is at:
> 
>                 if entry.is_dir():
>                     yield from self._parse_dir(name)
> 
> It should be easy to change the above to check for symlinks with either:
> 
> +	if entry.is_symlink():
> +	    continue
> +
>         if entry.is_dir():
>             yield from self._parse_dir(name)
> 
> (this would ignore symlinks on files - not sure if this is the best
> strategy)
> 
> or:
> 
>                 if entry.is_dir():
> +		    if entry.is_symlink():
> +		        continue
> +
>                     yield from self._parse_dir(name)
> 
> Alternatively, you can, instead, do:
> 
> -               if entry.is_dir():
> +               if entry.is_dir(follow_symlinks=False):
>                     yield from self._parse_dir(name)

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

> which should prevent it to follow symlinks.
> 
> I would try the last one first.

This (above one-line change) is the only change that I tested and
it worked as expected/needed with a build subdir at the top of
the kernel source tree.

> It is likely easier if you write such patch, as you have already a setup
> where you can test it.

Thanks.
-- 
~Randy


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

end of thread, other threads:[~2025-11-09  5:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-08 22:50 make mandocs: subdirectories scanned Randy Dunlap
2025-11-08 23:08 ` Mauro Carvalho Chehab
2025-11-08 23:11   ` Randy Dunlap
2025-11-09  5:00   ` Randy Dunlap

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox