Browse Source

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
Joshua Harlow 4 years ago
parent
commit
7ad4aaec88
2 changed files with 2 additions and 2 deletions
  1. 0
    2
      doc8/checks.py
  2. 2
    0
      doc8/main.py

+ 0
- 2
doc8/checks.py View File

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

+ 2
- 0
doc8/main.py View File

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

Loading…
Cancel
Save