]> Gentwo Git Trees - linux/.git/commitdiff
Documentation/sphinx/kernel_feat.py: use class directly
authorMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Tue, 18 Nov 2025 19:09:27 +0000 (20:09 +0100)
committerJonathan Corbet <corbet@lwn.net>
Fri, 21 Nov 2025 17:32:30 +0000 (10:32 -0700)
Now that get_feat is in Python, we don't need to use subprocess
to fork an executable file: we can use the feature classes
directly.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Message-ID: <c59d2542d7cc914fd5f8c84df966e63adc924cdc.1763492868.git.mchehab+huawei@kernel.org>

Documentation/sphinx/kernel_feat.py

index 1dcbfe335a658f503003c3bc241f36b176de7f13..bdc0fef5c87f3e498ce3e981125d86b0ce7e041b 100644 (file)
@@ -34,7 +34,6 @@
 import codecs
 import os
 import re
-import subprocess
 import sys
 
 from docutils import nodes, statemachine
@@ -43,9 +42,9 @@ from docutils.parsers.rst import directives, Directive
 from sphinx.util.docutils import switch_source_input
 
 srctree = os.path.abspath(os.environ["srctree"])
-sys.path.insert(0, os.path.join(srctree, "tools/docs/lib"))
+sys.path.insert(0, os.path.join(srctree, "tools/lib/python"))
 
-from parse_features import ParseFeature                # pylint: disable=C0413
+from feat.parse_features import ParseFeature                # pylint: disable=C0413
 
 def ErrorString(exc):  # Shamelessly stolen from docutils
     return f'{exc.__class__.__name}: {exc}'
@@ -89,18 +88,16 @@ class KernelFeat(Directive):
 
         srctree = os.path.abspath(os.environ["srctree"])
 
-        args = [
-            os.path.join(srctree, 'tools/docs/get_feat.pl'),
-            'rest',
-            '--enable-fname',
-            '--dir',
-            os.path.join(srctree, 'Documentation', self.arguments[0]),
-        ]
+        feature_dir = os.path.join(srctree, 'Documentation', self.arguments[0])
 
-        if len(self.arguments) > 1:
-            args.extend(['--arch', self.arguments[1]])
+        feat = ParseFeature(feature_dir, False, True)
+        feat.parse()
 
-        lines = subprocess.check_output(args, cwd=os.path.dirname(doc.current_source)).decode('utf-8')
+        if len(self.arguments) > 1:
+            arch = self.arguments[1]
+            lines = feat.output_arch_table(arch)
+        else:
+            lines = feat.output_matrix()
 
         line_regex = re.compile(r"^\.\. FILE (\S+)$")