From nobody Sat Oct 4 01:43:24 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 E280A2857F7; Thu, 21 Aug 2025 14:21:39 +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=1755786100; cv=none; b=pxY7T9luwTGbR55Dna40FH2ZBuoLJ0xGsuNxU93/YK+AM01EA8fHP1XW7PIxLxv6wC/Ij7uXVzF9/npoGvdgf7+xnZvEdqCNviuh5OYvSSu9DcuNrTaEduiP1lIvaiPJr8w1gKKE1h0snzl2kJgdwnZRHAVooKV1uUEV4c3qijI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755786100; c=relaxed/simple; bh=LQfriqJ7w45m1TsmRVR1XR73bImTQyUEqk93YtSCuzA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=N8XPqzh21EX9QPpYlZyiZlxpYyuzZHupActfJPI91rWqVmRvNvmx9KZw963CgTIntYYM39wQgXSBJir931XKFhvsZ/dXNTuDG0fTTANoP7D64IdrWkqGO0DYKyvUdkSvoCa0OinYASPHlvG91XB3x0Pv+cwJsBdyuOjIn8BIykE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=HrSDWfIf; 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="HrSDWfIf" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4D934C2BCF5; Thu, 21 Aug 2025 14:21:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1755786099; bh=LQfriqJ7w45m1TsmRVR1XR73bImTQyUEqk93YtSCuzA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HrSDWfIf7ufCni7PxZ62/b7X3KzBuHr3HM03lebFs6XM9xW98cOU+TplnNkMgCi1d kyx2B39dd6dIqq/LaBPX0pf9c+whwhkjz/BugfmXqYA7v9gk+3Q1FWeTSswzBWgLO7 gkcZgyanlORJ1W5VX7ZVZyCU6dLvYThv9wGu3wfh8J3yFxe3/MfwuBHry8dZBRFJ9k eptdpIda1A7cMJY76XXOSfGp3Y93DzPdVvrPORrhrozdSmz3LELXVhrYDceuUUOyDz JGzLZWMNW/Qvabcl32hLlsBLaAvHR2kReC5OjOMOTK5UnGmOvGU7Bg4+/UBPsEz8Cf Bq3UlqEqMT2TQ== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1up6Ab-0000000BT9M-2DIg; Thu, 21 Aug 2025 16:21:37 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Jonathan Corbet Cc: Mauro Carvalho Chehab , Kees Cook , linux-kernel@vger.kernel.org Subject: [PATCH 21/24] docs: kernel_include.py: remove Include class inheritance Date: Thu, 21 Aug 2025 16:21:27 +0200 Message-ID: <69206f9a5709c39591be515397fde851658eedc0.1755784930.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.50.1 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" While the original code came from the Sphinx Include class, such class is monolithic: it has only one function that does everything, and 3 variables that are used: - required_arguments - optional_arguments - option_spec So, basically those are the only members that remain from the original class, but hey! Those are the same vars that every other Sphinx directive extension has to define! In summary, keeping inheritance here doesn't make much sense. Worse than that, kernel-include doesn't support the current set of options that the original Include class has, but it also has its own set of options. So, let's fill in the argument vars with what it does support, dropping the rest. Signed-off-by: Mauro Carvalho Chehab --- Documentation/sphinx/kernel_include.py | 40 ++++++++++++++++++++------ 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/Documentation/sphinx/kernel_include.py b/Documentation/sphinx/= kernel_include.py index 3a1753486319..e6f734476ab3 100755 --- a/Documentation/sphinx/kernel_include.py +++ b/Documentation/sphinx/kernel_include.py @@ -62,9 +62,8 @@ import sys from docutils import io, nodes, statemachine from docutils.statemachine import ViewList from docutils.utils.error_reporting import SafeString, ErrorString -from docutils.parsers.rst import directives +from docutils.parsers.rst import Directive, directives from docutils.parsers.rst.directives.body import CodeBlock, NumberLines -from docutils.parsers.rst.directives.misc import Include =20 from sphinx.util import logging =20 @@ -81,18 +80,43 @@ RE_SIMPLE_REF =3D re.compile(r'`([^`]+)`') =20 =20 # =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=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=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D -class KernelInclude(Include): - """KernelInclude (``kernel-include``) directive""" +class KernelInclude(Directive): + """ + KernelInclude (``kernel-include``) directive =20 - # Add extra options - option_spec =3D Include.option_spec.copy() + Most of the stuff here came from Include directive defined at: + docutils/parsers/rst/directives/misc.py =20 - option_spec.update({ + Yet, overriding the class don't has any benefits: the original class + only have run() and argument list. Not all of them are implemented, + when checked against latest Sphinx version, as with time more arguments + were added. + + So, keep its own list of supported arguments + """ + + required_arguments =3D 1 + optional_arguments =3D 0 + final_argument_whitespace =3D True + option_spec =3D { + 'literal': directives.flag, + 'code': directives.unchanged, + 'encoding': directives.encoding, + 'tab-width': int, + 'start-line': int, + 'end-line': int, + 'start-after': directives.unchanged_required, + 'end-before': directives.unchanged_required, + # ignored except for 'literal' or 'code': + 'number-lines': directives.unchanged, # integer or None + 'class': directives.class_option, + + # Arguments that aren't from Sphinx Include directive 'generate-cross-refs': directives.flag, 'warn-broken': directives.flag, 'toc': directives.flag, 'exception-file': directives.unchanged, - }) + } =20 def read_rawtext(self, path, encoding): """Read and process file content with error handling""" --=20 2.50.1