From nobody Thu Oct 9 06:50:10 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 099EB14F98; Thu, 19 Jun 2025 06:50:20 +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=1750315821; cv=none; b=ClP93R9l0xIpB6k+RmRvvAzyZsTxiX1Kr3KsMDOYwGcWmBEycP5huGk4BpnavOu5luBhUDhJSKlqOqwl+NLKjGLdH3nYENPbGDDZ19806Ai9fgsoNK8rED2qp1RblgrtM1XqTUuyypRJO80E2hXUP6VGUzO092MJVshrMHLr2Sg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750315821; c=relaxed/simple; bh=JvTI+DF/1Dszyn4T0n7ZKhi6vNtj6FoC1Ae/TMd5FHM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=I+qfVXZYT29iX4h+3j0SR4PhWQcJxwbHnBi0Jg++OjmrZQ7alQfNb2gzl5a9Lx7v5xQEybC/DTwe6rLLxS1a3yPMG8uKzDbyokQSFof2t/cbdzH9mlbrj12ugmHVeX7uEPriREMN3w6P5dVvId4q/WDGMZiflwvCCiq57FIVLpw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=G3Ias+ip; 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="G3Ias+ip" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A6FEBC4CEEF; Thu, 19 Jun 2025 06:50:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1750315820; bh=JvTI+DF/1Dszyn4T0n7ZKhi6vNtj6FoC1Ae/TMd5FHM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=G3Ias+ipf86GGwEO696BS4I3hyYvFXlxOBAGciBgQQdC+P+FTYaKXuiz7aXKqEekB 41ROxbKjmPuoKAd9tjfNgQqtOqQYazDXp6UegXPSFE0/pZ+LCyI/gFx5I1zmeq7Jr9 tA81uMylDht8q2RvATdvzBe93F4GvuVAy2Z08iAW1lF+Rb1kETwLbWk8haNy/j8Y3j 1AOV+ArwTydcOqym6NhVQx+FxNx130IYvv0gRNHa8vhMf7pqjfvRAjDx/G0jWUr1IT oAmKW6DE2sqa5wo3YM0ZLVbEgD4eP3sqO1PwNPhHlH00nh30QsotYnZb99Sbw1UkTu OgpLPizO9qIrA== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1uS96I-00000003dGa-3TSR; Thu, 19 Jun 2025 08:50:18 +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 v7 01/17] docs: conf.py: properly handle include and exclude patterns Date: Thu, 19 Jun 2025 08:48:54 +0200 Message-ID: <737b08e891765dc10bd944d4d42f8b1e37b80275.1750315578.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" When one does: make SPHINXDIRS=3D"foo" htmldocs All patterns would be relative to Documentation/foo, which causes the include/exclude patterns like: include_patterns =3D [ ... f'foo/*.{ext}', ] to break. This is not what it is expected. Address it by adding a logic to dynamically adjust the pattern when SPHINXDIRS is used. That allows adding parsers for other file types. It should be noticed that include_patterns was added on Sphinx 5.1: https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-incl= ude_patterns So, a backward-compatible code is needed when we start using it for real. Signed-off-by: Mauro Carvalho Chehab Reviewed-by: Donald Hunter --- Documentation/conf.py | 67 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 63 insertions(+), 4 deletions(-) diff --git a/Documentation/conf.py b/Documentation/conf.py index 12de52a2b17e..4ba4ee45e599 100644 --- a/Documentation/conf.py +++ b/Documentation/conf.py @@ -17,6 +17,66 @@ import os import sphinx import shutil =20 +# Get Sphinx version +major, minor, patch =3D sphinx.version_info[:3] + +# Include_patterns were added on Sphinx 5.1 +if (major < 5) or (major =3D=3D 5 and minor < 1): + has_include_patterns =3D False +else: + has_include_patterns =3D True + # Include patterns that don't contain directory names, in glob format + include_patterns =3D ['**.rst'] + +# Location of Documentation/ directory +doctree =3D os.path.abspath('.') + +# Exclude of patterns that don't contain directory names, in glob format. +exclude_patterns =3D [] + +# List of patterns that contain directory names in glob format. +dyn_include_patterns =3D [] +dyn_exclude_patterns =3D ['output'] + +# Properly handle include/exclude patterns +# ---------------------------------------- + +def update_patterns(app): + + """ + On Sphinx, all directories are relative to what it is passed as + SOURCEDIR parameter for sphinx-build. Due to that, all patterns + that have directory names on it need to be dynamically set, after + converting them to a relative patch. + + As Sphinx doesn't include any patterns outside SOURCEDIR, we should + exclude relative patterns that start with "../". + """ + + sourcedir =3D app.srcdir # full path to the source directory + builddir =3D os.environ.get("BUILDDIR") + + # setup include_patterns dynamically + if has_include_patterns: + for p in dyn_include_patterns: + full =3D os.path.join(doctree, p) + + rel_path =3D os.path.relpath(full, start =3D app.srcdir) + if rel_path.startswith("../"): + continue + + app.config.include_patterns.append(rel_path) + + # setup exclude_patterns dynamically + for p in dyn_exclude_patterns: + full =3D os.path.join(doctree, p) + + rel_path =3D os.path.relpath(full, start =3D app.srcdir) + if rel_path.startswith("../"): + continue + + app.config.exclude_patterns.append(rel_path) + # helper # ------ =20 @@ -219,10 +279,6 @@ language =3D 'en' # Else, today_fmt is used as the format for a strftime call. #today_fmt =3D '%B %d, %Y' =20 -# List of patterns, relative to source directory, that match files and -# directories to ignore when looking for source files. -exclude_patterns =3D ['output'] - # The reST default role (used for this markup: `text`) to use for all # documents. #default_role =3D None @@ -516,3 +572,6 @@ kerneldoc_srctree =3D '..' # the last statement in the conf.py file # ------------------------------------------------------------------------= ------ loadConfig(globals()) + +def setup(app): + app.connect('builder-inited', update_patterns) --=20 2.49.0 From nobody Thu Oct 9 06:50:10 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 09A8523C513; Thu, 19 Jun 2025 06:50:20 +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=1750315821; cv=none; b=bdayaJ/VlIUU0EW07sUniqC7fqqSqBSIHTEqMq3j1hcdLeh+e+KfHUAHTB0tfgu4Mu78P1gswnIMBoXQwZkVT8aBm6sp2h2hSvvRNxvgxG3pksVbFz/SzkshIs0P2yr7JEoJssCuLqGvgUyPT1SLOPgOy1fMjSY/1AMP2AYsaqI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750315821; c=relaxed/simple; bh=9sv3o8O8M0IyOR5wJkoSEusaPecRlQcEL5SoMo0iJ7A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pabstBfxszBw9PNQY+2MByzu/1bIHatVyYM8TjBc3nXbBEV+1tmfG0lwRATi0tTHyk6rUy8wYBWdoa6qiT+E550fOwH8MR5yJwJ7kx8z1A4mn7wILO5nxVmAq1kkHc8rGxAGXkX0pkPbPovRMKUTK0VAt4Fc8hnOEV/Qi18fpEo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=pbnZLsJO; 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="pbnZLsJO" Received: by smtp.kernel.org (Postfix) with ESMTPSA id ACCD4C4CEED; Thu, 19 Jun 2025 06:50:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1750315820; bh=9sv3o8O8M0IyOR5wJkoSEusaPecRlQcEL5SoMo0iJ7A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pbnZLsJOfX17tLAz7qbnLMk773IGNbYnRDyQpKMIaYSSYXx+7QT50vdx1PdbrnYDl cfgRFpMTse25+SNe+5bQP+SFsJ9Das/C6MDrUWobo5twvuIMWpUu0S1gBNQJn8AN7I ZQpEVrX7OolctvrgJ9lZ73Klhq8RqmSbu/nscz6Qn5Z1JSL0w9LxYcov8/44A4yK7r qkdNOHWZjuUbT9fHqM8NyV6MX2PPIghFatRSQp45C4u8xanw0Zn+yR3p3cIGjn3xbh 5X/29p5GSdfq+ClQ+7+IhLxnaDcH2tkMEMLKPHqBz+G7lnfmP7QZyKcqKH+DbWlrM2 NLaTMQv3RmkeQ== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1uS96I-00000003dGe-3atf; Thu, 19 Jun 2025 08:50:18 +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 v7 02/17] docs: Makefile: disable check rules on make cleandocs Date: Thu, 19 Jun 2025 08:48:55 +0200 Message-ID: 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" It doesn't make sense to check for missing ABI and documents when cleaning the tree. Signed-off-by: Mauro Carvalho Chehab Reviewed-by: Breno Leitao Reviewed-by: Donald Hunter --- Documentation/Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Documentation/Makefile b/Documentation/Makefile index d30d66ddf1ad..b98477df5ddf 100644 --- a/Documentation/Makefile +++ b/Documentation/Makefile @@ -5,6 +5,7 @@ # for cleaning subdir- :=3D devicetree/bindings =20 +ifneq ($(MAKECMDGOALS),cleandocs) # Check for broken documentation file references ifeq ($(CONFIG_WARN_MISSING_DOCUMENTS),y) $(shell $(srctree)/scripts/documentation-file-ref-check --warn) @@ -14,6 +15,7 @@ endif ifeq ($(CONFIG_WARN_ABI_ERRORS),y) $(shell $(srctree)/scripts/get_abi.py --dir $(srctree)/Documentation/ABI v= alidate) endif +endif =20 # You can set these variables from the command line. SPHINXBUILD =3D sphinx-build --=20 2.49.0 From nobody Thu Oct 9 06:50:10 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 09B59242D81; Thu, 19 Jun 2025 06:50:20 +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=1750315821; cv=none; b=oOLntwgWsubP6DPizx9+g9FViQqgr2APr2vbiDkXgCAW1X4G5sDHBhzFmow7SicRJHnRFVT16O9i43pzqsZbBdnJWZt8Yw6xTvXSILzMzNRKIZhirx2wE/b/12M9g8vNOs3yzz8Ld+2VTUKKDiHoRnCwuhIuqZyQJMH30g1+2nc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750315821; c=relaxed/simple; bh=MZJWqI3Ttw/muYCtmcZ8ZV0+firnnb8VF0+QvKwQ1QU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cr0mUFHEqIPM0UpoZ2tPId8kBrIEs/tOfSdAtfPNAdfuKEKmdYwC3zPowr/ZJ1hL+2Lfuw8xbZW/bq4fta9kcrzJll53pkk7b33jXoxUsBqRCD+DTEbFHRJEfQeMZTQFl/YvcYAUg9KgYEHBu+Wum/8my+L3mTYMaTA79eAaUec= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=H9fTX6OE; 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="H9fTX6OE" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9F505C4CEEA; Thu, 19 Jun 2025 06:50:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1750315820; bh=MZJWqI3Ttw/muYCtmcZ8ZV0+firnnb8VF0+QvKwQ1QU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=H9fTX6OEZXvQVBkITyfqwB9AFcpmsWVPHCA4sk9G2tfxQiNfvdh954ZZN4J5L2Jbd k30SUED0wE4DV4VN0ubXR54vm5DxahOtiKp3DRYDE9b0vmWf4UfkbhCqVhjYIrJIBS JdIPMWxio7H21L2w9dCv4eX9aTIiCZaUXjc53xcUvduwOGw46qzTDhm5uqF433plLd gmLkdCEOpMW3L07wV8lt3Xcu+jC6B7xsvddDE/x4BRg8072pFw2NZASOOOoU01P8vo JmuBdv85epNM3NXjs0YDFwVIyUgOK9hlLFlpJDyirImPwzLnpBk9+nsKn+lDOxTHnG lABTPBbLAU4Zw== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1uS96I-00000003dGj-3icu; Thu, 19 Jun 2025 08:50:18 +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" , Jakub Kicinski , Simon Horman , 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 v7 03/17] docs: netlink: netlink-raw.rst: use :ref: instead of :doc: Date: Thu, 19 Jun 2025 08:48:56 +0200 Message-ID: <205e2b0baddabf47ab23ed08fbddd3fdc0cdcc58.1750315578.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" Currently, rt documents are referred with: Documentation/userspace-api/netlink/netlink-raw.rst: :doc:`rt-link<../../ne= tworking/netlink_spec/rt-link>` Documentation/userspace-api/netlink/netlink-raw.rst: :doc:`tc<../../network= ing/netlink_spec/tc>` Documentation/userspace-api/netlink/netlink-raw.rst: :doc:`tc<../../network= ing/netlink_spec/tc>` Having :doc: references with relative paths doesn't always work, as it may have troubles when O=3D is used. Also that's hard to maintain, and may break if we change the way rst files are generated from yaml. Better to use instead a reference for the netlink family. So, replace them by Sphinx cross-reference tag that are created by ynl_gen_rst.py. Signed-off-by: Mauro Carvalho Chehab Reviewed-by: Donald Hunter --- Documentation/userspace-api/netlink/netlink-raw.rst | 6 +++--- tools/net/ynl/pyynl/ynl_gen_rst.py | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Documentation/userspace-api/netlink/netlink-raw.rst b/Document= ation/userspace-api/netlink/netlink-raw.rst index 31fc91020eb3..aae296c170c5 100644 --- a/Documentation/userspace-api/netlink/netlink-raw.rst +++ b/Documentation/userspace-api/netlink/netlink-raw.rst @@ -62,8 +62,8 @@ Sub-messages ------------ =20 Several raw netlink families such as -:doc:`rt-link<../../networking/netlink_spec/rt-link>` and -:doc:`tc<../../networking/netlink_spec/tc>` use attribute nesting as an +:ref:`rt-link` and +:ref:`tc` use attribute nesting as an abstraction to carry module specific information. =20 Conceptually it looks as follows:: @@ -162,7 +162,7 @@ then this is an error. Nested struct definitions ------------------------- =20 -Many raw netlink families such as :doc:`tc<../../networking/netlink_spec/t= c>` +Many raw netlink families such as :ref:`tc` make use of nested struct definitions. The ``netlink-raw`` schema makes it possible to embed a struct within a struct definition using the ``struct`` property. For example, the following struct definition embeds the diff --git a/tools/net/ynl/pyynl/ynl_gen_rst.py b/tools/net/ynl/pyynl/ynl_g= en_rst.py index 0cb6348e28d3..7bfb8ceeeefc 100755 --- a/tools/net/ynl/pyynl/ynl_gen_rst.py +++ b/tools/net/ynl/pyynl/ynl_gen_rst.py @@ -314,10 +314,11 @@ def parse_yaml(obj: Dict[str, Any]) -> str: =20 # Main header =20 - lines.append(rst_header()) - family =3D obj['name'] =20 + lines.append(rst_header()) + lines.append(rst_label("netlink-" + family)) + title =3D f"Family ``{family}`` netlink specification" lines.append(rst_title(title)) lines.append(rst_paragraph(".. contents:: :depth: 3\n")) --=20 2.49.0 From nobody Thu Oct 9 06:50:10 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 A75762586C8; Thu, 19 Jun 2025 06:50:21 +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=1750315821; cv=none; b=XJtP+Luqc5iwheOMUFHskeo0oh8NkjRuuXnxLO5rkoxjsZK639VnKWnfYtrdWKeAxXthX7dd2Nf1VhdXtCyYa6AqAjVFa8YW2cepAtIoU9X0lszIRWm2Pdkxt5pN/oJZBfm9m7/TfQt7PF9cFq7MCUM+T0B0n4eHr4xYuAHPRxM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750315821; c=relaxed/simple; bh=ILMkIMZRBVquHVA7G08AHG7My5iKhrMAj1qGVO2Pimg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iH1hVdjufvz2M/2FwkhotmIu6TDbJg+hTfevI1sek0EEBhO6iLNmxTf1r/mUmQoO7oIkdH7jH7PAdffZwALILbOEmGZ1qsdvDOhbgwMBdvYaZmPnhO6ev67qVnN5/d3jw1+1xKiMPmZKlfQ9Y/xDeGB5hRCk3xLsZYXllU3gWcg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gvi+XkxJ; 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="gvi+XkxJ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B7808C4CEF2; Thu, 19 Jun 2025 06:50:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1750315821; bh=ILMkIMZRBVquHVA7G08AHG7My5iKhrMAj1qGVO2Pimg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gvi+XkxJx9NyjWH4FQuYyxCXsxOPIRBMeVLIsvasylQIsXH0LDKGZoWNdN27fTeNn D/EUm2uleq384bGoGISxwyxwR0Q9MlU1aEL/C1sT7cEOcZQL2du879XTT7FmU/6Ya4 RcBo5O464qnhod6UyWxD63xCE5gw1pIeI/QrW4g+SQW92ZsTPox/SnWmAgeeTrOv7o Ixy5PraOEAatiieJQ1zaLmPtc4tEa2+k+cTekgH2dyc0kPqIWoDg2cLJ6OpajI47py GOlAoWjch2aBw8NtiO1Svf0wkKb1wDcHliTTO8PL175u7JPg0qvAnuHgKrUTQ6Ktfl hnxNnaRJjSp3g== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1uS96I-00000003dGn-3qnu; Thu, 19 Jun 2025 08:50:18 +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" , Jakub Kicinski , Simon Horman , 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 v7 04/17] tools: ynl_gen_rst.py: Split library from command line tool Date: Thu, 19 Jun 2025 08:48:57 +0200 Message-ID: <4e26583ad1d8a05ba40cada4213c95120bd45efc.1750315578.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" As we'll be using the Netlink specs parser inside a Sphinx extension, move the library part from the command line parser. No functional changes. Signed-off-by: Mauro Carvalho Chehab --- tools/net/ynl/pyynl/lib/__init__.py | 2 + tools/net/ynl/pyynl/lib/doc_generator.py | 409 +++++++++++++++++++++++ tools/net/ynl/pyynl/ynl_gen_rst.py | 361 +------------------- 3 files changed, 419 insertions(+), 353 deletions(-) create mode 100644 tools/net/ynl/pyynl/lib/doc_generator.py diff --git a/tools/net/ynl/pyynl/lib/__init__.py b/tools/net/ynl/pyynl/lib/= __init__.py index 71518b9842ee..5f266ebe4526 100644 --- a/tools/net/ynl/pyynl/lib/__init__.py +++ b/tools/net/ynl/pyynl/lib/__init__.py @@ -4,6 +4,8 @@ from .nlspec import SpecAttr, SpecAttrSet, SpecEnumEntry, S= pecEnumSet, \ SpecFamily, SpecOperation, SpecSubMessage, SpecSubMessageFormat from .ynl import YnlFamily, Netlink, NlError =20 +from .doc_generator import YnlDocGenerator + __all__ =3D ["SpecAttr", "SpecAttrSet", "SpecEnumEntry", "SpecEnumSet", "SpecFamily", "SpecOperation", "SpecSubMessage", "SpecSubMessag= eFormat", "YnlFamily", "Netlink", "NlError"] diff --git a/tools/net/ynl/pyynl/lib/doc_generator.py b/tools/net/ynl/pyynl= /lib/doc_generator.py new file mode 100644 index 000000000000..839e78b39de3 --- /dev/null +++ b/tools/net/ynl/pyynl/lib/doc_generator.py @@ -0,0 +1,409 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-2.0 +# -*- coding: utf-8; mode: python -*- + +""" + Class to auto generate the documentation for Netlink specifications. + + :copyright: Copyright (C) 2023 Breno Leitao + :license: GPL Version 2, June 1991 see linux/COPYING for details. + + This class performs extensive parsing to the Linux kernel's netlink YA= ML + spec files, in an effort to avoid needing to heavily mark up the origi= nal + YAML file. + + This code is split in two classes: + 1) RST formatters: Use to convert a string to a RST output + 2) YAML Netlink (YNL) doc generator: Generate docs from YAML data +""" + +from typing import Any, Dict, List +import os.path +import sys +import argparse +import logging +import yaml + + +# =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +# RST Formatters +# =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +class RstFormatters: + SPACE_PER_LEVEL =3D 4 + + @staticmethod + def headroom(level: int) -> str: + """Return space to format""" + return " " * (level * RstFormatters.SPACE_PER_LEVEL) + + + @staticmethod + def bold(text: str) -> str: + """Format bold text""" + return f"**{text}**" + + + @staticmethod + def inline(text: str) -> str: + """Format inline text""" + return f"``{text}``" + + + @staticmethod + def sanitize(text: str) -> str: + """Remove newlines and multiple spaces""" + # This is useful for some fields that are spread across multiple l= ines + return str(text).replace("\n", " ").strip() + + + def rst_fields(self, key: str, value: str, level: int =3D 0) -> str: + """Return a RST formatted field""" + return self.headroom(level) + f":{key}: {value}" + + + def rst_definition(self, key: str, value: Any, level: int =3D 0) -> st= r: + """Format a single rst definition""" + return self.headroom(level) + key + "\n" + self.headroom(level + 1= ) + str(value) + + + def rst_paragraph(self, paragraph: str, level: int =3D 0) -> str: + """Return a formatted paragraph""" + return self.headroom(level) + paragraph + + + def rst_bullet(self, item: str, level: int =3D 0) -> str: + """Return a formatted a bullet""" + return self.headroom(level) + f"- {item}" + + + @staticmethod + def rst_subsection(title: str) -> str: + """Add a sub-section to the document""" + return f"{title}\n" + "-" * len(title) + + + @staticmethod + def rst_subsubsection(title: str) -> str: + """Add a sub-sub-section to the document""" + return f"{title}\n" + "~" * len(title) + + + @staticmethod + def rst_section(namespace: str, prefix: str, title: str) -> str: + """Add a section to the document""" + return f".. _{namespace}-{prefix}-{title}:\n\n{title}\n" + "=3D" *= len(title) + + + @staticmethod + def rst_subtitle(title: str) -> str: + """Add a subtitle to the document""" + return "\n" + "-" * len(title) + f"\n{title}\n" + "-" * len(title)= + "\n\n" + + + @staticmethod + def rst_title(title: str) -> str: + """Add a title to the document""" + return "=3D" * len(title) + f"\n{title}\n" + "=3D" * len(title) + = "\n\n" + + + def rst_list_inline(self, list_: List[str], level: int =3D 0) -> str: + """Format a list using inlines""" + return self.headroom(level) + "[" + ", ".join(self.inline(i) for i= in list_) + "]" + + + @staticmethod + def rst_ref(namespace: str, prefix: str, name: str) -> str: + """Add a hyperlink to the document""" + mappings =3D {'enum': 'definition', + 'fixed-header': 'definition', + 'nested-attributes': 'attribute-set', + 'struct': 'definition'} + if prefix in mappings: + prefix =3D mappings[prefix] + return f":ref:`{namespace}-{prefix}-{name}`" + + + def rst_header(self) -> str: + """The headers for all the auto generated RST files""" + lines =3D [] + + lines.append(self.rst_paragraph(".. SPDX-License-Identifier: GPL-2= .0")) + lines.append(self.rst_paragraph(".. NOTE: This document was auto-g= enerated.\n\n")) + + return "\n".join(lines) + + + @staticmethod + def rst_toctree(maxdepth: int =3D 2) -> str: + """Generate a toctree RST primitive""" + lines =3D [] + + lines.append(".. toctree::") + lines.append(f" :maxdepth: {maxdepth}\n\n") + + return "\n".join(lines) + + + @staticmethod + def rst_label(title: str) -> str: + """Return a formatted label""" + return f".. _{title}:\n\n" + +# =3D=3D=3D=3D=3D=3D=3D +# Parsers +# =3D=3D=3D=3D=3D=3D=3D +class YnlDocGenerator: + + fmt =3D RstFormatters() + + def parse_mcast_group(self, mcast_group: List[Dict[str, Any]]) -> str: + """Parse 'multicast' group list and return a formatted string""" + lines =3D [] + for group in mcast_group: + lines.append(self.fmt.rst_bullet(group["name"])) + + return "\n".join(lines) + + + def parse_do(self, do_dict: Dict[str, Any], level: int =3D 0) -> str: + """Parse 'do' section and return a formatted string""" + lines =3D [] + for key in do_dict.keys(): + lines.append(self.fmt.rst_paragraph(self.fmt.bold(key), level = + 1)) + if key in ['request', 'reply']: + lines.append(self.parse_do_attributes(do_dict[key], level = + 1) + "\n") + else: + lines.append(self.fmt.headroom(level + 2) + do_dict[key] += "\n") + + return "\n".join(lines) + + + def parse_do_attributes(self, attrs: Dict[str, Any], level: int =3D 0)= -> str: + """Parse 'attributes' section""" + if "attributes" not in attrs: + return "" + lines =3D [self.fmt.rst_fields("attributes", self.fmt.rst_list_inl= ine(attrs["attributes"]), level + 1)] + + return "\n".join(lines) + + + def parse_operations(self, operations: List[Dict[str, Any]], namespace= : str) -> str: + """Parse operations block""" + preprocessed =3D ["name", "doc", "title", "do", "dump", "flags"] + linkable =3D ["fixed-header", "attribute-set"] + lines =3D [] + + for operation in operations: + lines.append(self.fmt.rst_section(namespace, 'operation', oper= ation["name"])) + lines.append(self.fmt.rst_paragraph(operation["doc"]) + "\n") + + for key in operation.keys(): + if key in preprocessed: + # Skip the special fields + continue + value =3D operation[key] + if key in linkable: + value =3D self.fmt.rst_ref(namespace, key, value) + lines.append(self.fmt.rst_fields(key, value, 0)) + if 'flags' in operation: + lines.append(self.fmt.rst_fields('flags', self.fmt.rst_lis= t_inline(operation['flags']))) + + if "do" in operation: + lines.append(self.fmt.rst_paragraph(":do:", 0)) + lines.append(self.parse_do(operation["do"], 0)) + if "dump" in operation: + lines.append(self.fmt.rst_paragraph(":dump:", 0)) + lines.append(self.parse_do(operation["dump"], 0)) + + # New line after fields + lines.append("\n") + + return "\n".join(lines) + + + def parse_entries(self, entries: List[Dict[str, Any]], level: int) -> = str: + """Parse a list of entries""" + ignored =3D ["pad"] + lines =3D [] + for entry in entries: + if isinstance(entry, dict): + # entries could be a list or a dictionary + field_name =3D entry.get("name", "") + if field_name in ignored: + continue + type_ =3D entry.get("type") + if type_: + field_name +=3D f" ({self.fmt.inline(type_)})" + lines.append( + self.fmt.rst_fields(field_name, self.fmt.sanitize(entr= y.get("doc", "")), level) + ) + elif isinstance(entry, list): + lines.append(self.fmt.rst_list_inline(entry, level)) + else: + lines.append(self.fmt.rst_bullet(self.fmt.inline(self.fmt.= sanitize(entry)), level)) + + lines.append("\n") + return "\n".join(lines) + + + def parse_definitions(self, defs: Dict[str, Any], namespace: str) -> s= tr: + """Parse definitions section""" + preprocessed =3D ["name", "entries", "members"] + ignored =3D ["render-max"] # This is not printed + lines =3D [] + + for definition in defs: + lines.append(self.fmt.rst_section(namespace, 'definition', def= inition["name"])) + for k in definition.keys(): + if k in preprocessed + ignored: + continue + lines.append(self.fmt.rst_fields(k, self.fmt.sanitize(defi= nition[k]), 0)) + + # Field list needs to finish with a new line + lines.append("\n") + if "entries" in definition: + lines.append(self.fmt.rst_paragraph(":entries:", 0)) + lines.append(self.parse_entries(definition["entries"], 1)) + if "members" in definition: + lines.append(self.fmt.rst_paragraph(":members:", 0)) + lines.append(self.parse_entries(definition["members"], 1)) + + return "\n".join(lines) + + + def parse_attr_sets(self, entries: List[Dict[str, Any]], namespace: st= r) -> str: + """Parse attribute from attribute-set""" + preprocessed =3D ["name", "type"] + linkable =3D ["enum", "nested-attributes", "struct", "sub-message"] + ignored =3D ["checks"] + lines =3D [] + + for entry in entries: + lines.append(self.fmt.rst_section(namespace, 'attribute-set', = entry["name"])) + for attr in entry["attributes"]: + type_ =3D attr.get("type") + attr_line =3D attr["name"] + if type_: + # Add the attribute type in the same line + attr_line +=3D f" ({self.fmt.inline(type_)})" + + lines.append(self.fmt.rst_subsubsection(attr_line)) + + for k in attr.keys(): + if k in preprocessed + ignored: + continue + if k in linkable: + value =3D self.fmt.rst_ref(namespace, k, attr[k]) + else: + value =3D self.fmt.sanitize(attr[k]) + lines.append(self.fmt.rst_fields(k, value, 0)) + lines.append("\n") + + return "\n".join(lines) + + + def parse_sub_messages(self, entries: List[Dict[str, Any]], namespace:= str) -> str: + """Parse sub-message definitions""" + lines =3D [] + + for entry in entries: + lines.append(self.fmt.rst_section(namespace, 'sub-message', en= try["name"])) + for fmt in entry["formats"]: + value =3D fmt["value"] + + lines.append(self.fmt.rst_bullet(self.fmt.bold(value))) + for attr in ['fixed-header', 'attribute-set']: + if attr in fmt: + lines.append(self.fmt.rst_fields(attr, + self.fmt.rst_ref(namespace= , attr, fmt[attr]), + 1)) + lines.append("\n") + + return "\n".join(lines) + + + def parse_yaml(self, obj: Dict[str, Any]) -> str: + """Format the whole YAML into a RST string""" + lines =3D [] + + # Main header + + family =3D obj['name'] + + lines.append(self.fmt.rst_header()) + lines.append(self.fmt.rst_label("netlink-" + family)) + + title =3D f"Family ``{family}`` netlink specification" + lines.append(self.fmt.rst_title(title)) + lines.append(self.fmt.rst_paragraph(".. contents:: :depth: 3\n")) + + if "doc" in obj: + lines.append(self.fmt.rst_subtitle("Summary")) + lines.append(self.fmt.rst_paragraph(obj["doc"], 0)) + + # Operations + if "operations" in obj: + lines.append(self.fmt.rst_subtitle("Operations")) + lines.append(self.parse_operations(obj["operations"]["list"], = family)) + + # Multicast groups + if "mcast-groups" in obj: + lines.append(self.fmt.rst_subtitle("Multicast groups")) + lines.append(self.parse_mcast_group(obj["mcast-groups"]["list"= ])) + + # Definitions + if "definitions" in obj: + lines.append(self.fmt.rst_subtitle("Definitions")) + lines.append(self.parse_definitions(obj["definitions"], family= )) + + # Attributes set + if "attribute-sets" in obj: + lines.append(self.fmt.rst_subtitle("Attribute sets")) + lines.append(self.parse_attr_sets(obj["attribute-sets"], famil= y)) + + # Sub-messages + if "sub-messages" in obj: + lines.append(self.fmt.rst_subtitle("Sub-messages")) + lines.append(self.parse_sub_messages(obj["sub-messages"], fami= ly)) + + return "\n".join(lines) + + + # Main functions + # =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + + + def parse_yaml_file(self, filename: str) -> str: + """Transform the YAML specified by filename into an RST-formatted = string""" + with open(filename, "r", encoding=3D"utf-8") as spec_file: + yaml_data =3D yaml.safe_load(spec_file) + content =3D self.parse_yaml(yaml_data) + + return content + + + def generate_main_index_rst(self, output: str, index_dir: str) -> None: + """Generate the `networking_spec/index` content and write to the f= ile""" + lines =3D [] + + lines.append(self.fmt.rst_header()) + lines.append(self.fmt.rst_label("specs")) + lines.append(self.fmt.rst_title("Netlink Family Specifications")) + lines.append(self.fmt.rst_toctree(1)) + + index_fname =3D os.path.basename(output) + base, ext =3D os.path.splitext(index_fname) + + if not index_dir: + index_dir =3D os.path.dirname(output) + + logging.debug(f"Looking for {ext} files in %s", index_dir) + for filename in sorted(os.listdir(index_dir)): + if not filename.endswith(ext) or filename =3D=3D index_fname: + continue + base, ext =3D os.path.splitext(filename) + lines.append(f" {base}\n") + + logging.debug("Writing an index file at %s", output) + + return "".join(lines) diff --git a/tools/net/ynl/pyynl/ynl_gen_rst.py b/tools/net/ynl/pyynl/ynl_g= en_rst.py index 7bfb8ceeeefc..b5a665eeaa5a 100755 --- a/tools/net/ynl/pyynl/ynl_gen_rst.py +++ b/tools/net/ynl/pyynl/ynl_gen_rst.py @@ -10,354 +10,17 @@ =20 This script performs extensive parsing to the Linux kernel's netlink Y= AML spec files, in an effort to avoid needing to heavily mark up the origi= nal - YAML file. - - This code is split in three big parts: - 1) RST formatters: Use to convert a string to a RST output - 2) Parser helpers: Functions to parse the YAML data structure - 3) Main function and small helpers + YAML file. It uses the library code from scripts/lib. """ =20 -from typing import Any, Dict, List import os.path +import pathlib import sys import argparse import logging -import yaml - - -SPACE_PER_LEVEL =3D 4 - - -# RST Formatters -# =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D -def headroom(level: int) -> str: - """Return space to format""" - return " " * (level * SPACE_PER_LEVEL) - - -def bold(text: str) -> str: - """Format bold text""" - return f"**{text}**" - - -def inline(text: str) -> str: - """Format inline text""" - return f"``{text}``" - - -def sanitize(text: str) -> str: - """Remove newlines and multiple spaces""" - # This is useful for some fields that are spread across multiple lines - return str(text).replace("\n", " ").strip() - - -def rst_fields(key: str, value: str, level: int =3D 0) -> str: - """Return a RST formatted field""" - return headroom(level) + f":{key}: {value}" - - -def rst_definition(key: str, value: Any, level: int =3D 0) -> str: - """Format a single rst definition""" - return headroom(level) + key + "\n" + headroom(level + 1) + str(value) - - -def rst_paragraph(paragraph: str, level: int =3D 0) -> str: - """Return a formatted paragraph""" - return headroom(level) + paragraph - - -def rst_bullet(item: str, level: int =3D 0) -> str: - """Return a formatted a bullet""" - return headroom(level) + f"- {item}" - - -def rst_subsection(title: str) -> str: - """Add a sub-section to the document""" - return f"{title}\n" + "-" * len(title) - - -def rst_subsubsection(title: str) -> str: - """Add a sub-sub-section to the document""" - return f"{title}\n" + "~" * len(title) - - -def rst_section(namespace: str, prefix: str, title: str) -> str: - """Add a section to the document""" - return f".. _{namespace}-{prefix}-{title}:\n\n{title}\n" + "=3D" * len= (title) - - -def rst_subtitle(title: str) -> str: - """Add a subtitle to the document""" - return "\n" + "-" * len(title) + f"\n{title}\n" + "-" * len(title) + "= \n\n" - - -def rst_title(title: str) -> str: - """Add a title to the document""" - return "=3D" * len(title) + f"\n{title}\n" + "=3D" * len(title) + "\n\= n" - - -def rst_list_inline(list_: List[str], level: int =3D 0) -> str: - """Format a list using inlines""" - return headroom(level) + "[" + ", ".join(inline(i) for i in list_) + "= ]" - - -def rst_ref(namespace: str, prefix: str, name: str) -> str: - """Add a hyperlink to the document""" - mappings =3D {'enum': 'definition', - 'fixed-header': 'definition', - 'nested-attributes': 'attribute-set', - 'struct': 'definition'} - if prefix in mappings: - prefix =3D mappings[prefix] - return f":ref:`{namespace}-{prefix}-{name}`" - - -def rst_header() -> str: - """The headers for all the auto generated RST files""" - lines =3D [] - - lines.append(rst_paragraph(".. SPDX-License-Identifier: GPL-2.0")) - lines.append(rst_paragraph(".. NOTE: This document was auto-generated.= \n\n")) - - return "\n".join(lines) - - -def rst_toctree(maxdepth: int =3D 2) -> str: - """Generate a toctree RST primitive""" - lines =3D [] - - lines.append(".. toctree::") - lines.append(f" :maxdepth: {maxdepth}\n\n") - - return "\n".join(lines) - - -def rst_label(title: str) -> str: - """Return a formatted label""" - return f".. _{title}:\n\n" - - -# Parsers -# =3D=3D=3D=3D=3D=3D=3D - - -def parse_mcast_group(mcast_group: List[Dict[str, Any]]) -> str: - """Parse 'multicast' group list and return a formatted string""" - lines =3D [] - for group in mcast_group: - lines.append(rst_bullet(group["name"])) - - return "\n".join(lines) - - -def parse_do(do_dict: Dict[str, Any], level: int =3D 0) -> str: - """Parse 'do' section and return a formatted string""" - lines =3D [] - for key in do_dict.keys(): - lines.append(rst_paragraph(bold(key), level + 1)) - if key in ['request', 'reply']: - lines.append(parse_do_attributes(do_dict[key], level + 1) + "\= n") - else: - lines.append(headroom(level + 2) + do_dict[key] + "\n") - - return "\n".join(lines) - - -def parse_do_attributes(attrs: Dict[str, Any], level: int =3D 0) -> str: - """Parse 'attributes' section""" - if "attributes" not in attrs: - return "" - lines =3D [rst_fields("attributes", rst_list_inline(attrs["attributes"= ]), level + 1)] - - return "\n".join(lines) - - -def parse_operations(operations: List[Dict[str, Any]], namespace: str) -> = str: - """Parse operations block""" - preprocessed =3D ["name", "doc", "title", "do", "dump", "flags"] - linkable =3D ["fixed-header", "attribute-set"] - lines =3D [] - - for operation in operations: - lines.append(rst_section(namespace, 'operation', operation["name"]= )) - lines.append(rst_paragraph(operation["doc"]) + "\n") - - for key in operation.keys(): - if key in preprocessed: - # Skip the special fields - continue - value =3D operation[key] - if key in linkable: - value =3D rst_ref(namespace, key, value) - lines.append(rst_fields(key, value, 0)) - if 'flags' in operation: - lines.append(rst_fields('flags', rst_list_inline(operation['fl= ags']))) - - if "do" in operation: - lines.append(rst_paragraph(":do:", 0)) - lines.append(parse_do(operation["do"], 0)) - if "dump" in operation: - lines.append(rst_paragraph(":dump:", 0)) - lines.append(parse_do(operation["dump"], 0)) - - # New line after fields - lines.append("\n") - - return "\n".join(lines) - - -def parse_entries(entries: List[Dict[str, Any]], level: int) -> str: - """Parse a list of entries""" - ignored =3D ["pad"] - lines =3D [] - for entry in entries: - if isinstance(entry, dict): - # entries could be a list or a dictionary - field_name =3D entry.get("name", "") - if field_name in ignored: - continue - type_ =3D entry.get("type") - if type_: - field_name +=3D f" ({inline(type_)})" - lines.append( - rst_fields(field_name, sanitize(entry.get("doc", "")), lev= el) - ) - elif isinstance(entry, list): - lines.append(rst_list_inline(entry, level)) - else: - lines.append(rst_bullet(inline(sanitize(entry)), level)) - - lines.append("\n") - return "\n".join(lines) - - -def parse_definitions(defs: Dict[str, Any], namespace: str) -> str: - """Parse definitions section""" - preprocessed =3D ["name", "entries", "members"] - ignored =3D ["render-max"] # This is not printed - lines =3D [] - - for definition in defs: - lines.append(rst_section(namespace, 'definition', definition["name= "])) - for k in definition.keys(): - if k in preprocessed + ignored: - continue - lines.append(rst_fields(k, sanitize(definition[k]), 0)) - - # Field list needs to finish with a new line - lines.append("\n") - if "entries" in definition: - lines.append(rst_paragraph(":entries:", 0)) - lines.append(parse_entries(definition["entries"], 1)) - if "members" in definition: - lines.append(rst_paragraph(":members:", 0)) - lines.append(parse_entries(definition["members"], 1)) - - return "\n".join(lines) - - -def parse_attr_sets(entries: List[Dict[str, Any]], namespace: str) -> str: - """Parse attribute from attribute-set""" - preprocessed =3D ["name", "type"] - linkable =3D ["enum", "nested-attributes", "struct", "sub-message"] - ignored =3D ["checks"] - lines =3D [] - - for entry in entries: - lines.append(rst_section(namespace, 'attribute-set', entry["name"]= )) - for attr in entry["attributes"]: - type_ =3D attr.get("type") - attr_line =3D attr["name"] - if type_: - # Add the attribute type in the same line - attr_line +=3D f" ({inline(type_)})" - - lines.append(rst_subsubsection(attr_line)) - - for k in attr.keys(): - if k in preprocessed + ignored: - continue - if k in linkable: - value =3D rst_ref(namespace, k, attr[k]) - else: - value =3D sanitize(attr[k]) - lines.append(rst_fields(k, value, 0)) - lines.append("\n") - - return "\n".join(lines) - - -def parse_sub_messages(entries: List[Dict[str, Any]], namespace: str) -> s= tr: - """Parse sub-message definitions""" - lines =3D [] - - for entry in entries: - lines.append(rst_section(namespace, 'sub-message', entry["name"])) - for fmt in entry["formats"]: - value =3D fmt["value"] - - lines.append(rst_bullet(bold(value))) - for attr in ['fixed-header', 'attribute-set']: - if attr in fmt: - lines.append(rst_fields(attr, - rst_ref(namespace, attr, fmt[a= ttr]), - 1)) - lines.append("\n") - - return "\n".join(lines) - - -def parse_yaml(obj: Dict[str, Any]) -> str: - """Format the whole YAML into a RST string""" - lines =3D [] - - # Main header - - family =3D obj['name'] - - lines.append(rst_header()) - lines.append(rst_label("netlink-" + family)) - - title =3D f"Family ``{family}`` netlink specification" - lines.append(rst_title(title)) - lines.append(rst_paragraph(".. contents:: :depth: 3\n")) - - if "doc" in obj: - lines.append(rst_subtitle("Summary")) - lines.append(rst_paragraph(obj["doc"], 0)) - - # Operations - if "operations" in obj: - lines.append(rst_subtitle("Operations")) - lines.append(parse_operations(obj["operations"]["list"], family)) - - # Multicast groups - if "mcast-groups" in obj: - lines.append(rst_subtitle("Multicast groups")) - lines.append(parse_mcast_group(obj["mcast-groups"]["list"])) - - # Definitions - if "definitions" in obj: - lines.append(rst_subtitle("Definitions")) - lines.append(parse_definitions(obj["definitions"], family)) - - # Attributes set - if "attribute-sets" in obj: - lines.append(rst_subtitle("Attribute sets")) - lines.append(parse_attr_sets(obj["attribute-sets"], family)) - - # Sub-messages - if "sub-messages" in obj: - lines.append(rst_subtitle("Sub-messages")) - lines.append(parse_sub_messages(obj["sub-messages"], family)) - - return "\n".join(lines) - - -# Main functions -# =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 +sys.path.append(pathlib.Path(__file__).resolve().parent.as_posix()) +from lib import YnlDocGenerator # pylint: disable=3DC0413 =20 def parse_arguments() -> argparse.Namespace: """Parse arguments from user""" @@ -392,15 +55,6 @@ def parse_arguments() -> argparse.Namespace: return args =20 =20 -def parse_yaml_file(filename: str) -> str: - """Transform the YAML specified by filename into an RST-formatted stri= ng""" - with open(filename, "r", encoding=3D"utf-8") as spec_file: - yaml_data =3D yaml.safe_load(spec_file) - content =3D parse_yaml(yaml_data) - - return content - - def write_to_rstfile(content: str, filename: str) -> None: """Write the generated content into an RST file""" logging.debug("Saving RST file to %s", filename) @@ -411,7 +65,6 @@ def write_to_rstfile(content: str, filename: str) -> Non= e: =20 def generate_main_index_rst(output: str) -> None: """Generate the `networking_spec/index` content and write to the file"= "" - lines =3D [] =20 lines.append(rst_header()) lines.append(rst_label("specs")) @@ -426,7 +79,7 @@ def generate_main_index_rst(output: str) -> None: lines.append(f" {filename.replace('.rst', '')}\n") =20 logging.debug("Writing an index file at %s", output) - write_to_rstfile("".join(lines), output) + write_to_rstfile(msg, output) =20 =20 def main() -> None: @@ -434,10 +87,12 @@ def main() -> None: =20 args =3D parse_arguments() =20 + parser =3D YnlDocGenerator() + if args.input: logging.debug("Parsing %s", args.input) try: - content =3D parse_yaml_file(os.path.join(args.input)) + content =3D parser.parse_yaml_file(os.path.join(args.input)) except Exception as exception: logging.warning("Failed to parse %s.", args.input) logging.warning(exception) --=20 2.49.0 From nobody Thu Oct 9 06:50:10 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 60E01248F7B; Thu, 19 Jun 2025 06:50:20 +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=1750315821; cv=none; b=T6LR11tBcFESwDUOTkBPYrSjf2/d8wDsdEq9vHHCvkazLReOsKxDor4AHRygoRpIeh//t1hYGICmhp1hox7S7afSfjtg8aEFizyTUvSYxywbqQusO55gZ8dVdZ3eF+G9DZDC5Hy8ZQui2i/h5eZJ/QQlYuO9/4KRQv402nrZrec= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750315821; c=relaxed/simple; bh=Hv3gLw50JLGG5g7ccl776oKGKqF7lxHBB7tVJrn/eaQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hHhX4v8g/zxV0+ZmWYY4LNXv9u2KsZgGFLRcNER9mAlm/X6JyXRf9rbnwkFc1NIC0zz7He5b5yJShcitT6+B+LMWenIht0DeEP+Ur+9YvtWwhs93EVh44yjUq/myXGw3OdJGSrEoG7Nxfhha4DR8Kfj8zdySzhrBPSzv+b6mc5w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Z1lC77v1; 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="Z1lC77v1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BEB0DC4CEF4; Thu, 19 Jun 2025 06:50:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1750315820; bh=Hv3gLw50JLGG5g7ccl776oKGKqF7lxHBB7tVJrn/eaQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z1lC77v1CMyMlktOJ9K6fejaPpT04fOC4Le879dTqXFAifbtZk3KRi6MKQ5XlEPow 4lqWFgJFjeImFQ4tHd1d6EBdeLe4WwDhT+Y5ShpfGuDn+/B6ln/JXpqejMTKC6JE4U HLaFGIVlrS5p+nO9YQVpcZRTGVqoQIv2onKEup31ieUOmCs1SgSvSDQVOI6yfx0RpA Y/cotgB3LUCyCVw/9X+KnWIDWcqYyA7KcMHhJdYOQZ1eV6AxqqRaLuPkdhekRDDt1/ Ov5YWqFD4nk+JKT0zsCmRngpO/qxkXkRb6qpNj2qNKVDfh1e2p6y2mpvWtDF/XiHb9 afd9EMrgl86wg== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1uS96I-00000003dGq-3yTM; Thu, 19 Jun 2025 08:50:18 +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" , Jakub Kicinski , Simon Horman , 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 v7 05/17] docs: netlink: index.rst: add a netlink index file Date: Thu, 19 Jun 2025 08:48:58 +0200 Message-ID: <468efe892aecc585288a3fcdbecc1db7d4871196.1750315578.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" Instead of generating the index file, use glob to automatically include all data from yaml. Signed-off-by: Mauro Carvalho Chehab Reviewed-by: Donald Hunter --- Documentation/netlink/specs/index.rst | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 Documentation/netlink/specs/index.rst diff --git a/Documentation/netlink/specs/index.rst b/Documentation/netlink/= specs/index.rst new file mode 100644 index 000000000000..7f7cf4a096f2 --- /dev/null +++ b/Documentation/netlink/specs/index.rst @@ -0,0 +1,13 @@ +.. SPDX-License-Identifier: GPL-2.0 + +.. _specs: + +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D +Netlink Family Specifications +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D + +.. toctree:: + :maxdepth: 1 + :glob: + + * --=20 2.49.0 From nobody Thu Oct 9 06:50:10 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 5FF2D248F76; Thu, 19 Jun 2025 06:50:21 +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=1750315821; cv=none; b=dIK8TZE03QhH+kwVH5TiMzBDYB2f5T8SX4Ky6uGO2A9y6gIrjq5yioaEDnPSZExuPmCd412rcUvTig/G97t84XyNZib8q4iDIrclsT9t2rtllTWQLdt4s9OsflQSNl2xPupcJ7lEYwGz3iBpEj8m3FE415hwrfwi8QJPZ/MWeEU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750315821; c=relaxed/simple; bh=eN7Fxcj9u2QqSQyAPJebfF4efSTAdGEp6Mz6tU0QxYE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ogloo1A3UzcWbzk9kIGwNmNC/N9LiiWGt0i53domv1dkRgQ0hPf+SgYuN30+0WV8ndV/bmz/Kd1+8c1o3WtzonqIReeERcvAfnIRE1ZbBxS/apW4hQLZ1RG+KW0uRWJJdYIC/LcUCf8QvD/xRoG8h7sR+O0XcNXWGvuTwRejl6M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=LKMCMIjE; 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="LKMCMIjE" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BBA13C4CEF3; Thu, 19 Jun 2025 06:50:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1750315820; bh=eN7Fxcj9u2QqSQyAPJebfF4efSTAdGEp6Mz6tU0QxYE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LKMCMIjEsE5N3Z9Ju4DelkjayK/N3EGZQ2NOqbrkVxsDt+ng26NfrJhEpSMGp0mBZ NeLXL633aWwk2lYZueL5Vx1Wh2u8iuVq4e04Q1iFQpGHI8HPdtndVW7DfNIJWgAgIm eKas4YrZVHPI72pVRlwMUK9A4F99kIY5SnPAyLReREaizf46WTqvA/fGVjp3G+TiLv mIJaK139fs0MZpfy5RJ+yANAQ/smJ2WeK6T66N28wrhARdWbogFwR1YtgL5RKVJetK l0wUIQ4ACCDu4vWfQjtI72b1URQXMqoCXOdh0UarfEQ2C0PgV2Fg4AOtmAhlLHlIBa /mEl1/H14OTrQ== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1uS96I-00000003dGv-46Ee; Thu, 19 Jun 2025 08:50:18 +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" , Jakub Kicinski , Simon Horman , 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 v7 06/17] tools: ynl_gen_rst.py: cleanup coding style Date: Thu, 19 Jun 2025 08:48:59 +0200 Message-ID: <901d329a2d679e05572eb399b39418a48a491844.1750315578.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" Cleanup some coding style issues pointed by pylint and flake8. No functional changes. Signed-off-by: Mauro Carvalho Chehab Reviewed-by: Breno Leitao Reviewed-by: Donald Hunter --- tools/net/ynl/pyynl/lib/doc_generator.py | 75 ++++++++---------------- 1 file changed, 26 insertions(+), 49 deletions(-) diff --git a/tools/net/ynl/pyynl/lib/doc_generator.py b/tools/net/ynl/pyynl= /lib/doc_generator.py index 839e78b39de3..f71360f0ceb7 100644 --- a/tools/net/ynl/pyynl/lib/doc_generator.py +++ b/tools/net/ynl/pyynl/lib/doc_generator.py @@ -18,17 +18,12 @@ """ =20 from typing import Any, Dict, List -import os.path -import sys -import argparse -import logging import yaml =20 =20 -# =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D -# RST Formatters -# =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D class RstFormatters: + """RST Formatters""" + SPACE_PER_LEVEL =3D 4 =20 @staticmethod @@ -36,81 +31,67 @@ class RstFormatters: """Return space to format""" return " " * (level * RstFormatters.SPACE_PER_LEVEL) =20 - @staticmethod def bold(text: str) -> str: """Format bold text""" return f"**{text}**" =20 - @staticmethod def inline(text: str) -> str: """Format inline text""" return f"``{text}``" =20 - @staticmethod def sanitize(text: str) -> str: """Remove newlines and multiple spaces""" # This is useful for some fields that are spread across multiple l= ines return str(text).replace("\n", " ").strip() =20 - def rst_fields(self, key: str, value: str, level: int =3D 0) -> str: """Return a RST formatted field""" return self.headroom(level) + f":{key}: {value}" =20 - def rst_definition(self, key: str, value: Any, level: int =3D 0) -> st= r: """Format a single rst definition""" return self.headroom(level) + key + "\n" + self.headroom(level + 1= ) + str(value) =20 - def rst_paragraph(self, paragraph: str, level: int =3D 0) -> str: """Return a formatted paragraph""" return self.headroom(level) + paragraph =20 - def rst_bullet(self, item: str, level: int =3D 0) -> str: """Return a formatted a bullet""" return self.headroom(level) + f"- {item}" =20 - @staticmethod def rst_subsection(title: str) -> str: """Add a sub-section to the document""" return f"{title}\n" + "-" * len(title) =20 - @staticmethod def rst_subsubsection(title: str) -> str: """Add a sub-sub-section to the document""" return f"{title}\n" + "~" * len(title) =20 - @staticmethod def rst_section(namespace: str, prefix: str, title: str) -> str: """Add a section to the document""" return f".. _{namespace}-{prefix}-{title}:\n\n{title}\n" + "=3D" *= len(title) =20 - @staticmethod def rst_subtitle(title: str) -> str: """Add a subtitle to the document""" return "\n" + "-" * len(title) + f"\n{title}\n" + "-" * len(title)= + "\n\n" =20 - @staticmethod def rst_title(title: str) -> str: """Add a title to the document""" return "=3D" * len(title) + f"\n{title}\n" + "=3D" * len(title) + = "\n\n" =20 - def rst_list_inline(self, list_: List[str], level: int =3D 0) -> str: """Format a list using inlines""" return self.headroom(level) + "[" + ", ".join(self.inline(i) for i= in list_) + "]" =20 - @staticmethod def rst_ref(namespace: str, prefix: str, name: str) -> str: """Add a hyperlink to the document""" @@ -119,10 +100,9 @@ class RstFormatters: 'nested-attributes': 'attribute-set', 'struct': 'definition'} if prefix in mappings: - prefix =3D mappings[prefix] + prefix =3D mappings.get(prefix, "") return f":ref:`{namespace}-{prefix}-{name}`" =20 - def rst_header(self) -> str: """The headers for all the auto generated RST files""" lines =3D [] @@ -132,7 +112,6 @@ class RstFormatters: =20 return "\n".join(lines) =20 - @staticmethod def rst_toctree(maxdepth: int =3D 2) -> str: """Generate a toctree RST primitive""" @@ -143,16 +122,13 @@ class RstFormatters: =20 return "\n".join(lines) =20 - @staticmethod def rst_label(title: str) -> str: """Return a formatted label""" return f".. _{title}:\n\n" =20 -# =3D=3D=3D=3D=3D=3D=3D -# Parsers -# =3D=3D=3D=3D=3D=3D=3D class YnlDocGenerator: + """YAML Netlink specs Parser""" =20 fmt =3D RstFormatters() =20 @@ -164,7 +140,6 @@ class YnlDocGenerator: =20 return "\n".join(lines) =20 - def parse_do(self, do_dict: Dict[str, Any], level: int =3D 0) -> str: """Parse 'do' section and return a formatted string""" lines =3D [] @@ -177,16 +152,16 @@ class YnlDocGenerator: =20 return "\n".join(lines) =20 - def parse_do_attributes(self, attrs: Dict[str, Any], level: int =3D 0)= -> str: """Parse 'attributes' section""" if "attributes" not in attrs: return "" - lines =3D [self.fmt.rst_fields("attributes", self.fmt.rst_list_inl= ine(attrs["attributes"]), level + 1)] + lines =3D [self.fmt.rst_fields("attributes", + self.fmt.rst_list_inline(attrs["attri= butes"]), + level + 1)] =20 return "\n".join(lines) =20 - def parse_operations(self, operations: List[Dict[str, Any]], namespace= : str) -> str: """Parse operations block""" preprocessed =3D ["name", "doc", "title", "do", "dump", "flags"] @@ -194,7 +169,8 @@ class YnlDocGenerator: lines =3D [] =20 for operation in operations: - lines.append(self.fmt.rst_section(namespace, 'operation', oper= ation["name"])) + lines.append(self.fmt.rst_section(namespace, 'operation', + operation["name"])) lines.append(self.fmt.rst_paragraph(operation["doc"]) + "\n") =20 for key in operation.keys(): @@ -206,7 +182,8 @@ class YnlDocGenerator: value =3D self.fmt.rst_ref(namespace, key, value) lines.append(self.fmt.rst_fields(key, value, 0)) if 'flags' in operation: - lines.append(self.fmt.rst_fields('flags', self.fmt.rst_lis= t_inline(operation['flags']))) + lines.append(self.fmt.rst_fields('flags', + self.fmt.rst_list_inline(= operation['flags']))) =20 if "do" in operation: lines.append(self.fmt.rst_paragraph(":do:", 0)) @@ -220,7 +197,6 @@ class YnlDocGenerator: =20 return "\n".join(lines) =20 - def parse_entries(self, entries: List[Dict[str, Any]], level: int) -> = str: """Parse a list of entries""" ignored =3D ["pad"] @@ -235,17 +211,19 @@ class YnlDocGenerator: if type_: field_name +=3D f" ({self.fmt.inline(type_)})" lines.append( - self.fmt.rst_fields(field_name, self.fmt.sanitize(entr= y.get("doc", "")), level) + self.fmt.rst_fields(field_name, + self.fmt.sanitize(entry.get("doc",= "")), + level) ) elif isinstance(entry, list): lines.append(self.fmt.rst_list_inline(entry, level)) else: - lines.append(self.fmt.rst_bullet(self.fmt.inline(self.fmt.= sanitize(entry)), level)) + lines.append(self.fmt.rst_bullet(self.fmt.inline(self.fmt.= sanitize(entry)), + level)) =20 lines.append("\n") return "\n".join(lines) =20 - def parse_definitions(self, defs: Dict[str, Any], namespace: str) -> s= tr: """Parse definitions section""" preprocessed =3D ["name", "entries", "members"] @@ -270,7 +248,6 @@ class YnlDocGenerator: =20 return "\n".join(lines) =20 - def parse_attr_sets(self, entries: List[Dict[str, Any]], namespace: st= r) -> str: """Parse attribute from attribute-set""" preprocessed =3D ["name", "type"] @@ -279,7 +256,8 @@ class YnlDocGenerator: lines =3D [] =20 for entry in entries: - lines.append(self.fmt.rst_section(namespace, 'attribute-set', = entry["name"])) + lines.append(self.fmt.rst_section(namespace, 'attribute-set', + entry["name"])) for attr in entry["attributes"]: type_ =3D attr.get("type") attr_line =3D attr["name"] @@ -301,13 +279,13 @@ class YnlDocGenerator: =20 return "\n".join(lines) =20 - def parse_sub_messages(self, entries: List[Dict[str, Any]], namespace:= str) -> str: """Parse sub-message definitions""" lines =3D [] =20 for entry in entries: - lines.append(self.fmt.rst_section(namespace, 'sub-message', en= try["name"])) + lines.append(self.fmt.rst_section(namespace, 'sub-message', + entry["name"])) for fmt in entry["formats"]: value =3D fmt["value"] =20 @@ -315,13 +293,14 @@ class YnlDocGenerator: for attr in ['fixed-header', 'attribute-set']: if attr in fmt: lines.append(self.fmt.rst_fields(attr, - self.fmt.rst_ref(namespace= , attr, fmt[attr]), - 1)) + self.fmt.rst_ref(= namespace, + = attr, + = fmt[attr]), + 1)) lines.append("\n") =20 return "\n".join(lines) =20 - def parse_yaml(self, obj: Dict[str, Any]) -> str: """Format the whole YAML into a RST string""" lines =3D [] @@ -344,7 +323,8 @@ class YnlDocGenerator: # Operations if "operations" in obj: lines.append(self.fmt.rst_subtitle("Operations")) - lines.append(self.parse_operations(obj["operations"]["list"], = family)) + lines.append(self.parse_operations(obj["operations"]["list"], + family)) =20 # Multicast groups if "mcast-groups" in obj: @@ -368,11 +348,9 @@ class YnlDocGenerator: =20 return "\n".join(lines) =20 - # Main functions # =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 - def parse_yaml_file(self, filename: str) -> str: """Transform the YAML specified by filename into an RST-formatted = string""" with open(filename, "r", encoding=3D"utf-8") as spec_file: @@ -381,7 +359,6 @@ class YnlDocGenerator: =20 return content =20 - def generate_main_index_rst(self, output: str, index_dir: str) -> None: """Generate the `networking_spec/index` content and write to the f= ile""" lines =3D [] --=20 2.49.0 From nobody Thu Oct 9 06:50:10 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 6103B248F7F; Thu, 19 Jun 2025 06:50:21 +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=1750315821; cv=none; b=kfuoO1oJ+H/a55aMEcEnVk2B7xpZCJtve3NDFs6xS9eZhRTfFFdvAEViDKCvs2sy1w3Yv1LBlZZJizq6h+XxvhyuUbS2Qr0+DCuL6UKd79fPxrK7xqjVPgkcw56zqLmBU3lPZqzycd0HbrMV1TuDFONZ6wue8qZ7iyDXJaeqmu8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750315821; c=relaxed/simple; bh=2WQh1GG+XNK0Cdx26utHd/0dTt1jIj+urA1wFYdPe3Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YZUB1FesV7y/lXyReaPGr0Be/TF0kIYW+yCReeYjF1iwpzfIatcSSx3eehXzohQifX9qFCrOwQELzt8OG9niioKTCNTFn1Odq4+0Bf4tNKF4ePk44BkiXeCeemK8T++08OZQWHVqd2CqmByzD+zsKinEiklyamo+1cYYBOonJ4Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jMEjse6c; 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="jMEjse6c" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CC450C4CEF9; Thu, 19 Jun 2025 06:50:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1750315820; bh=2WQh1GG+XNK0Cdx26utHd/0dTt1jIj+urA1wFYdPe3Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jMEjse6cg4r2ntotJIAcyHpxXXyFo0O8Qp1tJuELRLjPwAmJPGNWkSVoNc6PM30FR cSLbje2+1PXsWR0o4Q2CploANXWcOO2iSBC+qanSnqGbr00LOsTtFo9SvCTXeQuCL0 l+gvjQHL14iwJKemVRzwNRcWnnom8qomn7JbFPy/7Xo/LMHYPwaYIFYt6ovSMYzHDs FSVimInct4LY6iIHjMUfGtyVAsFFKPpUhuLqE7phIyHfVItRxUcqG/GHXou3S2e5+f dYdf3RYRyHSrqjqAlHSzL7U9iXwc4NL+nmUeYV2BsnL63EwQcePCvaGPJmfFj9hBmb KBCgOWTCXBqdQ== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1uS96J-00000003dGy-01bn; Thu, 19 Jun 2025 08:50:19 +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 v7 07/17] docs: sphinx: add a parser for yaml files for Netlink specs Date: Thu, 19 Jun 2025 08:49:00 +0200 Message-ID: <79fd88d84e63351d1156a343d697d9bbca8159c5.1750315578.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" Add a simple sphinx.Parser to handle yaml files and add the the code to handle Netlink specs. All other yaml files are ignored. The code was written in a way that parsing yaml for different subsystems and even for different parts of Netlink are easy. All it takes to have a different parser is to add an import line similar to: from netlink_yml_parser import YnlDocGenerator adding the corresponding parser somewhere at the extension: netlink_parser =3D YnlDocGenerator() And then add a logic inside parse() to handle different doc outputs, depending on the file location, similar to: if "/netlink/specs/" in fname: msg =3D self.netlink_parser.parse_yaml_file(fname) Signed-off-by: Mauro Carvalho Chehab --- Documentation/sphinx/parser_yaml.py | 76 +++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100755 Documentation/sphinx/parser_yaml.py diff --git a/Documentation/sphinx/parser_yaml.py b/Documentation/sphinx/par= ser_yaml.py new file mode 100755 index 000000000000..635945e1c5ba --- /dev/null +++ b/Documentation/sphinx/parser_yaml.py @@ -0,0 +1,76 @@ +""" +Sphinx extension for processing YAML files +""" + +import os +import re +import sys + +from pprint import pformat + +from docutils.parsers.rst import Parser as RSTParser +from docutils.statemachine import ViewList + +from sphinx.util import logging +from sphinx.parsers import Parser + +srctree =3D os.path.abspath(os.environ["srctree"]) +sys.path.insert(0, os.path.join(srctree, "tools/net/ynl/pyynl")) + +from netlink_yml_parser import YnlDocGenerator # pylint: disable=3D= C0413 + +logger =3D logging.getLogger(__name__) + +class YamlParser(Parser): + """Custom parser for YAML files.""" + + # Need at least two elements on this set + supported =3D ('yaml', 'yml') + + netlink_parser =3D YnlDocGenerator() + + def do_parse(self, inputstring, document, msg): + """Parse YAML and generate a document tree.""" + + self.setup_parse(inputstring, document) + + result =3D ViewList() + + try: + # Parse message with RSTParser + for i, line in enumerate(msg.split('\n')): + result.append(line, document.current_source, i) + + rst_parser =3D RSTParser() + rst_parser.parse('\n'.join(result), document) + + except Exception as e: + document.reporter.error("YAML parsing error: %s" % pformat(e)) + + self.finish_parse() + + # 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 "/netlink/specs/" in fname: + 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.""" + + # Add YAML parser + app.add_source_parser(YamlParser) + app.add_source_suffix('.yaml', 'yaml') + + return { + 'version': '1.0', + 'parallel_read_safe': True, + 'parallel_write_safe': True, + } --=20 2.49.0 From nobody Thu Oct 9 06:50:10 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 60F6E248F7C; Thu, 19 Jun 2025 06:50:21 +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=1750315821; cv=none; b=HSU9B5YdID6gGoE31O0hey9CjQ0QnKHGMKJf+Ab+TQCVkCQWHFCjXYpAG/JLC20wK0dt5W+QoUm+e+RBudRD4ogaSLCCrdQxekvWhlJ8zu1j/8qn80/IyPNAuRxA+ZcErIyID2NtlX1+/oyTz7si1zTTPsFoXqDEhG2164hkp8M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750315821; c=relaxed/simple; bh=x9AeS/miPbBkEF42gU7I9M77AvT46AbR0fPXxclljq0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=psHnY05aH6s9YeIRW2U20EQhSAk3L+12hJuBuhIBhKH8hyW6y4+P2s5PsdNnAc9cCx0SBjv8LD3w8OVASyqJpsdaKFA9RGd22T9jvi756X62Kv0HfWwtMvRPfyNmmodYLeL/yY8wd2O00N5ZrYzSvChHGI26zs541tB8lHQKx4A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=hWjU2mvT; 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="hWjU2mvT" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CB9C7C4AF0B; Thu, 19 Jun 2025 06:50:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1750315820; bh=x9AeS/miPbBkEF42gU7I9M77AvT46AbR0fPXxclljq0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hWjU2mvTM8g3G+veWzWN4pE+zeRfUiKQcQoXloMNBLLEWidB9wwBFLG74ItSk9Tos CaB4dY++KdR0QYeMWJoW+S+YegVvX8Q8n7u42SNZKU/GlYBFDQhHKhOm4qi3cOoZmM BPvYL31Pg6GFTpnns3+c9ocfk/f+r2gO8iSjwugZEd4L5TDTtucjK0tqD20rD6ehHx qMMxLtMq3CSRsqykDJLdG+dLPlxjXC8GB5sQUxV5rb68jpkfxL0bRCPdXn/PAAMjWp zuhyYBQcw2jNybPnWauMF5XSlGLXu9u5v8CW+zNbGznsrTmOgX074oFiODWEHR9kOf DMxsbygqf1EDw== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1uS96J-00000003dH3-09OJ; Thu, 19 Jun 2025 08:50:19 +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" , Jakub Kicinski , Simon Horman , 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 v7 08/17] docs: use parser_yaml extension to handle Netlink specs Date: Thu, 19 Jun 2025 08:49:01 +0200 Message-ID: <4ee82983b4702f4c52296c3bae9c5be8b452650a.1750315578.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" Instead of manually calling ynl_gen_rst.py, use a Sphinx extension. This way, no .rst files would be written to the Kernel source directories. We are using here a toctree with :glob: property. This way, there is no need to touch the netlink/specs/index.rst file every time a new Netlink spec is added/renamed/removed. Signed-off-by: Mauro Carvalho Chehab Reviewed-by: Donald Hunter --- Documentation/Makefile | 17 ---------------- Documentation/conf.py | 20 ++++++++++++++----- Documentation/networking/index.rst | 2 +- .../networking/netlink_spec/readme.txt | 4 ---- Documentation/sphinx/parser_yaml.py | 4 ++-- 5 files changed, 18 insertions(+), 29 deletions(-) delete mode 100644 Documentation/networking/netlink_spec/readme.txt diff --git a/Documentation/Makefile b/Documentation/Makefile index b98477df5ddf..820f07e0afe6 100644 --- a/Documentation/Makefile +++ b/Documentation/Makefile @@ -104,22 +104,6 @@ quiet_cmd_sphinx =3D SPHINX $@ --> file://$(abspath $= (BUILDDIR)/$3/$4) cp $(if $(patsubst /%,,$(DOCS_CSS)),$(abspath $(srctree)/$(DOCS_CSS)),$(= DOCS_CSS)) $(BUILDDIR)/$3/_static/; \ fi =20 -YNL_INDEX:=3D$(srctree)/Documentation/networking/netlink_spec/index.rst -YNL_RST_DIR:=3D$(srctree)/Documentation/networking/netlink_spec -YNL_YAML_DIR:=3D$(srctree)/Documentation/netlink/specs -YNL_TOOL:=3D$(srctree)/tools/net/ynl/pyynl/ynl_gen_rst.py - -YNL_RST_FILES_TMP :=3D $(patsubst %.yaml,%.rst,$(wildcard $(YNL_YAML_DIR)/= *.yaml)) -YNL_RST_FILES :=3D $(patsubst $(YNL_YAML_DIR)%,$(YNL_RST_DIR)%, $(YNL_RST_= FILES_TMP)) - -$(YNL_INDEX): $(YNL_RST_FILES) - $(Q)$(YNL_TOOL) -o $@ -x - -$(YNL_RST_DIR)/%.rst: $(YNL_YAML_DIR)/%.yaml $(YNL_TOOL) - $(Q)$(YNL_TOOL) -i $< -o $@ - -htmldocs texinfodocs latexdocs epubdocs xmldocs: $(YNL_INDEX) - htmldocs: @$(srctree)/scripts/sphinx-pre-install --version-check @+$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,html,$(var),,$(var))) @@ -186,7 +170,6 @@ refcheckdocs: $(Q)cd $(srctree);scripts/documentation-file-ref-check =20 cleandocs: - $(Q)rm -f $(YNL_INDEX) $(YNL_RST_FILES) $(Q)rm -rf $(BUILDDIR) $(Q)$(MAKE) BUILDDIR=3D$(abspath $(BUILDDIR)) $(build)=3DDocumentation/us= erspace-api/media clean =20 diff --git a/Documentation/conf.py b/Documentation/conf.py index 4ba4ee45e599..6af61e26cec5 100644 --- a/Documentation/conf.py +++ b/Documentation/conf.py @@ -38,6 +38,15 @@ exclude_patterns =3D [] dyn_include_patterns =3D [] dyn_exclude_patterns =3D ['output'] =20 +# Currently, only netlink/specs has a parser for yaml. +# Prefer using include patterns if available, as it is faster +if has_include_patterns: + dyn_include_patterns.append('netlink/specs/*.yaml') +else: + dyn_exclude_patterns.append('netlink/*.yaml') + dyn_exclude_patterns.append('devicetree/bindings/**.yaml') + dyn_exclude_patterns.append('core-api/kho/bindings/**.yaml') + # Properly handle include/exclude patterns # ---------------------------------------- =20 @@ -105,7 +114,7 @@ needs_sphinx =3D '3.4.3' extensions =3D ['kerneldoc', 'rstFlatTable', 'kernel_include', 'kfigure', 'sphinx.ext.ifconfig', 'automarkup', 'maintainers_include', 'sphinx.ext.autosectionlabel', - 'kernel_abi', 'kernel_feat', 'translations'] + 'kernel_abi', 'kernel_feat', 'translations', 'parser_yaml'] =20 # Since Sphinx version 3, the C function parser is more pedantic with rega= rds # to type checking. Due to that, having macros at c:function cause problem= s. @@ -203,10 +212,11 @@ else: # Add any paths that contain templates here, relative to this directory. templates_path =3D ['sphinx/templates'] =20 -# The suffix(es) of source filenames. -# You can specify multiple suffix as a list of string: -# source_suffix =3D ['.rst', '.md'] -source_suffix =3D '.rst' +# The suffixes of source filenames that will be automatically parsed +source_suffix =3D { + '.rst': 'restructuredtext', + '.yaml': 'yaml', +} =20 # The encoding of source files. #source_encoding =3D 'utf-8-sig' diff --git a/Documentation/networking/index.rst b/Documentation/networking/= index.rst index ac90b82f3ce9..b7a4969e9bc9 100644 --- a/Documentation/networking/index.rst +++ b/Documentation/networking/index.rst @@ -57,7 +57,7 @@ Contents: filter generic-hdlc generic_netlink - netlink_spec/index + ../netlink/specs/index gen_stats gtp ila diff --git a/Documentation/networking/netlink_spec/readme.txt b/Documentati= on/networking/netlink_spec/readme.txt deleted file mode 100644 index 030b44aca4e6..000000000000 --- a/Documentation/networking/netlink_spec/readme.txt +++ /dev/null @@ -1,4 +0,0 @@ -SPDX-License-Identifier: GPL-2.0 - -This file is populated during the build of the documentation (htmldocs) by= the -tools/net/ynl/pyynl/ynl_gen_rst.py script. diff --git a/Documentation/sphinx/parser_yaml.py b/Documentation/sphinx/par= ser_yaml.py index 635945e1c5ba..2b2af239a1c2 100755 --- a/Documentation/sphinx/parser_yaml.py +++ b/Documentation/sphinx/parser_yaml.py @@ -15,9 +15,9 @@ from sphinx.util import logging from sphinx.parsers import Parser =20 srctree =3D os.path.abspath(os.environ["srctree"]) -sys.path.insert(0, os.path.join(srctree, "tools/net/ynl/pyynl")) +sys.path.insert(0, os.path.join(srctree, "tools/net/ynl/pyynl/lib")) =20 -from netlink_yml_parser import YnlDocGenerator # pylint: disable=3D= C0413 +from doc_generator import YnlDocGenerator # pylint: disable=3DC0413 =20 logger =3D logging.getLogger(__name__) =20 --=20 2.49.0 From nobody Thu Oct 9 06:50:10 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 5D940248F70; Thu, 19 Jun 2025 06:50:21 +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=1750315821; cv=none; b=QeAYrNC5dLVIrbvRlSHake1IyMyCqKzE3r674tIr8z/9XTnqN1NdUo692MBrPE2yW/EUjbW2pp5zsh+luEyX7sEYQUEBlbVLeSUYY2oBvhteKo5SGyznDuq+pCxNPlDA7PvP8b7jttwy4GWQzEwYNbhfTF/k1vPlclO+QzQefJA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750315821; c=relaxed/simple; bh=gCUujhjF05O4bN0j1mBzTOE2gqunIOFmC86Oe+w0BHo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VyKFlJ4kt1C4a6BnIhIgBBC4K0ZppXxfWQdXRz8vtczeZEFH6d02W9eVbV3BE86cudUZM0brpDFa3XNpwfrlmVU1NLgsNQY6jB3qaQ4So8GmPMG5qD/VopwF5I0DzriVie+Xztlv7eQjrngiV0H+f75tty0GPpzjlbTkP6Rf6mM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=pn6LfRLa; 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="pn6LfRLa" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DA87EC4CEF8; Thu, 19 Jun 2025 06:50:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1750315820; bh=gCUujhjF05O4bN0j1mBzTOE2gqunIOFmC86Oe+w0BHo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pn6LfRLarxJoTOzmEmnaEIsLqYTjH6sbOYDTZ8505bbemCUy5rchyANoPA91IOs+u uj3qiUSaVzABP3pqABm0jcdbP/NMfoWjlJh2ZZkseTK347CHXOIAyXDG2+8PM0ivDb Ab+/1zFrLjq6jaPkDQ3vULR1vr74ridnIm89EALw55aOYTuvn77A8Yhb7vKA37t7// Q+wb8GS/nSyfAEuvIUCu4ot8Wpf+UbYDmhZoox3RtGeUNYutsT6+tE076dFstH7E8l 4p+EHSkCjOTWw8SpAYhFyigUVWmKt77UZwhdcLzS4tPUSkV3wCw124hcViVChoc8Lw 6qjDlnAEdl6lQ== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1uS96J-00000003dH7-0H56; Thu, 19 Jun 2025 08:50:19 +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" , Jakub Kicinski , Simon Horman , 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 v7 09/17] docs: uapi: netlink: update netlink specs link Date: Thu, 19 Jun 2025 08:49:02 +0200 Message-ID: <1dbe019319a6fd9f0c672280e079ddad1149cbe4.1750315578.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" With the recent parser_yaml extension, and the removal of the auto-generated ReST source files, the location of netlink specs changed. Update uAPI accordingly. Signed-off-by: Mauro Carvalho Chehab Reviewed-by: Donald Hunter --- Documentation/userspace-api/netlink/index.rst | 2 +- Documentation/userspace-api/netlink/specs.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/userspace-api/netlink/index.rst b/Documentation/= userspace-api/netlink/index.rst index c1b6765cc963..83ae25066591 100644 --- a/Documentation/userspace-api/netlink/index.rst +++ b/Documentation/userspace-api/netlink/index.rst @@ -18,4 +18,4 @@ Netlink documentation for users. =20 See also: - :ref:`Documentation/core-api/netlink.rst ` - - :ref:`Documentation/networking/netlink_spec/index.rst ` + - :ref:`Documentation/netlink/specs/index.rst ` diff --git a/Documentation/userspace-api/netlink/specs.rst b/Documentation/= userspace-api/netlink/specs.rst index 1b50d97d8d7c..debb4bfca5c4 100644 --- a/Documentation/userspace-api/netlink/specs.rst +++ b/Documentation/userspace-api/netlink/specs.rst @@ -15,7 +15,7 @@ kernel headers directly. Internally kernel uses the YAML specs to generate: =20 - the C uAPI header - - documentation of the protocol as a ReST file - see :ref:`Documentation/= networking/netlink_spec/index.rst ` + - documentation of the protocol as a ReST file - see :ref:`Documentation/= netlink/specs/index.rst ` - policy tables for input attribute validation - operation tables =20 --=20 2.49.0 From nobody Thu Oct 9 06:50:10 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 4D091248F55; Thu, 19 Jun 2025 06:50:21 +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=1750315821; cv=none; b=Td4NhxG91HTGCUGnA+5HZ0/SlROU7j+e/3rJ2SQyyYaKowVqQyMID4MF4DQYXH3W163Xpb1ZgYD10mP1McblcOjBUI0vFT0UWfRilf7vICtiI4Xusv5wUTcb/eVVXaTT8sz/UtweSnjM1fq4QqyLSE3GV2Zl6l+CFypylMq/vyE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750315821; c=relaxed/simple; bh=EpBDvvCEgkXYhfewwIef0GKxoO/B4wVDI6b8/pzv1js=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KlCQ1M1Qsz0QGQHqy/j4hwogZFZKJX9kJ79W9f9xzJQbywiNSq7p0etxHY1FZZ8nt7nww1H0GWLaWFoAC2NgkjR84RnLeHvBA0r7vTAxFAHuC8N5PF1D93aNgjqv7mBAEvd+1WowkXAFanTOSgEJrcZ85K9BVwXX/zJVDSpxs70= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=IyaOWa6j; 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="IyaOWa6j" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E476DC4CEFE; Thu, 19 Jun 2025 06:50:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1750315821; bh=EpBDvvCEgkXYhfewwIef0GKxoO/B4wVDI6b8/pzv1js=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IyaOWa6j2mmLnbXdwE9VbGZuqL3CrX3Xupwg0hrDxHhOVqC9li+mA82rDePFjyAvl mzvD7A/2Vqhk95OOO9WRMIhFeuIOM0GdG3Re1QtamSYw7v8pRdMwtPt8SaGEFGaQJK 983ovu9+DqsDsIKQi3Rb3LuiQZxEvmWk55y8XntXFUDMnJcbQZed1fmWbEkKTZfDkn VnVqCeNBuMcwUQYZQQUrTNKoCu+1d73PeEAsKdwQjcdEuHDaPHi6lzohyzn0w17bul 2NLM4kdxdTJwnWa6CXM9LoAYxlGALMljE+aQfbcNDxjdE8oVZsKa9aT3+c/XFBdiYl qaCmb4dC+eNdQ== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1uS96J-00000003dHA-0OqG; Thu, 19 Jun 2025 08:50:19 +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" , Jakub Kicinski , Simon Horman , 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 v7 10/17] tools: ynl_gen_rst.py: drop support for generating index files Date: Thu, 19 Jun 2025 08:49:03 +0200 Message-ID: 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" As we're now using an index file with a glob, there's no need to generate index files anymore. Signed-off-by: Mauro Carvalho Chehab --- tools/net/ynl/pyynl/lib/doc_generator.py | 26 ------------------------ tools/net/ynl/pyynl/ynl_gen_rst.py | 26 ------------------------ 2 files changed, 52 deletions(-) diff --git a/tools/net/ynl/pyynl/lib/doc_generator.py b/tools/net/ynl/pyynl= /lib/doc_generator.py index f71360f0ceb7..866551726723 100644 --- a/tools/net/ynl/pyynl/lib/doc_generator.py +++ b/tools/net/ynl/pyynl/lib/doc_generator.py @@ -358,29 +358,3 @@ class YnlDocGenerator: content =3D self.parse_yaml(yaml_data) =20 return content - - def generate_main_index_rst(self, output: str, index_dir: str) -> None: - """Generate the `networking_spec/index` content and write to the f= ile""" - lines =3D [] - - lines.append(self.fmt.rst_header()) - lines.append(self.fmt.rst_label("specs")) - lines.append(self.fmt.rst_title("Netlink Family Specifications")) - lines.append(self.fmt.rst_toctree(1)) - - index_fname =3D os.path.basename(output) - base, ext =3D os.path.splitext(index_fname) - - if not index_dir: - index_dir =3D os.path.dirname(output) - - logging.debug(f"Looking for {ext} files in %s", index_dir) - for filename in sorted(os.listdir(index_dir)): - if not filename.endswith(ext) or filename =3D=3D index_fname: - continue - base, ext =3D os.path.splitext(filename) - lines.append(f" {base}\n") - - logging.debug("Writing an index file at %s", output) - - return "".join(lines) diff --git a/tools/net/ynl/pyynl/ynl_gen_rst.py b/tools/net/ynl/pyynl/ynl_g= en_rst.py index b5a665eeaa5a..90ae19aac89d 100755 --- a/tools/net/ynl/pyynl/ynl_gen_rst.py +++ b/tools/net/ynl/pyynl/ynl_gen_rst.py @@ -31,9 +31,6 @@ def parse_arguments() -> argparse.Namespace: =20 # Index and input are mutually exclusive group =3D parser.add_mutually_exclusive_group() - group.add_argument( - "-x", "--index", action=3D"store_true", help=3D"Generate the index= page" - ) group.add_argument("-i", "--input", help=3D"YAML file name") =20 args =3D parser.parse_args() @@ -63,25 +60,6 @@ def write_to_rstfile(content: str, filename: str) -> Non= e: rst_file.write(content) =20 =20 -def generate_main_index_rst(output: str) -> None: - """Generate the `networking_spec/index` content and write to the file"= "" - - lines.append(rst_header()) - lines.append(rst_label("specs")) - lines.append(rst_title("Netlink Family Specifications")) - lines.append(rst_toctree(1)) - - index_dir =3D os.path.dirname(output) - logging.debug("Looking for .rst files in %s", index_dir) - for filename in sorted(os.listdir(index_dir)): - if not filename.endswith(".rst") or filename =3D=3D "index.rst": - continue - lines.append(f" {filename.replace('.rst', '')}\n") - - logging.debug("Writing an index file at %s", output) - write_to_rstfile(msg, output) - - def main() -> None: """Main function that reads the YAML files and generates the RST files= """ =20 @@ -100,10 +78,6 @@ def main() -> None: =20 write_to_rstfile(content, args.output) =20 - if args.index: - # Generate the index RST file - generate_main_index_rst(args.output) - =20 if __name__ =3D=3D "__main__": main() --=20 2.49.0 From nobody Thu Oct 9 06:50:10 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 7963924C68B; Thu, 19 Jun 2025 06:50:21 +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=1750315821; cv=none; b=tZ6hD4iWDAubDNrUpylOfA/owcGSvIvOkXnhOdTAB7z7EfShkEDDxYn+vdkyNpOqKtQTxiqTNPcEwciZDSJr94Q5jRs2fHjkhiJKoX+dvdto593ERYTyhfMTNhX1FaV71hxSHVJHK1A0aGHE0uOPFDzEiHFWFynnVTgkbfCx7jE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750315821; c=relaxed/simple; bh=ogBoG80VZdRt95wsoC2snRc4eLHl6tjexBrTDr8vuXE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GWNpgIT0qekSM6lksgWTiwdnKUiylSk8ZphK6a1QdOq1ED4UJauDxoAyvAthAwQykpE+DLZ1p6CHnZJapayMVad8CRvb8rb0S+JEemTY3t8GB79kOQOHdQqkpgIoDJvCN6ihKcrYSEVBYcgOTRxDqG7TJ+9XfW8IBrh8QFd/nU0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=nBqdGUxa; 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="nBqdGUxa" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E2771C4CEFC; Thu, 19 Jun 2025 06:50:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1750315821; bh=ogBoG80VZdRt95wsoC2snRc4eLHl6tjexBrTDr8vuXE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nBqdGUxauHkjPdPkH1CLHlh8829DMsO/E/yRm7/fSfPdYVjj+Ds3Xl+SSU8FWZVAJ caPJAcrxX+et7iyq52dQpTBAs62TjrDZoYRuHK1oi/8WWZCydUePumgda0NBcs/esJ 97flDxTJSaw5L75N+HckG9NE8UEGRaJENaGa3NBtYgGWFUxw4NHt97jK82y9le11x9 AQpErNXxrcLa0rC7S0n/3IZyYL6ZcVRIVn6kXHJosVHRSLwAGZjNOKRf86j+dmtKgu Ll3xYShpSCKs3C7a3wtyfXCoq6+Fy/VVg+vCvkPnSnthz2BoTcBG6QxAEMN5CbNLO4 NkphEdBqLZzug== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1uS96J-00000003dHE-0WgH; Thu, 19 Jun 2025 08:50:19 +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" , Jakub Kicinski , Simon Horman , 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 v7 11/17] docs: netlink: remove obsolete .gitignore from unused directory Date: Thu, 19 Jun 2025 08:49:04 +0200 Message-ID: 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" The previous code was generating source rst files under Documentation/networking/netlink_spec/. With the Sphinx YAML parser, this is now gone. So, stop ignoring *.rst files inside netlink specs directory. Signed-off-by: Mauro Carvalho Chehab Reviewed-by: Donald Hunter --- Documentation/networking/netlink_spec/.gitignore | 1 - 1 file changed, 1 deletion(-) delete mode 100644 Documentation/networking/netlink_spec/.gitignore diff --git a/Documentation/networking/netlink_spec/.gitignore b/Documentati= on/networking/netlink_spec/.gitignore deleted file mode 100644 index 30d85567b592..000000000000 --- a/Documentation/networking/netlink_spec/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.rst --=20 2.49.0 From nobody Thu Oct 9 06:50:10 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 58091248F57; Thu, 19 Jun 2025 06:50:21 +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=1750315821; cv=none; b=Fv0c5hM3taG3fxysfKZ7iewVO6lVfPwei2mMZ2yJ6GuRm4ziV+ebtIwFzAPRdXcr9v6kYt+aR8kv36U2Op4XYdvGia5CrwULHCMnv/QkEkAuIXkCalGO7qWEXJOY5ZKcwhOELHilNzdpwm/F/S6o/39CNE1O4tDzh5VdnURmckk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750315821; c=relaxed/simple; bh=NWHr6s5MAHhaxWhvDkXosw3Qmf8A786TTZ4Xlu7HoGk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MCyzEq9+yn2ov44giYcgDrr9koPmo1XwgWpmydnQ3DabNFvd/VTbaLYBhoLXO/VKNgsr0BxL5SLIApToIXAfUEOz9vJ8vxOZ/awZWbLR/KsGLRjJbgrAxmRIO/Daiue1ztWA+Svva9e7mzZ+QQZLDo9WfOi/RVsK9dI/1gooetw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=HKoyUQo4; 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="HKoyUQo4" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F3394C113D0; Thu, 19 Jun 2025 06:50:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1750315821; bh=NWHr6s5MAHhaxWhvDkXosw3Qmf8A786TTZ4Xlu7HoGk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HKoyUQo4Ffzqqd/6TNqqWE8CyBYPSsYR9yebXX8DrslA4TVnNXcl/YeuCiHHJP2gE j5fzsu3JfTQ80Kxkyr7xF4FP7qSt8vDunBtc3/SxxYKGGAItx8EkXNvxNexs2ppebd oM3x5p4AqwmYL/sGVIhzrz9hIyeuHmoFzfs0jSOrh54KkUty77ujQqS7KIkp0gUnEW ZCQ+IAQkgg8BpStVcnEux/bAePfM4bFYhPSFovtbTmFSYfHCck3UzZkH4uPqlf0tpA NYC5vFpZnrFnTxkT+cQiUtxBVMbnI/IKBizhvUq323nGWEAbDtKS1VF7JkoRtCwSnf VaH47rOZj+0Mg== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1uS96J-00000003dHI-0e7s; Thu, 19 Jun 2025 08:50:19 +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 v7 12/17] MAINTAINERS: add netlink_yml_parser.py to linux-doc Date: Thu, 19 Jun 2025 08:49:05 +0200 Message-ID: <4077605f84d7ba6423dcb5fda4e96ac950856f1d.1750315578.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" The documentation build depends on the parsing code at ynl_gen_rst.py. Ensure that changes to it will be c/c to linux-doc ML and maintainers by adding an entry for it. This way, if a change there would affect the build, or the minimal version required for Python, doc developers may know in advance. Signed-off-by: Mauro Carvalho Chehab Reviewed-by: Breno Leitao --- MAINTAINERS | 1 + 1 file changed, 1 insertion(+) diff --git a/MAINTAINERS b/MAINTAINERS index a92290fffa16..caa3425e5755 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -7202,6 +7202,7 @@ F: scripts/get_abi.py F: scripts/kernel-doc* F: scripts/lib/abi/* F: scripts/lib/kdoc/* +F: tools/net/ynl/pyynl/netlink_yml_parser.py F: scripts/sphinx-pre-install X: Documentation/ABI/ X: Documentation/admin-guide/media/ --=20 2.49.0 From nobody Thu Oct 9 06:50:10 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 78EC824BBFC; Thu, 19 Jun 2025 06:50:21 +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=1750315821; cv=none; b=dffciLOzPK8WYEl6PEl7BBJHo3Gw94xRBfkQIbNWrCBd5/GVK1Jls7JOzmM8ZbPAgKPJQae92roHCUwb6siQGN7FQEIgflIdZZ5WUtDsT3VLjZFKkmp+4OSfb7InMf8lNwB6HdrG1cB03A+7kdiXsP8PR0XzPQcBRhR8qN7LdS4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750315821; c=relaxed/simple; bh=ZRwnGGD63dY02hpT4BqTMDO35vMSt+NPRBYC3eA8F/0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BEe4QVw9rzzN38q6g1GsWlEuOROGu0FJmcVcraM9eiy2Cq1+QgBDPFhdBwAG62f9V9UqWxQXeDVlz175E1HF55O6phYOjqsiQxSI1opd6U6FUjBVQXHQhjtrkBapXPbwNRGXcGJw9XSJlf/D0eVZ+ekLY7gfg9o+ilUMacJoMmw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=lppJ3Kzs; 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="lppJ3Kzs" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F1548C4CEFF; Thu, 19 Jun 2025 06:50:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1750315821; bh=ZRwnGGD63dY02hpT4BqTMDO35vMSt+NPRBYC3eA8F/0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lppJ3KzscHSaHWzZ9sjS9vY3r4UEEUqSrZLPTMmyUlixmU7ZFp2yrBq8A/qJSQurG qGCpQf5Oq6NNBh9ft13zG7+CjBQSUtikk5OjmQnAeGAQNqpBMPcjo+wfltFlQU8ECu xjYBzLPSBFJPiDZ1VxGWn2EuXcyYq91GacRqujtuGLM73uvoZswZrf8JabUxnquydZ HGaJRk4CHkyKD1/Axmz6JMVc5ZGGKELWxC5kaWdAkI11mS3aVHplSVAl3amoCNLvgZ FFzwKe0h7iF8XVP6co4BOjtfHm6J9BS/SP92ml1cnGTtValji5f+FW9uhQXMD8WQz4 72lX1gSlhQm4w== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1uS96J-00000003dHM-0ll3; Thu, 19 Jun 2025 08:50:19 +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" , Jakub Kicinski , Simon Horman , 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 v7 13/17] tools: netlink_yml_parser.py: add line numbers to parsed data Date: Thu, 19 Jun 2025 08:49:06 +0200 Message-ID: <21722a5346cfc3b8a0ad7427fca157cff032e2f0.1750315578.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" When something goes wrong, we want Sphinx error to point to the right line number from the original source, not from the processed ReST data. Signed-off-by: Mauro Carvalho Chehab --- tools/net/ynl/pyynl/lib/doc_generator.py | 34 ++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/tools/net/ynl/pyynl/lib/doc_generator.py b/tools/net/ynl/pyynl= /lib/doc_generator.py index 866551726723..a9d8ab6f2639 100644 --- a/tools/net/ynl/pyynl/lib/doc_generator.py +++ b/tools/net/ynl/pyynl/lib/doc_generator.py @@ -20,6 +20,16 @@ from typing import Any, Dict, List import yaml =20 +LINE_STR =3D '__lineno__' + +class NumberedSafeLoader(yaml.SafeLoader): + """Override the SafeLoader class to add line number to parsed data""" + + def construct_mapping(self, node): + mapping =3D super().construct_mapping(node) + mapping[LINE_STR] =3D node.start_mark.line + + return mapping =20 class RstFormatters: """RST Formatters""" @@ -127,6 +137,11 @@ class RstFormatters: """Return a formatted label""" return f".. _{title}:\n\n" =20 + @staticmethod + def rst_lineno(lineno: int) -> str: + """Return a lineno comment""" + return f".. LINENO {lineno}\n" + class YnlDocGenerator: """YAML Netlink specs Parser""" =20 @@ -144,6 +159,9 @@ class YnlDocGenerator: """Parse 'do' section and return a formatted string""" lines =3D [] for key in do_dict.keys(): + if key =3D=3D LINE_STR: + lines.append(self.fmt.rst_lineno(do_dict[key])) + continue lines.append(self.fmt.rst_paragraph(self.fmt.bold(key), level = + 1)) if key in ['request', 'reply']: lines.append(self.parse_do_attributes(do_dict[key], level = + 1) + "\n") @@ -174,6 +192,10 @@ class YnlDocGenerator: lines.append(self.fmt.rst_paragraph(operation["doc"]) + "\n") =20 for key in operation.keys(): + if key =3D=3D LINE_STR: + lines.append(self.fmt.rst_lineno(operation[key])) + continue + if key in preprocessed: # Skip the special fields continue @@ -233,6 +255,9 @@ class YnlDocGenerator: for definition in defs: lines.append(self.fmt.rst_section(namespace, 'definition', def= inition["name"])) for k in definition.keys(): + if k =3D=3D LINE_STR: + lines.append(self.fmt.rst_lineno(definition[k])) + continue if k in preprocessed + ignored: continue lines.append(self.fmt.rst_fields(k, self.fmt.sanitize(defi= nition[k]), 0)) @@ -268,6 +293,9 @@ class YnlDocGenerator: lines.append(self.fmt.rst_subsubsection(attr_line)) =20 for k in attr.keys(): + if k =3D=3D LINE_STR: + lines.append(self.fmt.rst_lineno(attr[k])) + continue if k in preprocessed + ignored: continue if k in linkable: @@ -306,6 +334,8 @@ class YnlDocGenerator: lines =3D [] =20 # Main header + lineno =3D obj.get('__lineno__', 0) + lines.append(self.fmt.rst_lineno(lineno)) =20 family =3D obj['name'] =20 @@ -354,7 +384,7 @@ class YnlDocGenerator: def parse_yaml_file(self, filename: str) -> str: """Transform the YAML specified by filename into an RST-formatted = string""" with open(filename, "r", encoding=3D"utf-8") as spec_file: - yaml_data =3D yaml.safe_load(spec_file) - content =3D self.parse_yaml(yaml_data) + numbered_yaml =3D yaml.load(spec_file, Loader=3DNumberedSafeLo= ader) + content =3D self.parse_yaml(numbered_yaml) =20 return content --=20 2.49.0 From nobody Thu Oct 9 06:50:10 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 A75E32586E0; Thu, 19 Jun 2025 06:50:21 +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=1750315821; cv=none; b=qZn3mNEsfNfWHiPVUIPVSKB2pjOay5ADV74GNwbprFeFNyrZKpYtLEjOHwJxToLC7P1zcDKoLPl/YIzOfIc8e2fVeQFvV4o1UdAlVEesKT0iwXnRUVjW8iiEPOVnPMPhkA1/dZrm0Qh4ryJtFjhWpYEAPwI6sSLs2MQxRg7/U6g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750315821; c=relaxed/simple; bh=sLGX0eyqIoRSaJCtRaOhRqFB+mw5FlWjFBG7e4HNq2I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RFkqSysymwHwzpEvs/PzdGFuCXGn224/mY5BO8Y3CYlkxBHSw6dJF+7S38fH4/l8uqSTYSFVjDPIWUgexNAhmGR57/2og9MDlb4JgSlxz8PICkg7tMK41W/wTW0fu6dFv0gSPYYBgkJekHC0BEwV7IMJpkLdjH62OdrUBLgY2E8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=YD6qezGc; 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="YD6qezGc" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 01C87C116C6; Thu, 19 Jun 2025 06:50:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1750315821; bh=sLGX0eyqIoRSaJCtRaOhRqFB+mw5FlWjFBG7e4HNq2I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YD6qezGcHVKgPQ7iY2lD7cpkxIaV5PL3Fxe5U1FafOwI8jTwRPpRQ/FXrwR6haiUu tUqs4Xs+UJ1H+SfVGjlDWOHJRjo0E0DHLy9ShUlEQdWMQZXRI7LYIT5aPZho/6fa5C nM01fd9UnTqcOM2wUB9R7dp5IUa2m8ViJS7k6vwanzEexFgUJRvuj7zjg3aPGV0CM/ 1a5je6uD0RzxHKHod/rFGwc7lXt9Yjnp58nEqRJiaDGSDCI1NTRw7MIXjkrHE4KDrC xBdr7yvuJkgJrzuW7+4pLjj7ZSAtkJ3RPRoloP0NMQc6jYrUkFEWMUw534K8IkZ1hg ak7ljWm0E7vhQ== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1uS96J-00000003dHR-0tQY; Thu, 19 Jun 2025 08:50:19 +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" , Jakub Kicinski , Simon Horman , 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 v7 14/17] docs: parser_yaml.py: add support for line numbers from the parser Date: Thu, 19 Jun 2025 08:49:07 +0200 Message-ID: <33fc2894166805b93d4cf652cff9927a54b4f242.1750315578.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" Instead of printing line numbers from the temp converted ReST file, get them from the original source. Signed-off-by: Mauro Carvalho Chehab --- Documentation/sphinx/parser_yaml.py | 12 ++++++++++-- tools/net/ynl/pyynl/lib/doc_generator.py | 16 ++++++++++++---- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/Documentation/sphinx/parser_yaml.py b/Documentation/sphinx/par= ser_yaml.py index 2b2af239a1c2..5360fcfd4fde 100755 --- a/Documentation/sphinx/parser_yaml.py +++ b/Documentation/sphinx/parser_yaml.py @@ -29,6 +29,8 @@ class YamlParser(Parser): =20 netlink_parser =3D YnlDocGenerator() =20 + re_lineno =3D re.compile(r"\.\. LINENO ([0-9]+)$") + def do_parse(self, inputstring, document, msg): """Parse YAML and generate a document tree.""" =20 @@ -38,8 +40,14 @@ class YamlParser(Parser): =20 try: # Parse message with RSTParser - for i, line in enumerate(msg.split('\n')): - result.append(line, document.current_source, i) + lineoffset =3D 0; + for line in msg.split('\n'): + match =3D self.re_lineno.match(line) + if match: + lineoffset =3D int(match.group(1)) + continue + + result.append(line, document.current_source, lineoffset) =20 rst_parser =3D RSTParser() rst_parser.parse('\n'.join(result), document) diff --git a/tools/net/ynl/pyynl/lib/doc_generator.py b/tools/net/ynl/pyynl= /lib/doc_generator.py index a9d8ab6f2639..7f4f98983cdf 100644 --- a/tools/net/ynl/pyynl/lib/doc_generator.py +++ b/tools/net/ynl/pyynl/lib/doc_generator.py @@ -158,9 +158,11 @@ class YnlDocGenerator: def parse_do(self, do_dict: Dict[str, Any], level: int =3D 0) -> str: """Parse 'do' section and return a formatted string""" lines =3D [] + if LINE_STR in do_dict: + lines.append(self.fmt.rst_lineno(do_dict[LINE_STR])) + for key in do_dict.keys(): if key =3D=3D LINE_STR: - lines.append(self.fmt.rst_lineno(do_dict[key])) continue lines.append(self.fmt.rst_paragraph(self.fmt.bold(key), level = + 1)) if key in ['request', 'reply']: @@ -187,13 +189,15 @@ class YnlDocGenerator: lines =3D [] =20 for operation in operations: + if LINE_STR in operation: + lines.append(self.fmt.rst_lineno(operation[LINE_STR])) + lines.append(self.fmt.rst_section(namespace, 'operation', operation["name"])) lines.append(self.fmt.rst_paragraph(operation["doc"]) + "\n") =20 for key in operation.keys(): if key =3D=3D LINE_STR: - lines.append(self.fmt.rst_lineno(operation[key])) continue =20 if key in preprocessed: @@ -253,10 +257,12 @@ class YnlDocGenerator: lines =3D [] =20 for definition in defs: + if LINE_STR in definition: + lines.append(self.fmt.rst_lineno(definition[LINE_STR])) + lines.append(self.fmt.rst_section(namespace, 'definition', def= inition["name"])) for k in definition.keys(): if k =3D=3D LINE_STR: - lines.append(self.fmt.rst_lineno(definition[k])) continue if k in preprocessed + ignored: continue @@ -284,6 +290,9 @@ class YnlDocGenerator: lines.append(self.fmt.rst_section(namespace, 'attribute-set', entry["name"])) for attr in entry["attributes"]: + if LINE_STR in attr: + lines.append(self.fmt.rst_lineno(attr[LINE_STR])) + type_ =3D attr.get("type") attr_line =3D attr["name"] if type_: @@ -294,7 +303,6 @@ class YnlDocGenerator: =20 for k in attr.keys(): if k =3D=3D LINE_STR: - lines.append(self.fmt.rst_lineno(attr[k])) continue if k in preprocessed + ignored: continue --=20 2.49.0 From nobody Thu Oct 9 06:50:10 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 810032512FA; Thu, 19 Jun 2025 06:50:21 +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=1750315821; cv=none; b=IJy+5abq/G2ONGD0WEBQyeTmYGCoqf//gc7AMbjRTBRtk0SVSbcLHebVRiB/yVxfvGcUXi1+CvoUuHrr5XZOYBQ26nSGYyxGdBJZlVzb16Z9zydDHpBgRQeNOvaUyXNnKOBs0Bn8vF5EVHZHt84oZpXHIPqdJbRKG5OF81m11cE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750315821; c=relaxed/simple; bh=Eu6NvKMYNdmD8XfJnfUGiXHKuW5qDdQasrskHf5QPZ8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=V/WgSli1eBK3ILLfdWSsZOy1RuMdFR3qHgcdcPU5F4poYA5SPb04CRzlgj86u7sifm9uBC3Fnk7E6eRTBqobU/xlc+O6hLWpkIjA5emy/yDiub2vKidWYiH4aqLnOlmNwzuJTJGt3NEY4iYXwEQOSUaY+qFS1h1ICaqKv32l3L4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dq3gzpca; 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="dq3gzpca" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 08F3AC116D0; Thu, 19 Jun 2025 06:50:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1750315821; bh=Eu6NvKMYNdmD8XfJnfUGiXHKuW5qDdQasrskHf5QPZ8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dq3gzpca5BoYs3ihHNdTlUhvI/81TS2OWbjM6BidamCOFgLlMjIaaxJqmNDjd2tfd XCB8SD5BaViIQDIDL6RgOhlRTKw04oRPq+nvnpIUz3guULiIUVVtZoz5qGHDtSfH/2 UqXD5qRfe1x/ilmzJOjSXAXL8YSk768MlwUrz918oxM6fMKnDSC/CunO9SyxO2dMIC gEv9gNM1LYYX1qf9PEDvr/zuF/f8CpnZkhjzDJK9xgXjsEFLXMY2MTVFMmbF5ObRyR IhQnNW4m2wiHtVsA53eGkJHIfucD0a70CpyZ15rGDEvmqpvsHbjm9AC4Pl1p1UKcgV niC7U7PgG8zTw== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1uS96J-00000003dHU-113E; Thu, 19 Jun 2025 08:50:19 +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" , Randy Dunlap , 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 v7 15/17] docs: sphinx: add a file with the requirements for lowest version Date: Thu, 19 Jun 2025 08:49:08 +0200 Message-ID: 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" Those days, it is hard to install a virtual env that would build docs with Sphinx 3.4.3, as even python 3.13 is not compatible anymore with it. /usr/bin/python3.9 -m venv sphinx_3.4.3 . sphinx_3.4.3/bin/activate pip install -r Documentation/sphinx/min_requirements.txt Signed-off-by: Mauro Carvalho Chehab --- Documentation/doc-guide/sphinx.rst | 15 +++++++++++++++ Documentation/sphinx/min_requirements.txt | 8 ++++++++ 2 files changed, 23 insertions(+) create mode 100644 Documentation/sphinx/min_requirements.txt diff --git a/Documentation/doc-guide/sphinx.rst b/Documentation/doc-guide/s= phinx.rst index 5a91df105141..13943eb532ac 100644 --- a/Documentation/doc-guide/sphinx.rst +++ b/Documentation/doc-guide/sphinx.rst @@ -131,6 +131,21 @@ It supports two optional parameters: ``--no-virtualenv`` Use OS packaging for Sphinx instead of Python virtual environment. =20 +Installing Sphinx Minimal Version +--------------------------------- + +When changing Sphinx build system, it is important to ensure that +the minimal version will still be supported. Nowadays, it is +becoming harder to do that on modern distributions, as it is not +possible to install with Python 3.13 and above. + +The recommended way is to use the lowest supported Python version +as defined at Documentation/process/changes.rst, creating +a venv with it with, and install minimal requirements with:: + + /usr/bin/python3.9 -m venv sphinx_min + . sphinx_min/bin/activate + pip install -r Documentation/sphinx/min_requirements.txt =20 Sphinx Build =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D diff --git a/Documentation/sphinx/min_requirements.txt b/Documentation/sphi= nx/min_requirements.txt new file mode 100644 index 000000000000..89ea36d5798f --- /dev/null +++ b/Documentation/sphinx/min_requirements.txt @@ -0,0 +1,8 @@ +Sphinx=3D=3D3.4.3 +jinja2<3.1 +docutils<0.18 +sphinxcontrib-applehelp=3D=3D1.0.4 +sphinxcontrib-devhelp=3D=3D1.0.2 +sphinxcontrib-htmlhelp=3D=3D2.0.1 +sphinxcontrib-qthelp=3D=3D1.0.3 +sphinxcontrib-serializinghtml=3D=3D1.1.5 --=20 2.49.0 From nobody Thu Oct 9 06:50:10 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 8E3C0254AFE; Thu, 19 Jun 2025 06:50:21 +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=1750315821; cv=none; b=ZOJ+BvGTG6jv7I8WRj/nde4fxE2ZGiYVo++DbQry6u57hFUgOvV54Jq+FwpSitYkbomwDtLC+IxBcyOFeAufkUblQf5Xqrk+xnsaDWEYpvG3MyyH+1Zqyh8E1sIFAyq2ab/OFFFMB+f3nghQ84eVKkwP01Nfo9QBPtUAvset4w0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750315821; c=relaxed/simple; bh=EwIFpAi3HCDmOVRmQu64Rd5sg5y7yc/MvVhjn7Gv4Ig=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=nzktr3M/DgPZ655HNY0ysmMwNEHS47EqwXJn7hXHQOoc2JHQCFonYweiH9mxeQ1WetnL3oNOU6Gb0w+G4BtdW/O7/jvy9Hdt9kbxjXc1ZDTnj4/ANbG3CFjqJjVAK0Z8AoCVb/7vYqXBfgLJKByJhpMpRRS0Pk+UQzLlRMsJ9XA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dahwDe1b; 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="dahwDe1b" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0FB2DC19422; Thu, 19 Jun 2025 06:50:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1750315821; bh=EwIFpAi3HCDmOVRmQu64Rd5sg5y7yc/MvVhjn7Gv4Ig=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dahwDe1b5Q4C+NkIKgGhqv3qQuLKef4DY7VmW5wYFbN+6rGOsCVZ8NXb+P1i3wtlc int0aiG1OnZk+U8wXIOjrCqpNzd2wdHV8LVCvpsQW33K+o3AM9HvmJdzSOPOUfGAfy bqTQETcvNxKu7iyqO9YcJ6JYAktiKOaI6G+wQOuRvrhZrYtBzXBgdD6WsEeUZ8JpA3 ii8ZiPnue9+VC4yRyoCkBjE5jzgLn1/DL2tFF9uzbRlGUVe2OpNdy8Xp2RcRIfgj6j G19jSmMcb0yD5GfDo7mq75lOviaTbqqfyIBqKdA3PqeVhDmPX8VVG+jvSS3pqB+5lv 8579pQofJmDkA== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1uS96J-00000003dHY-18hE; Thu, 19 Jun 2025 08:50:19 +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 v7 16/17] docs: conf.py: several coding style fixes Date: Thu, 19 Jun 2025 08:49:09 +0200 Message-ID: <5df3f27dde61e0d0dcdb0d74be753662890c6886.1750315578.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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: Mauro Carvalho Chehab conf.py is missing a SPDX header and doesn't really have a proper python coding style. It also has an obsolete commented LaTeX syntax that doesn't work anymore. Clean it up a little bit with some help from autolints and manual adjustments. Signed-off-by: Mauro Carvalho Chehab --- Documentation/conf.py | 367 +++++++++++++++++++++--------------------- 1 file changed, 181 insertions(+), 186 deletions(-) diff --git a/Documentation/conf.py b/Documentation/conf.py index 6af61e26cec5..5eddf5885f77 100644 --- a/Documentation/conf.py +++ b/Documentation/conf.py @@ -1,24 +1,28 @@ -# -*- coding: utf-8 -*- -# -# The Linux Kernel documentation build configuration file, created by -# sphinx-quickstart on Fri Feb 12 13:51:46 2016. -# -# This file is execfile()d with the current directory set to its -# containing dir. -# -# Note that not all possible configuration values are present in this -# autogenerated file. -# -# All configuration values have a default; values that are commented out -# serve to show the default. +# SPDX-License-Identifier: GPL-2.0-only +# pylint: disable=3DC0103,C0209 + +""" +The Linux Kernel documentation build configuration file. +""" =20 -import sys import os -import sphinx import shutil +import sys + +import sphinx + +# If extensions (or modules to document with autodoc) are in another direc= tory, +# add these directories to sys.path here. If the directory is relative to = the +# documentation root, use os.path.abspath to make it absolute, like shown = here. +sys.path.insert(0, os.path.abspath("sphinx")) + +from load_config import loadConfig # pylint: disable=3DC0413= ,E0401 + +# Minimal supported version +needs_sphinx =3D "3.4.3" =20 # Get Sphinx version -major, minor, patch =3D sphinx.version_info[:3] +major, minor, patch =3D sphinx.version_info[:3] # pylint: disable= =3DI1101 =20 # Include_patterns were added on Sphinx 5.1 if (major < 5) or (major =3D=3D 5 and minor < 1): @@ -26,32 +30,32 @@ if (major < 5) or (major =3D=3D 5 and minor < 1): else: has_include_patterns =3D True # Include patterns that don't contain directory names, in glob format - include_patterns =3D ['**.rst'] + include_patterns =3D ["**.rst"] =20 # Location of Documentation/ directory -doctree =3D os.path.abspath('.') +doctree =3D os.path.abspath(".") =20 # Exclude of patterns that don't contain directory names, in glob format. exclude_patterns =3D [] =20 # List of patterns that contain directory names in glob format. dyn_include_patterns =3D [] -dyn_exclude_patterns =3D ['output'] +dyn_exclude_patterns =3D ["output"] =20 # Currently, only netlink/specs has a parser for yaml. # Prefer using include patterns if available, as it is faster if has_include_patterns: - dyn_include_patterns.append('netlink/specs/*.yaml') + dyn_include_patterns.append("netlink/specs/*.yaml") else: - dyn_exclude_patterns.append('netlink/*.yaml') - dyn_exclude_patterns.append('devicetree/bindings/**.yaml') - dyn_exclude_patterns.append('core-api/kho/bindings/**.yaml') + dyn_exclude_patterns.append("netlink/*.yaml") + dyn_exclude_patterns.append("devicetree/bindings/**.yaml") + dyn_exclude_patterns.append("core-api/kho/bindings/**.yaml") =20 # Properly handle include/exclude patterns # ---------------------------------------- =20 + def update_patterns(app): - """ On Sphinx, all directories are relative to what it is passed as SOURCEDIR parameter for sphinx-build. Due to that, all patterns @@ -62,15 +66,12 @@ def update_patterns(app): exclude relative patterns that start with "../". """ =20 - sourcedir =3D app.srcdir # full path to the source directory - builddir =3D os.environ.get("BUILDDIR") - # setup include_patterns dynamically if has_include_patterns: for p in dyn_include_patterns: full =3D os.path.join(doctree, p) =20 - rel_path =3D os.path.relpath(full, start =3D app.srcdir) + rel_path =3D os.path.relpath(full, start=3Dapp.srcdir) if rel_path.startswith("../"): continue =20 @@ -80,15 +81,17 @@ def update_patterns(app): for p in dyn_exclude_patterns: full =3D os.path.join(doctree, p) =20 - rel_path =3D os.path.relpath(full, start =3D app.srcdir) + rel_path =3D os.path.relpath(full, start=3Dapp.srcdir) if rel_path.startswith("../"): continue =20 app.config.exclude_patterns.append(rel_path) =20 + # helper # ------ =20 + def have_command(cmd): """Search ``cmd`` in the ``PATH`` environment. =20 @@ -97,24 +100,24 @@ def have_command(cmd): """ return shutil.which(cmd) is not None =20 -# If extensions (or modules to document with autodoc) are in another direc= tory, -# add these directories to sys.path here. If the directory is relative to = the -# documentation root, use os.path.abspath to make it absolute, like shown = here. -sys.path.insert(0, os.path.abspath('sphinx')) -from load_config import loadConfig =20 # -- General configuration ------------------------------------------------ =20 -# If your documentation needs a minimal Sphinx version, state it here. -needs_sphinx =3D '3.4.3' - -# Add any Sphinx extension module names here, as strings. They can be -# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom -# ones. -extensions =3D ['kerneldoc', 'rstFlatTable', 'kernel_include', - 'kfigure', 'sphinx.ext.ifconfig', 'automarkup', - 'maintainers_include', 'sphinx.ext.autosectionlabel', - 'kernel_abi', 'kernel_feat', 'translations', 'parser_yaml'] +# Add any Sphinx extensions in alphabetic order +extensions =3D [ + "automarkup", + "kernel_abi", + "kerneldoc", + "kernel_feat", + "kernel_include", + "kfigure", + "maintainers_include", + "parser_yaml", + "rstFlatTable", + "sphinx.ext.autosectionlabel", + "sphinx.ext.ifconfig", + "translations", +] =20 # Since Sphinx version 3, the C function parser is more pedantic with rega= rds # to type checking. Due to that, having macros at c:function cause problem= s. @@ -189,45 +192,45 @@ autosectionlabel_maxdepth =3D 2 # Load math renderer: # For html builder, load imgmath only when its dependencies are met. # mathjax is the default math renderer since Sphinx 1.8. -have_latex =3D have_command('latex') -have_dvipng =3D have_command('dvipng') +have_latex =3D have_command("latex") +have_dvipng =3D have_command("dvipng") load_imgmath =3D have_latex and have_dvipng =20 # Respect SPHINX_IMGMATH (for html docs only) -if 'SPHINX_IMGMATH' in os.environ: - env_sphinx_imgmath =3D os.environ['SPHINX_IMGMATH'] - if 'yes' in env_sphinx_imgmath: +if "SPHINX_IMGMATH" in os.environ: + env_sphinx_imgmath =3D os.environ["SPHINX_IMGMATH"] + if "yes" in env_sphinx_imgmath: load_imgmath =3D True - elif 'no' in env_sphinx_imgmath: + elif "no" in env_sphinx_imgmath: load_imgmath =3D False else: sys.stderr.write("Unknown env SPHINX_IMGMATH=3D%s ignored.\n" % en= v_sphinx_imgmath) =20 if load_imgmath: extensions.append("sphinx.ext.imgmath") - math_renderer =3D 'imgmath' + math_renderer =3D "imgmath" else: - math_renderer =3D 'mathjax' + math_renderer =3D "mathjax" =20 # Add any paths that contain templates here, relative to this directory. -templates_path =3D ['sphinx/templates'] +templates_path =3D ["sphinx/templates"] =20 # The suffixes of source filenames that will be automatically parsed source_suffix =3D { - '.rst': 'restructuredtext', - '.yaml': 'yaml', + ".rst": "restructuredtext", + ".yaml": "yaml", } =20 # The encoding of source files. -#source_encoding =3D 'utf-8-sig' +# source_encoding =3D 'utf-8-sig' =20 # The master toctree document. -master_doc =3D 'index' +master_doc =3D "index" =20 # General information about the project. -project =3D 'The Linux Kernel' -copyright =3D 'The kernel development community' -author =3D 'The kernel development community' +project =3D "The Linux Kernel" +copyright =3D "The kernel development community" # pylint: disable= =3DW0622 +author =3D "The kernel development community" =20 # The version info for the project you're documenting, acts as replacement= for # |version| and |release|, also used in various other places throughout the @@ -242,82 +245,86 @@ author =3D 'The kernel development community' try: makefile_version =3D None makefile_patchlevel =3D None - for line in open('../Makefile'): - key, val =3D [x.strip() for x in line.split('=3D', 2)] - if key =3D=3D 'VERSION': - makefile_version =3D val - elif key =3D=3D 'PATCHLEVEL': - makefile_patchlevel =3D val - if makefile_version and makefile_patchlevel: - break -except: + with open("../Makefile", encoding=3D"utf=3D8") as fp: + for line in fp: + key, val =3D [x.strip() for x in line.split("=3D", 2)] + if key =3D=3D "VERSION": + makefile_version =3D val + elif key =3D=3D "PATCHLEVEL": + makefile_patchlevel =3D val + if makefile_version and makefile_patchlevel: + break +except Exception: pass finally: if makefile_version and makefile_patchlevel: - version =3D release =3D makefile_version + '.' + makefile_patchlev= el + version =3D release =3D makefile_version + "." + makefile_patchlev= el else: version =3D release =3D "unknown version" =20 -# -# HACK: there seems to be no easy way for us to get at the version and -# release information passed in from the makefile...so go pawing through t= he -# command-line options and find it for ourselves. -# + def get_cline_version(): - c_version =3D c_release =3D '' + """ + HACK: There seems to be no easy way for us to get at the version and + release information passed in from the makefile...so go pawing through= the + command-line options and find it for ourselves. + """ + + c_version =3D c_release =3D "" for arg in sys.argv: - if arg.startswith('version=3D'): + if arg.startswith("version=3D"): c_version =3D arg[8:] - elif arg.startswith('release=3D'): + elif arg.startswith("release=3D"): c_release =3D arg[8:] if c_version: if c_release: - return c_version + '-' + c_release + return c_version + "-" + c_release return c_version - return version # Whatever we came up with before + return version # Whatever we came up with before + =20 # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. # # This is also used if you do content translation via gettext catalogs. # Usually you set "language" from the command line for these cases. -language =3D 'en' +language =3D "en" =20 # There are two options for replacing |today|: either, you set today to so= me # non-false value, then it is used: -#today =3D '' +# today =3D '' # Else, today_fmt is used as the format for a strftime call. -#today_fmt =3D '%B %d, %Y' +# today_fmt =3D '%B %d, %Y' =20 # The reST default role (used for this markup: `text`) to use for all # documents. -#default_role =3D None +# default_role =3D None =20 # If true, '()' will be appended to :func: etc. cross-reference text. -#add_function_parentheses =3D True +# add_function_parentheses =3D True =20 # If true, the current module name will be prepended to all description # unit titles (such as .. function::). -#add_module_names =3D True +# add_module_names =3D True =20 # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. -#show_authors =3D False +# show_authors =3D False =20 # The name of the Pygments (syntax highlighting) style to use. -pygments_style =3D 'sphinx' +pygments_style =3D "sphinx" =20 # A list of ignored prefixes for module index sorting. -#modindex_common_prefix =3D [] +# modindex_common_prefix =3D [] =20 # If true, keep warnings as "system message" paragraphs in the built docum= ents. -#keep_warnings =3D False +# keep_warnings =3D False =20 # If true, `todo` and `todoList` produce output, else they produce nothing. todo_include_todos =3D False =20 -primary_domain =3D 'c' -highlight_language =3D 'none' +primary_domain =3D "c" +highlight_language =3D "none" =20 # -- Options for HTML output ---------------------------------------------- =20 @@ -325,43 +332,45 @@ highlight_language =3D 'none' # a list of builtin themes. =20 # Default theme -html_theme =3D 'alabaster' +html_theme =3D "alabaster" html_css_files =3D [] =20 if "DOCS_THEME" in os.environ: html_theme =3D os.environ["DOCS_THEME"] =20 -if html_theme =3D=3D 'sphinx_rtd_theme' or html_theme =3D=3D 'sphinx_rtd_d= ark_mode': +if html_theme in ["sphinx_rtd_theme", "sphinx_rtd_dark_mode"]: # Read the Docs theme try: import sphinx_rtd_theme + html_theme_path =3D [sphinx_rtd_theme.get_html_theme_path()] =20 # Add any paths that contain custom static files (such as style sh= eets) here, # relative to this directory. They are copied after the builtin st= atic files, # so a file named "default.css" will overwrite the builtin "defaul= t.css". html_css_files =3D [ - 'theme_overrides.css', + "theme_overrides.css", ] =20 # Read the Docs dark mode override theme - if html_theme =3D=3D 'sphinx_rtd_dark_mode': + if html_theme =3D=3D "sphinx_rtd_dark_mode": try: - import sphinx_rtd_dark_mode - extensions.append('sphinx_rtd_dark_mode') + import sphinx_rtd_dark_mode # pylint: disable= =3DW0611 + + extensions.append("sphinx_rtd_dark_mode") except ImportError: - html_theme =3D=3D 'sphinx_rtd_theme' + html_theme =3D "sphinx_rtd_theme" =20 - if html_theme =3D=3D 'sphinx_rtd_theme': - # Add color-specific RTD normal mode - html_css_files.append('theme_rtd_colors.css') + if html_theme =3D=3D "sphinx_rtd_theme": + # Add color-specific RTD normal mode + html_css_files.append("theme_rtd_colors.css") =20 html_theme_options =3D { - 'navigation_depth': -1, + "navigation_depth": -1, } =20 except ImportError: - html_theme =3D 'alabaster' + html_theme =3D "alabaster" =20 if "DOCS_CSS" in os.environ: css =3D os.environ["DOCS_CSS"].split(" ") @@ -369,14 +378,14 @@ if "DOCS_CSS" in os.environ: for l in css: html_css_files.append(l) =20 -if html_theme =3D=3D 'alabaster': +if html_theme =3D=3D "alabaster": html_theme_options =3D { - 'description': get_cline_version(), - 'page_width': '65em', - 'sidebar_width': '15em', - 'fixed_sidebar': 'true', - 'font_size': 'inherit', - 'font_family': 'serif', + "description": get_cline_version(), + "page_width": "65em", + "sidebar_width": "15em", + "fixed_sidebar": "true", + "font_size": "inherit", + "font_family": "serif", } =20 sys.stderr.write("Using %s theme\n" % html_theme) @@ -384,104 +393,79 @@ sys.stderr.write("Using %s theme\n" % html_theme) # Add any paths that contain custom static files (such as style sheets) he= re, # relative to this directory. They are copied after the builtin static fil= es, # so a file named "default.css" will overwrite the builtin "default.css". -html_static_path =3D ['sphinx-static'] +html_static_path =3D ["sphinx-static"] =20 # If true, Docutils "smart quotes" will be used to convert quotes and dash= es # to typographically correct entities. However, conversion of "--" to "= =E2=80=94" # is not always what we want, so enable only quotes. -smartquotes_action =3D 'q' +smartquotes_action =3D "q" =20 # Custom sidebar templates, maps document names to template names. # Note that the RTD theme ignores this -html_sidebars =3D { '**': ['searchbox.html', 'kernel-toc.html', 'sourcelin= k.html']} +html_sidebars =3D {"**": ["searchbox.html", + "kernel-toc.html", + "sourcelink.html"]} =20 # about.html is available for alabaster theme. Add it at the front. -if html_theme =3D=3D 'alabaster': - html_sidebars['**'].insert(0, 'about.html') +if html_theme =3D=3D "alabaster": + html_sidebars["**"].insert(0, "about.html") =20 # The name of an image file (relative to this directory) to place at the t= op # of the sidebar. -html_logo =3D 'images/logo.svg' +html_logo =3D "images/logo.svg" =20 # Output file base name for HTML help builder. -htmlhelp_basename =3D 'TheLinuxKerneldoc' +htmlhelp_basename =3D "TheLinuxKerneldoc" =20 # -- Options for LaTeX output --------------------------------------------- =20 latex_elements =3D { # The paper size ('letterpaper' or 'a4paper'). - 'papersize': 'a4paper', - + "papersize": "a4paper", # The font size ('10pt', '11pt' or '12pt'). - 'pointsize': '11pt', - + "pointsize": "11pt", # Latex figure (float) alignment - #'figure_align': 'htbp', - + # 'figure_align': 'htbp', # Don't mangle with UTF-8 chars - 'inputenc': '', - 'utf8extra': '', - + "inputenc": "", + "utf8extra": "", # Set document margins - 'sphinxsetup': ''' + "sphinxsetup": """ hmargin=3D0.5in, vmargin=3D1in, parsedliteralwraps=3Dtrue, verbatimhintsturnover=3Dfalse, - ''', - + """, # # Some of our authors are fond of deep nesting; tell latex to # cope. # - 'maxlistdepth': '10', - + "maxlistdepth": "10", # For CJK One-half spacing, need to be in front of hyperref - 'extrapackages': r'\usepackage{setspace}', - + "extrapackages": r"\usepackage{setspace}", # Additional stuff for the LaTeX preamble. - 'preamble': ''' + "preamble": """ % Use some font with UTF-8 support with XeLaTeX \\usepackage{fontspec} \\setsansfont{DejaVu Sans} \\setromanfont{DejaVu Serif} \\setmonofont{DejaVu Sans Mono} - ''', + """, } =20 # Load kerneldoc specific LaTeX settings -latex_elements['preamble'] +=3D ''' +latex_elements["preamble"] +=3D """ % Load kerneldoc specific LaTeX settings - \\input{kerneldoc-preamble.sty} -''' - -# With Sphinx 1.6, it is possible to change the Bg color directly -# by using: -# \definecolor{sphinxnoteBgColor}{RGB}{204,255,255} -# \definecolor{sphinxwarningBgColor}{RGB}{255,204,204} -# \definecolor{sphinxattentionBgColor}{RGB}{255,255,204} -# \definecolor{sphinximportantBgColor}{RGB}{192,255,204} -# -# However, it require to use sphinx heavy box with: -# -# \renewenvironment{sphinxlightbox} {% -# \\begin{sphinxheavybox} -# } -# \\end{sphinxheavybox} -# } -# -# Unfortunately, the implementation is buggy: if a note is inside a -# table, it isn't displayed well. So, for now, let's use boring -# black and white notes. + \\input{kerneldoc-preamble.sty} +""" =20 # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). # Sorted in alphabetical order -latex_documents =3D [ -] +latex_documents =3D [] =20 # Add all other index files from Documentation/ subdirectories -for fn in os.listdir('.'): +for fn in os.listdir("."): doc =3D os.path.join(fn, "index") if os.path.exists(doc + ".rst"): has =3D False @@ -490,34 +474,39 @@ for fn in os.listdir('.'): has =3D True break if not has: - latex_documents.append((doc, fn + '.tex', - 'Linux %s Documentation' % fn.capitali= ze(), - 'The kernel development community', - 'manual')) + latex_documents.append( + ( + doc, + fn + ".tex", + "Linux %s Documentation" % fn.capitalize(), + "The kernel development community", + "manual", + ) + ) =20 # The name of an image file (relative to this directory) to place at the t= op of # the title page. -#latex_logo =3D None +# latex_logo =3D None =20 # For "manual" documents, if this is true, then toplevel headings are part= s, # not chapters. -#latex_use_parts =3D False +# latex_use_parts =3D False =20 # If true, show page references after internal links. -#latex_show_pagerefs =3D False +# latex_show_pagerefs =3D False =20 # If true, show URL addresses after external links. -#latex_show_urls =3D False +# latex_show_urls =3D False =20 # Documents to append as an appendix to all manuals. -#latex_appendices =3D [] +# latex_appendices =3D [] =20 # If false, no module index is generated. -#latex_domain_indices =3D True +# latex_domain_indices =3D True =20 # Additional LaTeX stuff to be copied to build directory latex_additional_files =3D [ - 'sphinx/kerneldoc-preamble.sty', + "sphinx/kerneldoc-preamble.sty", ] =20 =20 @@ -526,12 +515,11 @@ latex_additional_files =3D [ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages =3D [ - (master_doc, 'thelinuxkernel', 'The Linux Kernel Documentation', - [author], 1) + (master_doc, "thelinuxkernel", "The Linux Kernel Documentation", [auth= or], 1) ] =20 # If true, show URL addresses after external links. -#man_show_urls =3D False +# man_show_urls =3D False =20 =20 # -- Options for Texinfo output ------------------------------------------- @@ -539,11 +527,15 @@ man_pages =3D [ # Grouping the document tree into Texinfo files. List of tuples # (source start file, target name, title, author, # dir menu entry, description, category) -texinfo_documents =3D [ - (master_doc, 'TheLinuxKernel', 'The Linux Kernel Documentation', - author, 'TheLinuxKernel', 'One line description of project.', - 'Miscellaneous'), -] +texinfo_documents =3D [( + master_doc, + "TheLinuxKernel", + "The Linux Kernel Documentation", + author, + "TheLinuxKernel", + "One line description of project.", + "Miscellaneous", + ),] =20 # -- Options for Epub output ---------------------------------------------- =20 @@ -554,9 +546,9 @@ epub_publisher =3D author epub_copyright =3D copyright =20 # A list of files that should not be packed into the epub file. -epub_exclude_files =3D ['search.html'] +epub_exclude_files =3D ["search.html"] =20 -#=3D=3D=3D=3D=3D=3D=3D +# =3D=3D=3D=3D=3D=3D=3D # rst2pdf # # Grouping the document tree into PDF files. List of tuples @@ -568,14 +560,14 @@ epub_exclude_files =3D ['search.html'] # multiple PDF files here actually tries to get the cross-referencing right # *between* PDF files. pdf_documents =3D [ - ('kernel-documentation', u'Kernel', u'Kernel', u'J. Random Bozo'), + ("kernel-documentation", "Kernel", "Kernel", "J. Random Bozo"), ] =20 # kernel-doc extension configuration for running Sphinx directly (e.g. by = Read # the Docs). In a normal build, these are supplied from the Makefile via c= ommand # line arguments. -kerneldoc_bin =3D '../scripts/kernel-doc.py' -kerneldoc_srctree =3D '..' +kerneldoc_bin =3D "../scripts/kernel-doc.py" +kerneldoc_srctree =3D ".." =20 # ------------------------------------------------------------------------= ------ # Since loadConfig overwrites settings from the global namespace, it has t= o be @@ -583,5 +575,8 @@ kerneldoc_srctree =3D '..' # ------------------------------------------------------------------------= ------ loadConfig(globals()) =20 + def setup(app): - app.connect('builder-inited', update_patterns) + """Patterns need to be updated at init time on older Sphinx versions""" + + app.connect("builder-inited", update_patterns) --=20 2.49.0 From nobody Thu Oct 9 06:50:10 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 88FCC253959; Thu, 19 Jun 2025 06:50:21 +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=1750315821; cv=none; b=tpY8ekRtmxW5EKAyiQPYPDtAY4M5rsTnCJGD1fQAvIgqJXHZplKe9aEegaDULk7SzUu11V4QMLhB1VJRG+ZZz0HQj9ZauyY8oGw6qEsOBb+jv4lwqk0H0gzjnDLgLAXHccn0Dqv2ej30l9wsNWuXtHKQRWdhOLr7CkO4NKj55J4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750315821; c=relaxed/simple; bh=4NisMpZH9SoZ5VV4u6jFkhlkA+lqE03MPhW7QcfYJIs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GpgNsgbZFaFNTde9MBGPPeBlqP5y/L+KpaHLyEK+hghI4EtRZOZ0Hm8pNhJZEKGDETyMBfheE6vDsWaRsVfR/ns9kSgiNn0Qa8gZkr7FO3LGzlpfCSd0m4ewwEd6/n5wx5N6NULIM4qm6VLP398MxBFxlkonrIKNSV4qtVbEHZE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=IimrqQdi; 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="IimrqQdi" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1AA05C19424; Thu, 19 Jun 2025 06:50:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1750315821; bh=4NisMpZH9SoZ5VV4u6jFkhlkA+lqE03MPhW7QcfYJIs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IimrqQdiUejm+wBblyRRTg9HZcr+2iaV49ANTlPsNNx0zs93yGxnDtI/Cb8IeQHHx xa8pBTEpSS1n56wI4IgWeyBHCVuxHMJEPmpIG/xRn8JFtfZmJOerxntvR3gV29bV8X CYaay9TE4gQ1sHmq13+OtupdxdHXmm+As9sA16UO/JFpk93dsYGaOXUxeys4KvTJY/ duNCnzf3pORXb456NAOpc9Dy6zruowkPUAxYQo/UDod1du1SZkQzQ0hK6n/iANYOy9 Pm4v7KPG1+GX6YZPf1+u/zJ1+0Q5iICJCAPKhVjZP0dHoMl+HijwHPF5UGwAS/wBX6 W5/BC6MlZrvJQ== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1uS96J-00000003dHc-1GDW; Thu, 19 Jun 2025 08:50:19 +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 v7 17/17] docs: conf.py: Check Sphinx and docutils version Date: Thu, 19 Jun 2025 08:49:10 +0200 Message-ID: <8719d77d3a6ef30dff58f959dad5dd973496eeea.1750315578.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" As reported by Akira, there are incompatibility issues with Sphinx and docutils. I manually checked that before docutils 0.17.1, yaml generation doesn't work properly. Akira checked that 0.19 is problematic too. After check Sphinx release notes, it seems that the versions that are supposed to cope well together are: =3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D Sphinx Min Docutils Max Docutils Version Version Version -------- ------------ ------------ < 4.0.0 0.17.1 0.17.1 < 6.0.0 0.17.1 0.18.1 < 7.0.0 0.18.0 0.18.1 >=3D 7.0.0 0.20.0 0.21.2 =3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D Add a logic inside conf.py to check the above, emitting warnings if the docutils version don't match what is known to be supported. Reported-by: Akira Yokosawa Closes: https://lore.kernel.org/linux-doc/6fcb75ee-61db-4fb3-9c5f-2029a7fea= 4ee@gmail.com/ Signed-off-by: Mauro Carvalho Chehab --- Documentation/conf.py | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/Documentation/conf.py b/Documentation/conf.py index 5eddf5885f77..6047ec85add1 100644 --- a/Documentation/conf.py +++ b/Documentation/conf.py @@ -9,7 +9,11 @@ import os import shutil import sys =20 +import docutils import sphinx +from sphinx.util import logging + +logger =3D logging.getLogger(__name__) =20 # If extensions (or modules to document with autodoc) are in another direc= tory, # add these directories to sys.path here. If the directory is relative to = the @@ -21,11 +25,34 @@ from load_config import loadConfig # pyli= nt: disable=3DC0413,E0401 # Minimal supported version needs_sphinx =3D "3.4.3" =20 -# Get Sphinx version -major, minor, patch =3D sphinx.version_info[:3] # pylint: disable= =3DI1101 +# Get Sphinx and docutils versions +sphinx_ver =3D sphinx.version_info[:3] # pylint: disable=3DI1101 +docutils_ver =3D docutils.__version_info__[:3] + +# +if sphinx_ver < (4, 0, 0): + min_docutils =3D (0, 16, 0) + max_docutils =3D (0, 17, 1) +elif sphinx_ver < (6, 0, 0): + min_docutils =3D (0, 17, 0) + max_docutils =3D (0, 18, 1) +elif sphinx_ver < (7, 0, 0): + min_docutils =3D (0, 18, 0) + max_docutils =3D (0, 18, 1) +else: + min_docutils =3D (0, 20, 0) + max_docutils =3D (0, 21, 2) + +sphinx_ver_str =3D ".".join([str(x) for x in sphinx_ver]) +docutils_ver_str =3D ".".join([str(x) for x in docutils_ver]) + +if docutils_ver < min_docutils: + logger.warning(f"Docutils {docutils_ver_str} is too old for Sphinx {sp= hinx_ver_str}. Doc generation may fail") +elif docutils_ver > max_docutils: + logger.warning(f"Docutils {docutils_ver_str} could be too new for Sphi= nx {sphinx_ver_str}. Doc generation may fail") =20 # Include_patterns were added on Sphinx 5.1 -if (major < 5) or (major =3D=3D 5 and minor < 1): +if sphinx_ver < (5, 1, 0): has_include_patterns =3D False else: has_include_patterns =3D True --=20 2.49.0