kdoc_item.py 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. """
  7. Data class to store a kernel-doc Item.
  8. """
  9. class KdocItem:
  10. """
  11. A class that will, eventually, encapsulate all of the parsed data that we
  12. then pass into the output modules.
  13. """
  14. def __init__(self, name, fname, type, start_line, **other_stuff):
  15. self.name = name
  16. self.fname = fname
  17. self.type = type
  18. self.declaration_start_line = start_line
  19. self.sections = {}
  20. self.sections_start_lines = {}
  21. self.parameterlist = []
  22. self.parameterdesc_start_lines = []
  23. self.parameterdescs = {}
  24. self.parametertypes = {}
  25. #
  26. # Just save everything else into our own dict so that the output
  27. # side can grab it directly as before. As we move things into more
  28. # structured data, this will, hopefully, fade away.
  29. #
  30. self.other_stuff = other_stuff
  31. def get(self, key, default = None):
  32. """
  33. Get a value from optional keys.
  34. """
  35. return self.other_stuff.get(key, default)
  36. def __getitem__(self, key):
  37. return self.get(key)
  38. #
  39. # Tracking of section and parameter information.
  40. #
  41. def set_sections(self, sections, start_lines):
  42. """
  43. Set sections and start lines.
  44. """
  45. self.sections = sections
  46. self.section_start_lines = start_lines
  47. def set_params(self, names, descs, types, starts):
  48. """
  49. Set parameter list: names, descriptions, types and start lines.
  50. """
  51. self.parameterlist = names
  52. self.parameterdescs = descs
  53. self.parametertypes = types
  54. self.parameterdesc_start_lines = starts