mirror of
https://github.com/torvalds/linux.git
synced 2026-04-18 14:53:58 -04:00
docs: kdoc: better handle source when producing YAML output
The current logic was storing symbols source code on a list, not linked to the actual KdocItem. While this works fine when kernel-doc markups are OK, on places where there is a "/**" without a valid kernel-doc markup, it ends that the 1:1 match between source code and KdocItem doesn't happen, causing problems to generate the YAML output. Fix it by storing the source code directly into the KdocItem structure. This shouldn't affect performance or memory footprint, except when --yaml option is used. While here, add a __repr__() function for KdocItem, as it helps debugging it. Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Signed-off-by: Jonathan Corbet <corbet@lwn.net> Message-ID: <77902dafabb5c3250486aa2dc1568d5fafa95c5b.1774256269.git.mchehab+huawei@kernel.org>
This commit is contained in:
committed by
Jonathan Corbet
parent
8326e4a218
commit
99ec67a998
@@ -14,7 +14,8 @@ class KdocItem:
|
||||
then pass into the output modules.
|
||||
"""
|
||||
|
||||
def __init__(self, name, fname, type, start_line, **other_stuff):
|
||||
def __init__(self, name, fname, type, start_line,
|
||||
**other_stuff):
|
||||
self.name = name
|
||||
self.fname = fname
|
||||
self.type = type
|
||||
@@ -60,6 +61,9 @@ class KdocItem:
|
||||
def __getitem__(self, key):
|
||||
return self.get(key)
|
||||
|
||||
def __repr__(self):
|
||||
return f"KdocItem({self.name}, {self.fname}, {self.type}, {self.declaration_start_line})"
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, d):
|
||||
"""Create a KdocItem from a plain dict."""
|
||||
|
||||
Reference in New Issue
Block a user