Skip long line check for rst definition list term

The definition list term cannot have more than one line of text.
On the other hand, we sometimes need to use the long term in the
definition lists. This change skips "D001 Line too long" check for
the definition terms in the definition lists.

Change-Id: Ieb272e506034eac7129c24ee0e0fbc40b55d11b1
Closes-Bug: #1533238
This commit is contained in:
KATO Tomoyuki 2016-01-24 22:12:57 +09:00
parent b2c19dd214
commit bccc2998ef
1 changed files with 18 additions and 0 deletions

View File

@ -206,6 +206,24 @@ class CheckMaxLineLength(ContentCheck):
directives.append((i, find_directive_end(i, lines)))
elif re.match(r"^::\s*$", line):
directives.append((i, find_directive_end(i, lines)))
# Find definition terms in definition lists
# This check may match the code, which is already appended
lwhitespaces = r"^\s*"
listspattern = r"^\s*(\* |- |#\. |\d+\. )"
for i in range(0, len(lines) - 1):
line = lines[i]
next_line = lines[i + 1]
# if line is a blank, line is not a definition term
if all_whitespace(line):
continue
# if line is a list, line is checked as normal line
if re.match(listspattern, line):
continue
if (len(re.search(lwhitespaces, line).group()) <
len(re.search(lwhitespaces, next_line).group())):
directives.append((i, i))
return directives
def _txt_checker(self, parsed_file):