Skip to content
Snippets Groups Projects
Commit 99343629 authored by timeless's avatar timeless
Browse files

docchecker: report context line at most once

parent 7a1ad08b
No related merge requests found
......@@ -10,7 +10,12 @@
import re
leadingline = re.compile(r'(^\s*)(\S.*)$')
hg_backtick = re.compile(r""":hg:`[^`]*'[^`]*`""")
hg_cramped = re.compile(r'\w:hg:`')
checks = [
(r""":hg:`[^`]*'[^`]*`""",
"""warning: please avoid nesting ' in :hg:`...`"""),
(r'\w:hg:`',
'warning: please have a space before :hg:'),
]
def check(line):
......@@ -15,4 +20,8 @@
def check(line):
if hg_backtick.search(line):
messages = []
for match, msg in checks:
if re.search(match, line):
messages.append(msg)
if messages:
print(line)
......@@ -18,8 +27,6 @@
print(line)
print("""warning: please avoid nesting ' in :hg:`...`""")
if hg_cramped.search(line):
print(line)
print('warning: please have a space before :hg:')
for msg in messages:
print(msg)
def work(file):
(llead, lline) = ('', '')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment