Mercurial > hg-stable
changeset 28810:9934362978e1
docchecker: report context line at most once
author | timeless <timeless@mozdev.org> |
---|---|
date | Thu, 03 Mar 2016 03:32:44 +0000 |
parents | 7a1ad08b9ff5 |
children | 1a623585a658 |
files | doc/docchecker |
diffstat | 1 files changed, 14 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/doc/docchecker Wed Jan 06 20:45:50 2016 +0000 +++ b/doc/docchecker Thu Mar 03 03:32:44 2016 +0000 @@ -10,16 +10,23 @@ 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): - if hg_backtick.search(line): + messages = [] + for match, msg in checks: + if re.search(match, line): + messages.append(msg) + if messages: 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) = ('', '')