(filename, errors)
| 209 | |
| 210 | |
| 211 | def _make_error_msg(filename, errors): |
| 212 | with open(filename) as f: |
| 213 | lines = f.readlines() |
| 214 | relative_name = filename[len(EXAMPLES_DIR) + 1 :] |
| 215 | failure_message = [ |
| 216 | 'The file "%s" contains invalid RST: ' % relative_name, |
| 217 | '', |
| 218 | ] |
| 219 | for error in errors: |
| 220 | # This may not always be super helpful because you sometimes need |
| 221 | # more than one line of context to understand what went wrong, |
| 222 | # but by giving you the filename and the line number, it's usually |
| 223 | # enough to track down what went wrong. |
| 224 | line_number = min(error['line_number'], len(lines)) |
| 225 | line_number -= 1 |
| 226 | if line_number > 0: |
| 227 | line_number -= 1 |
| 228 | current_message = [ |
| 229 | 'Line %s: %s' % (error['line_number'], error['msg']), |
| 230 | ' %s' % lines[line_number], |
| 231 | ] |
| 232 | failure_message.extend(current_message) |
| 233 | return '\n'.join(failure_message) |
| 234 | |
| 235 | |
| 236 | def verify_cli_commands_valid(filename, command_validator): |
no outgoing calls
no test coverage detected