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 self.sections = {} 13 self.sections_start_lines = {} 14 self.parameterlist = [] 15 self.parameterdesc_start_lines = [] 16 self.parameterdescs = {} 17 self.parametertypes = {} 18 # 19 # Just save everything else into our own dict so that the output 20 # side can grab it directly as before. As we move things into more 21 # structured data, this will, hopefully, fade away. 22 # 23 self.other_stuff = other_stuff 24 25 def get(self, key, default = None): 26 ret = self.other_stuff.get(key, default) 27 if ret == default: 28 return self.__dict__.get(key, default) 29 return ret 30 31 def __getitem__(self, key): 32 return self.get(key) 33 34 # 35 # Tracking of section and parameter information. 36 # 37 def set_sections(self, sections, start_lines): 38 self.sections = sections 39 self.section_start_lines = start_lines 40 41 def set_params(self, names, descs, types, starts): 42 self.parameterlist = names 43 self.parameterdescs = descs 44 self.parametertypes = types 45 self.parameterdesc_start_lines = starts 46