##// END OF EJS Templates
docchecker: try to reject single quotes
timeless -
r28811:1a623585 default
parent child Browse files
Show More
@@ -1,61 +1,63 b''
1 1 #!/usr/bin/env python
2 2 #
3 3 # docchecker - look for problematic markup
4 4 #
5 5 # Copyright 2016 timeless <timeless@mozdev.org> and others
6 6 #
7 7 # This software may be used and distributed according to the terms of the
8 8 # GNU General Public License version 2 or any later version.
9 9 import sys
10 10 import re
11 11
12 12 leadingline = re.compile(r'(^\s*)(\S.*)$')
13 13
14 14 checks = [
15 15 (r""":hg:`[^`]*'[^`]*`""",
16 16 """warning: please avoid nesting ' in :hg:`...`"""),
17 17 (r'\w:hg:`',
18 18 'warning: please have a space before :hg:'),
19 (r"""(?:[^a-z][^'.])hg ([^,;"`]*'(?!hg)){2}""",
20 '''warning: please use " instead of ' for hg ... "..."'''),
19 21 ]
20 22
21 23 def check(line):
22 24 messages = []
23 25 for match, msg in checks:
24 26 if re.search(match, line):
25 27 messages.append(msg)
26 28 if messages:
27 29 print(line)
28 30 for msg in messages:
29 31 print(msg)
30 32
31 33 def work(file):
32 34 (llead, lline) = ('', '')
33 35
34 36 for line in file:
35 37 # this section unwraps lines
36 38 match = leadingline.match(line)
37 39 if not match:
38 40 check(lline)
39 41 (llead, lline) = ('', '')
40 42 continue
41 43
42 44 lead, line = match.group(1), match.group(2)
43 45 if (lead == llead):
44 46 if (lline != ''):
45 47 lline += ' ' + line
46 48 else:
47 49 lline = line
48 50 else:
49 51 check(lline)
50 52 (llead, lline) = (lead, line)
51 53 check(lline)
52 54
53 55 def main():
54 56 for f in sys.argv[1:]:
55 57 try:
56 58 with open(f) as file:
57 59 work(file)
58 60 except BaseException as e:
59 61 print("failed to process %s: %s" % (f, e))
60 62
61 63 main()
@@ -1,4 +1,6 b''
1 1 #require docutils gettext
2 2
3 3 $ $TESTDIR/check-gendoc ja
4 4 checking for parse errors
5 \xe8\xa4\x87\xe8\xa3\xbd\xef\xbc\x8f\xe6\x94\xb9\xe5\x90\x8d\xe3\x81\xab\xe9\x96\xa2\xe3\x81\x99\xe3\x82\x8b\xe5\xb1\xa5\xe6\xad\xb4\xe4\xbf\x9d\xe5\xad\x98\xe3\x81\xae\xe3\x81\x9f\xe3\x82\x81\xe3\x81\xab git \xe5\xb7\xae\xe5\x88\x86\xe5\xbd\xa2\xe5\xbc\x8f\xe3\x82\x92\xe4\xbd\xbf\xe7\x94\xa8(-g/--git \xe6\x8c\x87\xe5\xae\x9a\xe3\x82\x84 \xe8\xa8\xad\xe5\xae\x9a\xe3\x83\x95\xe3\x82\xa1\xe3\x82\xa4\xe3\x83\xab\xe3\x81\xa7\xe3\x81\xae [diff] git=1 \xe8\xa8\x98\xe8\xbf\xb0)\xe3\x81\x99\xe3\x82\x8b\xe3\x81\xae\xe3\x81\xa7\xe3\x81\x82\xe3\x82\x8c\xe3\x81\xb0\xe3\x80\x81 add/remove/copy/rename \xe3\x81\xa8\xe3\x81\x84\xe3\x81\xa3\xe3\x81\x9f hg \xe3\x81\xae\xe3\x82\xb3\xe3\x83\x9e\xe3\x83\xb3\xe3\x83\x89\xe3\x81\xab\xe3\x82\x88\xe3\x82\x8b\xe5\xb1\xa5\xe6\xad\xb4\xe8\xa8\x98\xe9\x8c\xb2\xe3\x82\x82\xe3\x80\x81 \xe9\x80\x9a\xe5\xb8\xb8\xe3\x81\xa8\xe5\xa4\x89\xe3\x82\x8f\xe3\x82\x8a\xe3\x81\xaa\xe3\x81\x8f\xe6\xa9\x9f\xe8\x83\xbd\xe3\x81\x97\xe3\x81\xbe\xe3\x81\x99\xe3\x80\x82 git \xe5\xb7\xae\xe5\x88\x86\xe5\xbd\xa2\xe5\xbc\x8f\xe3\x81\xae\xe8\xa9\xb3\xe7\xb4\xb0\xe3\x81\xab\xe9\x96\xa2\xe3\x81\x97\xe3\x81\xa6\xe3\x81\xaf\xe3\x80\x81 'help diffs' \xe3\x82\x92\xe5\x8f\x82\xe7\x85\xa7\xe3\x81\x97\xe3\x81\xa6\xe3\x81\x8f\xe3\x81\xa0\xe3\x81\x95\xe3\x81\x84\xe3\x80\x82 (esc)
6 warning: please use " instead of ' for hg ... "..."
General Comments 0
You need to be logged in to leave comments. Login now