From 7ad4aaec88c130723409bc85ff3a3e6af53be574 Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Thu, 5 Mar 2015 14:51:10 -0800 Subject: [PATCH] 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 --- doc8/checks.py | 2 -- doc8/main.py | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc8/checks.py b/doc8/checks.py index 648e499..9d8578a 100644 --- a/doc8/checks.py +++ b/doc8/checks.py @@ -110,8 +110,6 @@ class CheckValidity(ContentCheck): def report_iter(self, parsed_file): for error in parsed_file.errors: - if error.line is None: - continue if error.level not in self.WARN_LEVELS: continue ignore = False diff --git a/doc8/main.py b/doc8/main.py index 2f34527..19b5171 100644 --- a/doc8/main.py +++ b/doc8/main.py @@ -226,6 +226,8 @@ def validate(cfg, files): for line_num, code, message in c.report_iter(f): if code in ignoreables: continue + if not isinstance(line_num, (float, int)): + line_num = "?" if cfg.get('verbose'): print(' - %s:%s: %s %s' % (f.filename, line_num, code, message))