File: ClassJsRef.py

package info (click to toggle)
libxpertmass 1.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,908 kB
  • sloc: cpp: 50,586; xml: 2,193; python: 417; ansic: 70; makefile: 33
file content (126 lines) | stat: -rw-r--r-- 2,719 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
'''This ClassJsRef module provides JS reference for a given C++ class'''

class ClassJsRef:
	'''This class acts as a storage unit for a class JS reference'''
	def __init__(self):

		self.name_space = ""
		self.class_name = ""
		# List of lines making the description
		self.description = [ ]
		# List of QpropertyJsRef instances
		self.properties = [ ]
		# List of QinvokableJsRef instances
		self.invokables = [ ]
		self.valid = False


	def __str__(self):
		return self.get_as_text("  ", 1)


	def get_description_as_text(self, tab, offset):

		lead = offset * tab

		# print(f"The description: {self.description}\n")
		# print(f"The description has {len(self.description)} items.")

		output_text = ""

		for line in self.description:

			# print(f"Appending class description line: '{line}")

			output_text = f"{output_text}{lead}{line}"

			# print(f"Now output_text is:\n{output_text}")

		return output_text


	def print_description(self, tab, offset):

		print(f"{self.get_description_as_text(tab, offset)}")


	def get_properties_as_text(self, tab, offset):

		output_text = ""

		for property  in self.properties:
			output_text = f"{output_text}{property.get_as_text(tab, offset)}"

		# print(f"Returning properties as text: {output_text}")

		return output_text


	def print_properties(self, tab, offset):

		print(f"{self.get_properties_as_text(tab, offset)}")


	def get_invokables_as_text(self, tab, offset):

		output_text = ""

		for invokable  in self.invokables:
			output_text = f"{output_text}{invokable.get_as_text(tab, offset)}"

		return output_text


	def print_invokables(self, tab, offset):

		print(f"{self.get_invokables_as_text(tab, offset)}")


	def get_as_text(self, tab, offset):

		lead = offset * tab

		output_text = f"{lead}{self.name_space} {self.class_name}:\n\n"

		offset += 1
		lead = offset * tab

		if len(self.description):

			output_text = f"{output_text}{lead}Description:\n\n"

			indented_offset = offset + 1

			output_text = f"{output_text}{self.get_description_as_text(tab, indented_offset)}\n"

		if len(self.properties):

			output_text = f"{output_text}{lead}Properties: {len(self.properties)}\n\n"

			indented_offset = offset + 1

			output_text = f"{output_text}{self.get_properties_as_text(tab, indented_offset)}\n"

			#print(f"Got {output_text} for properties text.")

		if len(self.invokables):

			output_text = f"{output_text}{lead}Invokables: {len(self.invokables)}\n\n"

			indented_offset = offset + 1

			output_text = f"{output_text}{self.get_invokables_as_text(tab, indented_offset)}\n"

			# print(f"Got {output_text} for invokables text.")

		return output_text


	def print(self, tab, offset):

		print(f"{self.get_as_text(tab, offset)}")