Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

docs: sphinx/kernel_abi: use AbiParser directly

Instead of running get_abi.py script, import AbiParser class and
handle messages directly there using an interactor. This shold save some
memory, as there's no need to exec python inside the Sphinx python
extension.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Link: https://lore.kernel.org/r/8dbc244dcda97112c1b694e2512a5d600e62873b.1739182025.git.mchehab+huawei@kernel.org

authored by

Mauro Carvalho Chehab and committed by
Jonathan Corbet
ee34f830 9bec7870

+17 -14
+16 -13
Documentation/sphinx/kernel_abi.py
··· 34 34 35 35 import os 36 36 import re 37 - import subprocess 38 37 import sys 39 38 40 39 from docutils import nodes ··· 41 42 from docutils.parsers.rst import directives, Directive 42 43 from sphinx.util.docutils import switch_source_input 43 44 from sphinx.util import logging 45 + 46 + srctree = os.path.abspath(os.environ["srctree"]) 47 + sys.path.insert(0, os.path.join(srctree, "scripts/lib/abi")) 48 + 49 + from abi_parser import AbiParser 44 50 45 51 __version__ = "1.0" 46 52 ··· 70 66 logger = logging.getLogger('kernel_abi') 71 67 72 68 option_spec = { 73 - "debug" : directives.flag, 69 + "debug": directives.flag, 74 70 } 75 71 76 72 def run(self): ··· 78 74 if not doc.settings.file_insertion_enabled: 79 75 raise self.warning("docutils: file insertion disabled") 80 76 81 - srctree = os.path.abspath(os.environ["srctree"]) 77 + path = os.path.join(srctree, "Documentation", self.arguments[0]) 78 + parser = AbiParser(path, logger=self.logger) 79 + parser.parse_abi() 80 + parser.check_issues() 82 81 83 - args = [ 84 - os.path.join(srctree, 'scripts/get_abi.py'), 85 - '-D', os.path.join(srctree, 'Documentation', self.arguments[0]), 86 - 'rest', 87 - '--enable-lineno', 88 - ] 82 + msg = "" 83 + for m in parser.doc(enable_lineno=True, show_file=True): 84 + msg += m 89 85 90 - lines = subprocess.check_output(args, cwd=os.path.dirname(doc.current_source)).decode('utf-8') 91 - nodeList = self.nestedParse(lines, self.arguments[0]) 92 - return nodeList 86 + node = self.nested_parse(msg, self.arguments[0]) 87 + return node 93 88 94 - def nestedParse(self, lines, fname): 89 + def nested_parse(self, lines, fname): 95 90 env = self.state.document.settings.env 96 91 content = ViewList() 97 92 node = nodes.section()
+1 -1
scripts/lib/abi/abi_parser.py
··· 427 427 428 428 return new_desc + "\n\n" 429 429 430 - def doc(self, enable_lineno, output_in_txt, show_file=False): 430 + def doc(self, enable_lineno, output_in_txt=False, show_file=False): 431 431 """Print ABI at stdout""" 432 432 433 433 part = None