This enforce a minimal formatting consistency for the documentation. The description and returns missing for a few helpers have also been added.
Unified · Split
| @@ -92,14 +92,14 @@ class HeaderParser(object): · 91 unmodified lines | ||
| 92 | 92 | |
| 93 | 93 | def parse_element(self): |
| 94 | 94 | 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) | |
| 97 | 97 | return APIElement(proto=proto, desc=desc, ret=ret) |
| 98 | 98 | |
| 99 | 99 | def parse_helper(self): |
| 100 | 100 | 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) | |
| 103 | 103 | return Helper(proto=proto, desc=desc, ret=ret) |
| 104 | 104 | |
| 105 | 105 | def parse_symbol(self): |
| @@ -129,16 +129,15 @@ class HeaderParser(object): · 23 unmodified lines | ||
| 129 | 129 | self.line = self.reader.readline() |
| 130 | 130 | return capture.group(1) |
| 131 | 131 | |
| 132 | − def parse_desc(self): | |
| 132 | + def parse_desc(self, proto): | |
| 133 | 133 | p = re.compile(' \* ?(?:\t| {5,8})Description$') |
| 134 | 134 | capture = p.match(self.line) |
| 135 | 135 | 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) | |
| 139 | 137 | # Description can be several lines, some of them possibly empty, and it |
| 140 | 138 | # stops when another subsection title is met. |
| 141 | 139 | desc = '' |
| 140 | + desc_present = False | |
| 142 | 141 | while True: |
| 143 | 142 | self.line = self.reader.readline() |
| 144 | 143 | if self.line == ' *\n': |
| @@ -147,21 +146,24 @@ class HeaderParser(object): · 2 unmodified lines | ||
| 147 | 146 | p = re.compile(' \* ?(?:\t| {5,8})(?:\t| {8})(.*)') |
| 148 | 147 | capture = p.match(self.line) |
| 149 | 148 | if capture: |
| 149 | + desc_present = True | |
| 150 | 150 | desc += capture.group(1) + '\n' |
| 151 | 151 | else: |
| 152 | 152 | break |
| 153 | + | |
| 154 | + if not desc_present: | |
| 155 | + raise Exception("No description found for " + proto) | |
| 153 | 156 | return desc |
| 154 | 157 | |
| 155 | − def parse_ret(self): | |
| 158 | + def parse_ret(self, proto): | |
| 156 | 159 | p = re.compile(' \* ?(?:\t| {5,8})Return$') |
| 157 | 160 | capture = p.match(self.line) |
| 158 | 161 | 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) | |
| 162 | 163 | # Return value description can be several lines, some of them possibly |
| 163 | 164 | # empty, and it stops when another subsection title is met. |
| 164 | 165 | ret = '' |
| 166 | + ret_present = False | |
| 165 | 167 | while True: |
| 166 | 168 | self.line = self.reader.readline() |
| 167 | 169 | if self.line == ' *\n': |
| @@ -170,9 +172,13 @@ class HeaderParser(object): · 2 unmodified lines | ||
| 170 | 172 | p = re.compile(' \* ?(?:\t| {5,8})(?:\t| {8})(.*)') |
| 171 | 173 | capture = p.match(self.line) |
| 172 | 174 | if capture: |
| 175 | + ret_present = True | |
| 173 | 176 | ret += capture.group(1) + '\n' |
| 174 | 177 | else: |
| 175 | 178 | break |
| 179 | + | |
| 180 | + if not ret_present: | |
| 181 | + raise Exception("No return found for " + proto) | |
| 176 | 182 | return ret |
| 177 | 183 | |
| 178 | 184 | def seek_to(self, target, help_message): |