Handle the linter returning anonyomous line numbers

When sphinx (and by association restructuredtext-lint)
finds an error with say a anonymous backref it does not
include the line number (it defaults to none); so in this
case covert that line number to ? and output that as the
line number in the output shown to the user.

Change-Id: I013857cdb6a24cf11d94265358b8294dfed0236d
This commit is contained in:
Joshua Harlow 2015-03-05 14:51:10 -08:00
parent 4d82c269ab
commit 7ad4aaec88
2 changed files with 2 additions and 2 deletions

View File

@ -110,8 +110,6 @@ class CheckValidity(ContentCheck):
def report_iter(self, parsed_file): def report_iter(self, parsed_file):
for error in parsed_file.errors: for error in parsed_file.errors:
if error.line is None:
continue
if error.level not in self.WARN_LEVELS: if error.level not in self.WARN_LEVELS:
continue continue
ignore = False ignore = False

View File

@ -226,6 +226,8 @@ def validate(cfg, files):
for line_num, code, message in c.report_iter(f): for line_num, code, message in c.report_iter(f):
if code in ignoreables: if code in ignoreables:
continue continue
if not isinstance(line_num, (float, int)):
line_num = "?"
if cfg.get('verbose'): if cfg.get('verbose'):
print(' - %s:%s: %s %s' print(' - %s:%s: %s %s'
% (f.filename, line_num, code, message)) % (f.filename, line_num, code, message))