From nobody Mon Apr 6 20:13:02 2026 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 C2E7D39F169; Wed, 18 Mar 2026 09:11: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=1773825080; cv=none; b=oRGDPkaut8b2yJCOUnjWjj6OUGcJ6JmI22n7f0ObqdiXq1zQeWBrNhXuQ+VAaur5+cH4myyxePBA3ZjEO5wuQUFgegAZ35rJDwFJ6VKoXvClo8wst9+vd2BAxL1Fo28uMZzIv4mj3+inFVY9uhJdGzLxV4OtvsyBnHnYfeEcSCw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773825080; c=relaxed/simple; bh=nBQ14W9/TnksHUfJjA8FVeDj3iQtD4VD4UidbU9q+Pw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=DXozSXvBwmOAd83anAcJzATBO4dXMceSoPkEfOJddvJESAkO6Wv1nDnEFXIjAOY/3y5lPrVFmfO8G65p5s1//1ouh9OuuAHHQoxJbzmetRYZZANZwb9Xo7L35UheqfMzlQwlSTAd5YLXDE+dV01CUe7n99MLXRsrH/3qg2SKSgU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=MPICeKuq; 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="MPICeKuq" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 65C35C2BC87; Wed, 18 Mar 2026 09:11:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1773825080; bh=nBQ14W9/TnksHUfJjA8FVeDj3iQtD4VD4UidbU9q+Pw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MPICeKuq7ZktL64ab2ev/n6bMNvRYlt02pOtbtgYdSMtOMLD4tWMZhJZEArhNI4ID S9wrX048aUV3quXYNdMar6rXZlz0BWxVBG+cx+XgxeVYCgUc3QQQWBfSFUdVhHxSoU hCbMhPoyGKZiyZnNke3WP2tGTvynoVJJPf424Z/YCFl2mMSOJrDJ7imLUbGOxdHkt7 fZdA+aq4BK2zRuPPP5sSrUVzmS4+UkJtwORBQ8AIfHE9Omz7oLgCMIQ6ERtFIUi46d uyVc52t147YJxDVKYQNPQvfyb1AetJRLFE9P+xPDPEP5qUCkntbFxUJkb+ud0UxNeq Qm0lPb4ui2Qcw== Received: from mchehab by mail.kernel.org with local (Exim 4.99.1) (envelope-from ) id 1w2mvu-00000002fpi-2eOa; Wed, 18 Mar 2026 10:11:18 +0100 From: Mauro Carvalho Chehab To: Jonathan Corbet , Linux Doc Mailing List Cc: Mauro Carvalho Chehab , linux-kernel@vger.kernel.org, Mauro Carvalho Chehab Subject: [PATCH 07/14] docs: kdoc_item: add support to generate a KdocItem from a dict Date: Wed, 18 Mar 2026 10:11:07 +0100 Message-ID: X-Mailer: git-send-email 2.53.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 When reading the contents on a KdocItem using YAML, the data will be imported into a dict. Add a method to create a new KdocItem from a dict to allow converting such input into a real KdocItem. While here, address an issue that, if the class is initialized with an internal parameter outside the 4 initial arguments, it would end being added inside other_stuff, which breaks initializing it from a dict. Signed-off-by: Mauro Carvalho Chehab --- tools/lib/python/kdoc/kdoc_item.py | 35 +++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/tools/lib/python/kdoc/kdoc_item.py b/tools/lib/python/kdoc/kdo= c_item.py index c0585cdbcbd1..5f41790efacb 100644 --- a/tools/lib/python/kdoc/kdoc_item.py +++ b/tools/lib/python/kdoc/kdoc_item.py @@ -25,12 +25,31 @@ class KdocItem: self.parameterdesc_start_lines =3D {} self.parameterdescs =3D {} self.parametertypes =3D {} + + self.warnings =3D [] + # # Just save everything else into our own dict so that the output # side can grab it directly as before. As we move things into more # structured data, this will, hopefully, fade away. # - self.other_stuff =3D other_stuff + known_keys =3D { + 'declaration_start_line', + 'sections', + 'sections_start_lines', + 'parameterlist', + 'parameterdesc_start_lines', + 'parameterdescs', + 'parametertypes', + 'warnings', + } + + self.other_stuff =3D {} + for k, v in other_stuff.items(): + if k in known_keys: + setattr(self, k, v) # real attribute + else: + self.other_stuff[k] =3D v =20 def get(self, key, default =3D None): """ @@ -41,6 +60,20 @@ class KdocItem: def __getitem__(self, key): return self.get(key) =20 + @classmethod + def from_dict(cls, d): + """Create a KdocItem from a plain dict.""" + + cp =3D d.copy() + name =3D cp.pop('name', None) + fname =3D cp.pop('fname', None) + type =3D cp.pop('type', None) + start_line =3D cp.pop('start_line', 1) + other_stuff =3D cp.pop('other_stuff', {}) + + # Everything that=E2=80=99s left goes straight to __init__ + return cls(name, fname, type, start_line, **cp, **other_stuff) + # # Tracking of section and parameter information. # --=20 2.53.0