History

bpf/scripts: Make description and returns section for helpers/syscalls mandatory

This enforce a minimal formatting consistency for the documentation. The description and returns missing for a few helpers have also been added.

Usama Arif committed 4 years ago

Commit f1f3f671 parent e40fbbf1 file · +18 −12Browse files

Showing the changes to scripts (1 of 1 file). Show all

Unified · Split

scripts/bpf_doc.py+18−12
@@ -92,14 +92,14 @@ class HeaderParser(object): · 91 unmodified lines
9292
9393 def parse_element(self):
9494 proto = self.parse_symbol()
95− desc = self.parse_desc()
96− ret = self.parse_ret()
95+ desc = self.parse_desc(proto)
96+ ret = self.parse_ret(proto)
9797 return APIElement(proto=proto, desc=desc, ret=ret)
9898
9999 def parse_helper(self):
100100 proto = self.parse_proto()
101− desc = self.parse_desc()
102− ret = self.parse_ret()
101+ desc = self.parse_desc(proto)
102+ ret = self.parse_ret(proto)
103103 return Helper(proto=proto, desc=desc, ret=ret)
104104
105105 def parse_symbol(self):
@@ -129,16 +129,15 @@ class HeaderParser(object): · 23 unmodified lines
129129 self.line = self.reader.readline()
130130 return capture.group(1)
131131
132− def parse_desc(self):
132+ def parse_desc(self, proto):
133133 p = re.compile(' \* ?(?:\t| {5,8})Description$')
134134 capture = p.match(self.line)
135135 if not capture:
136− # Helper can have empty description and we might be parsing another
137− # attribute: return but do not consume.
138− return ''
136+ raise Exception("No description section found for " + proto)
139137 # Description can be several lines, some of them possibly empty, and it
140138 # stops when another subsection title is met.
141139 desc = ''
140+ desc_present = False
142141 while True:
143142 self.line = self.reader.readline()
144143 if self.line == ' *\n':
@@ -147,21 +146,24 @@ class HeaderParser(object): · 2 unmodified lines
147146 p = re.compile(' \* ?(?:\t| {5,8})(?:\t| {8})(.*)')
148147 capture = p.match(self.line)
149148 if capture:
149+ desc_present = True
150150 desc += capture.group(1) + '\n'
151151 else:
152152 break
153+
154+ if not desc_present:
155+ raise Exception("No description found for " + proto)
153156 return desc
154157
155− def parse_ret(self):
158+ def parse_ret(self, proto):
156159 p = re.compile(' \* ?(?:\t| {5,8})Return$')
157160 capture = p.match(self.line)
158161 if not capture:
159− # Helper can have empty retval and we might be parsing another
160− # attribute: return but do not consume.
161− return ''
162+ raise Exception("No return section found for " + proto)
162163 # Return value description can be several lines, some of them possibly
163164 # empty, and it stops when another subsection title is met.
164165 ret = ''
166+ ret_present = False
165167 while True:
166168 self.line = self.reader.readline()
167169 if self.line == ' *\n':
@@ -170,9 +172,13 @@ class HeaderParser(object): · 2 unmodified lines
170172 p = re.compile(' \* ?(?:\t| {5,8})(?:\t| {8})(.*)')
171173 capture = p.match(self.line)
172174 if capture:
175+ ret_present = True
173176 ret += capture.group(1) + '\n'
174177 else:
175178 break
179+
180+ if not ret_present:
181+ raise Exception("No return found for " + proto)
176182 return ret
177183
178184 def seek_to(self, target, help_message):