160016e01SJonathan Corbet# SPDX-License-Identifier: GPL-2.0 260016e01SJonathan Corbet# 360016e01SJonathan Corbet# A class that will, eventually, encapsulate all of the parsed data that we 460016e01SJonathan Corbet# then pass into the output modules. 560016e01SJonathan Corbet# 660016e01SJonathan Corbet 7*f40bba94SMauro Carvalho Chehab""" 8*f40bba94SMauro Carvalho ChehabData class to store a kernel-doc Item. 9*f40bba94SMauro Carvalho Chehab""" 10*f40bba94SMauro Carvalho Chehab 1160016e01SJonathan Corbetclass KdocItem: 12*f40bba94SMauro Carvalho Chehab """ 13*f40bba94SMauro Carvalho Chehab A class that will, eventually, encapsulate all of the parsed data that we 14*f40bba94SMauro Carvalho Chehab then pass into the output modules. 15*f40bba94SMauro Carvalho Chehab """ 16*f40bba94SMauro Carvalho Chehab 172bd22194SMauro Carvalho Chehab def __init__(self, name, fname, type, start_line, **other_stuff): 1860016e01SJonathan Corbet self.name = name 192bd22194SMauro Carvalho Chehab self.fname = fname 2060016e01SJonathan Corbet self.type = type 2160016e01SJonathan Corbet self.declaration_start_line = start_line 228d733875SJonathan Corbet self.sections = {} 238d733875SJonathan Corbet self.sections_start_lines = {} 24de6f7ac9SJonathan Corbet self.parameterlist = [] 25de6f7ac9SJonathan Corbet self.parameterdesc_start_lines = [] 26de6f7ac9SJonathan Corbet self.parameterdescs = {} 27de6f7ac9SJonathan Corbet self.parametertypes = {} 2860016e01SJonathan Corbet # 2960016e01SJonathan Corbet # Just save everything else into our own dict so that the output 3060016e01SJonathan Corbet # side can grab it directly as before. As we move things into more 3160016e01SJonathan Corbet # structured data, this will, hopefully, fade away. 3260016e01SJonathan Corbet # 3360016e01SJonathan Corbet self.other_stuff = other_stuff 3460016e01SJonathan Corbet 3560016e01SJonathan Corbet def get(self, key, default = None): 36*f40bba94SMauro Carvalho Chehab """ 37*f40bba94SMauro Carvalho Chehab Get a value from optional keys. 38*f40bba94SMauro Carvalho Chehab """ 39bd5628bfSJonathan Corbet return self.other_stuff.get(key, default) 4060016e01SJonathan Corbet 4160016e01SJonathan Corbet def __getitem__(self, key): 4260016e01SJonathan Corbet return self.get(key) 438d733875SJonathan Corbet 448d733875SJonathan Corbet # 45de6f7ac9SJonathan Corbet # Tracking of section and parameter information. 468d733875SJonathan Corbet # 478d733875SJonathan Corbet def set_sections(self, sections, start_lines): 48*f40bba94SMauro Carvalho Chehab """ 49*f40bba94SMauro Carvalho Chehab Set sections and start lines. 50*f40bba94SMauro Carvalho Chehab """ 518d733875SJonathan Corbet self.sections = sections 528d733875SJonathan Corbet self.section_start_lines = start_lines 53de6f7ac9SJonathan Corbet 54de6f7ac9SJonathan Corbet def set_params(self, names, descs, types, starts): 55*f40bba94SMauro Carvalho Chehab """ 56*f40bba94SMauro Carvalho Chehab Set parameter list: names, descriptions, types and start lines. 57*f40bba94SMauro Carvalho Chehab """ 58de6f7ac9SJonathan Corbet self.parameterlist = names 59de6f7ac9SJonathan Corbet self.parameterdescs = descs 60de6f7ac9SJonathan Corbet self.parametertypes = types 61de6f7ac9SJonathan Corbet self.parameterdesc_start_lines = starts 62