(fname)
| 30 | |
| 31 | |
| 32 | def check_file(fname): |
| 33 | errors, doc_start_line = 0, None |
| 34 | docfile = join(DOCS_PATH, get_cmd(fname)+'.rst') |
| 35 | if not exists(docfile): |
| 36 | print_error('missing documentation file: {!r}'.format(docfile), fname) |
| 37 | return 1 |
| 38 | with open(docfile, errors='ignore') as f: |
| 39 | lines = f.readlines() |
| 40 | if not lines: |
| 41 | print_error('empty documentation file', docfile) |
| 42 | return 1 |
| 43 | for i, l in enumerate(lines): |
| 44 | l = l.strip() |
| 45 | if l and not doc_start_line and doc_start_line != 0: |
| 46 | doc_start_line = i |
| 47 | doc_end_line = i |
| 48 | lines[i] = l |
| 49 | |
| 50 | errors += check_ls(docfile, lines) |
| 51 | title, underline = lines[doc_start_line:doc_start_line+2] |
| 52 | expected_underline = '=' * len(title) |
| 53 | if underline != expected_underline: |
| 54 | print_error('title/underline mismatch: expected {!r}, got {!r}'.format( |
| 55 | expected_underline, underline), |
| 56 | docfile, doc_start_line+1) |
| 57 | errors += 1 |
| 58 | if title != get_cmd(fname): |
| 59 | print_error('expected script title {!r}, got {!r}'.format( |
| 60 | get_cmd(fname), title), |
| 61 | docfile, doc_start_line) |
| 62 | errors += 1 |
| 63 | return errors |
| 64 | |
| 65 | |
| 66 | def main(): |
no test coverage detected