docs: conf.py: properly handle include and exclude patterns
authorMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Sun, 22 Jun 2025 06:02:30 +0000 (08:02 +0200)
committerJonathan Corbet <corbet@lwn.net>
Wed, 25 Jun 2025 18:22:47 +0000 (12:22 -0600)
commit097fe72746950acbba39a6b6bf8ab26a4ba02e25
treeed1b1c4d5e9a00a8a9335e11d44004f5dedb0bfe
parent07e04d8e7dceae9822377abcb2dd07aae5747e7d
docs: conf.py: properly handle include and exclude patterns

When one does:
make SPHINXDIRS="foo" htmldocs

All patterns would be relative to Documentation/foo, which
causes the include/exclude patterns like:

include_patterns = [
...
f'foo/*.{ext}',
]

to break. This is not what it is expected. Address it by
adding a logic to dynamically adjust the pattern when
SPHINXDIRS is used.

That allows adding parsers for other file types.

It should be noticed that include_patterns was added on
Sphinx 5.1:
https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-include_patterns

So, a backward-compatible code is needed when we start
using it for real.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Reviewed-by: Donald Hunter <donald.hunter@gmail.com>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Link: https://lore.kernel.org/r/429c9c670fe27860f5e4f29aaf72576a4ed52ad1.1750571906.git.mchehab+huawei@kernel.org
Documentation/conf.py