From 0421e038c5bc7237be09b33243071728ac979881 Mon Sep 17 00:00:00 2001 From: yuehua-meng <2368492046@qq.com> Date: Sat, 14 Nov 2026 13:15:24 +0800 Subject: [PATCH 4/4] docs: kernel-doc: pass transforms when parsing export files A separate -export-file reaches a KernelDoc constructor call that does not pass the required xforms argument, raising TypeError. Pass the configured transforms just as parse_file() does. Add a regression with declarations in a header and an export in a separate source file; only the exported declaration is emitted. Fixes: d842057c4a20 ("docs: kdoc_parser: move transform lists to a separate file") AI assistance (Codex) was used to reproduce the failures, prepare the fixes and regression tests, and execute the tests. The task was to inspect and repair kernel-doc behavior in a local Linux tree. Signed-off-by: yuehua-meng <2368492046@qq.com> --- tools/lib/python/kdoc/kdoc_files.py | 2 +- tools/unittests/test_kdoc_export_file.py | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 tools/unittests/test_kdoc_export_file.py diff --git a/tools/lib/python/kdoc/kdoc_files.py b/tools/lib/python/kdoc/kdoc_files.py index 8555433bb..da78908f0 100644 --- a/tools/lib/python/kdoc/kdoc_files.py +++ b/tools/lib/python/kdoc/kdoc_files.py @@ -212,7 +212,7 @@ class KernelFiles(): if fname in self.export_files: return - doc = KernelDoc(self.config, fname) + doc = KernelDoc(self.config, fname, self.xforms) export_table = doc.parse_export() if not export_table: diff --git a/tools/unittests/test_kdoc_export_file.py b/tools/unittests/test_kdoc_export_file.py new file mode 100644 index 000000000..9d2790780 --- /dev/null +++ b/tools/unittests/test_kdoc_export_file.py @@ -0,0 +1,19 @@ +# SPDX-License-Identifier: GPL-2.0 +"""Regression test for a separate kernel-doc export source file.""" + +from kdoc_cli_helper import KernelDocCliTest + + +class TestKernelDocExportFile(KernelDocCliTest): + def test_explicit_export_file(self): + source = self.source("example.h", ( + "/**\n * alpha - internal function\n */\n" + "void alpha(void);\n" + "/**\n * beta - exported function\n */\n" + "void beta(void);\n" + )) + exports = self.source("exports.c", "EXPORT_SYMBOL(beta);\n") + result = self.run_kdoc("-export", "-export-file", exports, source) + self.assertEqual(result.returncode, 0, result.stderr) + self.assertNotIn("void alpha", result.stdout) + self.assertIn("void beta", result.stdout) -- 2.53.0.windows.2