Don't hardcode line numbers in script documentation check

develop
lethosor 2015-12-28 16:31:36 -05:00
parent 9dbb5b92f9
commit 6637a85164
1 changed files with 4 additions and 1 deletions

@ -1,3 +1,4 @@
from __future__ import print_function
from io import open from io import open
import os import os
from os.path import basename, dirname, join, splitext from os.path import basename, dirname, join, splitext
@ -16,6 +17,8 @@ def check_file(fname):
errors, doclines = 0, [] errors, doclines = 0, []
with open(fname, errors='ignore') as f: with open(fname, errors='ignore') as f:
for l in f.readlines(): for l in f.readlines():
if not l.strip():
continue
if doclines or l.strip().endswith('=begin'): if doclines or l.strip().endswith('=begin'):
doclines.append(l.rstrip()) doclines.append(l.rstrip())
if l.startswith('=end'): if l.startswith('=end'):
@ -26,7 +29,7 @@ def check_file(fname):
else: else:
print('Error: no documentation in: ' + fname) print('Error: no documentation in: ' + fname)
return 1 return 1
title, underline = doclines[2], doclines[3] title, underline = doclines[1], doclines[2]
if underline != '=' * len(title): if underline != '=' * len(title):
print('Error: title/underline mismatch:', fname, title, underline) print('Error: title/underline mismatch:', fname, title, underline)
errors += 1 errors += 1