diff options
author | Mauro Carvalho Chehab <mchehab+huawei@kernel.org> | 2025-02-10 11:18:12 +0100 |
---|---|---|
committer | Jonathan Corbet <corbet@lwn.net> | 2025-02-10 11:19:57 -0700 |
commit | 5ca0e7ffc898ad43bbd1360adf50398fa817dbc9 (patch) | |
tree | 4253d3a42ce546fc03c65cb347f9f731c95c563f /Documentation/sphinx/kernel_abi.py | |
parent | c940816968da6ef9a9462b7c070cc333d609a16c (diff) |
docs: sphinx/kernel_abi: avoid warnings during Sphinx module init
Sphinx logging system doesn't like warnings during module load,
as it understands that such logs are produced at the wrong time:
WARNING: while setting up extension automarkup: /sys/devices/system/cpu/cpuX/topology/physical_package_id is defined 2 times: /new_devel/v4l/docs/Documentation/ABI/stable/sysfs-devices-system-cpu:27; /new_devel/v4l/docs/Documentation/ABI/testing/sysfs-devices-system-cpu:70
WARNING: while setting up extension automarkup: /sys/devices/system/cpu/cpuX/topology/ppin is defined 2 times: /new_devel/v4l/docs/Documentation/ABI/stable/sysfs-devices-system-cpu:89; /new_devel/v4l/docs/Documentation/ABI/testing/sysfs-devices-system-cpu:70
So, use a function to allocate/process ABI files and use it to
be called at kernel_abi.py, as automarkup also needs it to
produce the right cross-references.
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Link: https://lore.kernel.org/r/b0e79dc60d556e3b39fa6774d3b7bf734b73f352.1739182025.git.mchehab+huawei@kernel.org
Diffstat (limited to 'Documentation/sphinx/kernel_abi.py')
-rw-r--r-- | Documentation/sphinx/kernel_abi.py | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/Documentation/sphinx/kernel_abi.py b/Documentation/sphinx/kernel_abi.py index 964f586de171..e017b0299953 100644 --- a/Documentation/sphinx/kernel_abi.py +++ b/Documentation/sphinx/kernel_abi.py @@ -52,10 +52,23 @@ __version__ = "1.0" logger = logging.getLogger('kernel_abi') path = os.path.join(srctree, "Documentation/ABI") -# Parse ABI symbols only once -kernel_abi = AbiParser(path, logger=logger) -kernel_abi.parse_abi() -kernel_abi.check_issues() +_kernel_abi = None + +def get_kernel_abi(): + u""" + Initialize kernel_abi global var, if not initialized yet. + + This is needed to avoid warnings during Sphinx module initialization. + """ + global _kernel_abi + + if not _kernel_abi: + # Parse ABI symbols only once + _kernel_abi = AbiParser(path, logger=logger) + _kernel_abi.parse_abi() + _kernel_abi.check_issues() + + return _kernel_abi def setup(app): @@ -83,6 +96,8 @@ class KernelCmd(Directive): } def run(self): + kernel_abi = get_kernel_abi() + doc = self.state.document if not doc.settings.file_insertion_enabled: raise self.warning("docutils: file insertion disabled") |