From nobody Fri Oct 10 16:00:15 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5339A2E7F11; Fri, 13 Jun 2025 11:42:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749814967; cv=none; b=UoRywwoQleQ2e7slaSIqXhZr7YFSHHktmp8jTQSQLnpJFkjI8VtCGXf/ZM44LDn3bSYhtD0S9Wa/JhgmL2a+hMDsPnxWnfRceUJY0+4LNzaJ01vljqd9J6RRtxF36PTboYhg6x4gXhcbJC1fqUAyd5+S4Rtm2lYcfQ/agzye1jw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749814967; c=relaxed/simple; bh=RRdlkBDEmtJLl36U7brH9gBLYzEATksRx+v4nftXEzw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OYM1h6YwA+J//k0wi6OlRHSbr1j0FoB3GI+lrG0Rp3qyxO11PrEUCybvWE86nE2ngcDcxLZE7ee4jwJF9ErmMZmWsKPjNFBUdkxatbkl5/QVYOlMvOYDrgJU1Vj4S7wS20b5VI89Syw4/M3pvP5Os8ptltso0Oq1JwmvGA2s7O4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZmGIdAIs; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ZmGIdAIs" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D376FC4CEFB; Fri, 13 Jun 2025 11:42:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1749814966; bh=RRdlkBDEmtJLl36U7brH9gBLYzEATksRx+v4nftXEzw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZmGIdAIsF0j6fvs/aNpGs7XICMloa8BBj4qNnaJyZorcJMurW0D9UgxrAAkTS9/0v 8SyEXLnnRagkMuh8G8DicDy8CXClaNLOu73Qyc25xezUaV7RkEh1k6b4t8KImyj7b7 rkdIKn7Ko2x6qegq3cgYFn02kZ/2PnQoBzY0JWRnwbmjgprHDWxZF8vSdfnjv77LV9 u8z3BPMS1m4YtSMzK5FwscoklNgc+D3VknGw2ud2mNCER6cBdHIjLZTjh2mdMA+4yL oBQedOA7OyLgaUqb0hChwXizST/9aaG/Sa/k0ZNHhzhP3+Ttp2uFd0WYIKLdkW/74p 3WvLkzbJztGkw== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1uQ2o1-00000005dFL-0H9X; Fri, 13 Jun 2025 13:42:45 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Jonathan Corbet Cc: Mauro Carvalho Chehab , "Akira Yokosawa" , "Breno Leitao" , "David S. Miller" , "Donald Hunter" , "Eric Dumazet" , "Ignacio Encinas Rubio" , "Jan Stancek" , "Marco Elver" , "Mauro Carvalho Chehab" , "Paolo Abeni" , "Ruben Wauters" , "Shuah Khan" , joel@joelfernandes.org, linux-kernel-mentees@lists.linux.dev, linux-kernel@vger.kernel.org, lkmm@lists.linux.dev, netdev@vger.kernel.org, peterz@infradead.org, stern@rowland.harvard.edu Subject: [PATCH v3 10/16] docs: sphinx: parser_yaml.py: add Netlink specs parser Date: Fri, 13 Jun 2025 13:42:31 +0200 Message-ID: <095fba5224a22b86a7604773ddaf9b5193157bc1.1749812870.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Mauro Carvalho Chehab Content-Type: text/plain; charset="utf-8" Place the code at parser_yaml.py to handle Netlink specs. All other yaml files are ignored. Signed-off-by: Mauro Carvalho Chehab --- .pylintrc | 2 +- Documentation/sphinx/parser_yaml.py | 39 +++++++++++++++++++++-------- 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/.pylintrc b/.pylintrc index 30b8ae1659f8..f1d21379254b 100644 --- a/.pylintrc +++ b/.pylintrc @@ -1,2 +1,2 @@ [MASTER] -init-hook=3D'import sys; sys.path +=3D ["scripts/lib/kdoc", "scripts/lib/a= bi"]' +init-hook=3D'import sys; sys.path +=3D ["scripts/lib", "scripts/lib/kdoc",= "scripts/lib/abi"]' diff --git a/Documentation/sphinx/parser_yaml.py b/Documentation/sphinx/par= ser_yaml.py index b3cde9cf7aac..eb32e3249274 100755 --- a/Documentation/sphinx/parser_yaml.py +++ b/Documentation/sphinx/parser_yaml.py @@ -3,6 +3,10 @@ Sphinx extension for processing YAML files """ =20 import os +import re +import sys + +from pprint import pformat =20 from docutils.parsers.rst import Parser as RSTParser from docutils.statemachine import ViewList @@ -10,7 +14,10 @@ from docutils.statemachine import ViewList from sphinx.util import logging from sphinx.parsers import Parser =20 -from pprint import pformat +srctree =3D os.path.abspath(os.environ["srctree"]) +sys.path.insert(0, os.path.join(srctree, "scripts/lib")) + +from netlink_yml_parser import NetlinkYamlParser # pylint: disable=3D= C0413 =20 logger =3D logging.getLogger(__name__) =20 @@ -19,8 +26,9 @@ class YamlParser(Parser): =20 supported =3D ('yaml', 'yml') =20 - # Overrides docutils.parsers.Parser. See sphinx.parsers.RSTParser - def parse(self, inputstring, document): + netlink_parser =3D NetlinkYamlParser() + + def do_parse(self, inputstring, document, msg): """Parse YAML and generate a document tree.""" =20 self.setup_parse(inputstring, document) @@ -28,14 +36,6 @@ class YamlParser(Parser): result =3D ViewList() =20 try: - # FIXME: Test logic to generate some ReST content - basename =3D os.path.basename(document.current_source) - title =3D os.path.splitext(basename)[0].replace('_', ' ').titl= e() - - msg =3D f"{title}\n" - msg +=3D "=3D" * len(title) + "\n\n" - msg +=3D "Something\n" - # Parse message with RSTParser for i, line in enumerate(msg.split('\n')): result.append(line, document.current_source, i) @@ -48,6 +48,23 @@ class YamlParser(Parser): =20 self.finish_parse() =20 + # Overrides docutils.parsers.Parser. See sphinx.parsers.RSTParser + def parse(self, inputstring, document): + """Check if a YAML is meant to be parsed.""" + + fname =3D document.current_source + + # Handle netlink yaml specs + if re.search("/netlink/specs/", fname): + if fname.endswith("index.yaml"): + msg =3D self.netlink_parser.generate_main_index_rst(fname,= None) + else: + msg =3D self.netlink_parser.parse_yaml_file(fname) + + self.do_parse(inputstring, document, msg) + + # All other yaml files are ignored + def setup(app): """Setup function for the Sphinx extension.""" =20 --=20 2.49.0