xref: /linux/scripts/lib/kdoc/kdoc_item.py (revision 60016e0116b8d33f95e797b011799e717766ec13)
1# SPDX-License-Identifier: GPL-2.0
2#
3# A class that will, eventually, encapsulate all of the parsed data that we
4# then pass into the output modules.
5#
6
7class KdocItem:
8    def __init__(self, name, type, start_line, **other_stuff):
9        self.name = name
10        self.type = type
11        self.declaration_start_line = start_line
12        #
13        # Just save everything else into our own dict so that the output
14        # side can grab it directly as before.  As we move things into more
15        # structured data, this will, hopefully, fade away.
16        #
17        self.other_stuff = other_stuff
18
19    def get(self, key, default = None):
20        ret = self.other_stuff.get(key, default)
21        if ret == default:
22            return self.__dict__.get(key, default)
23        return ret
24
25    def __getitem__(self, key):
26        return self.get(key)
27